Answers for "how to download from youtube in discord.py"

0

how to download from youtube in discord.py

import discord
from discord.ext import commands
import youtube_dl

client = commands.Bot(command_prefix = '!', intents=intents)

@client.command(pass_context = True)
async def download(ctx, url:str):

  ydl_opts = {
              'format': 'bestaudio/best',
              'preferredcodec': [{
                  'key': 'FFmpegExtractAudio',
                  'preferredcodec': 'webm',
                  'preferredquality': '192',
          }],
          }
  
  with youtube_dl.YoutubeDL(ydl_opts) as ydl:
    ydl.download([url])

client.run(TOKEN)
Posted by: Guest on September-24-2021

Code answers related to "how to download from youtube in discord.py"

Python Answers by Framework

Browse Popular Code Answers by Language