Answer the question
In order to leave comments, you need to log in
How to use the youtube_dl library to play audio without downloading?
@client.command()
@commands.has_permissions(administrator = True)
async def connect(ctx):
if(ctx.author.voice):
voice = await ctx.author.voice.channel.connect()
await ctx.send("Подключён")
url = "https://youtu.be/rLeQSd7R-jU"
source = FFmpegPCMAudio(url)
voice.play(source)
else:
await ctx.send("Что-то пошло не так!")
Answer the question
In order to leave comments, you need to log in
FFMPEG_OPTIONS = {'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5', 'options': '-vn'}
youdl_opts = {'format': 'bestaudio'}
with youtube_dl.YoutubeDL(youdl_opts) as youdl:
info = youdl.extract_info(video_link, download=False)
URL = info['formats'][0]['url']
voice = get(self.bot.voice_clients, guild=ctx.guild)
voice.play(discord.FFmpegPCMAudio(URL, **FFMPEG_OPTIONS))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question