Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

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)
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #download #youtube
ADD COMMENT
Topic
Name
1+9 =