Как зделать музыку по названию а не по ссылке? discord.py
Я делаю бота музыки и как зделать что бы он включал музыку не ток по URL ссылке? вот код:
#play
YDL_OPTIONS = {'format': 'bestaudio', 'noplaylist': 'False'}
FFMPEG_OPTIONS = {'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5', 'options': '-vn'}
server = None
list_of_song = []
@client.command(aliases = ['play', 'плей'])
async def play__(ctx, *, url):
"""Грає музику"""
global voice
if not ctx.message.author.voice:
await ctx.send('**Ви зараз не находитесь в голосовому каналі!**')
return
else:
channel = ctx.message.author.voice.channel
try:
voice = await channel.connect()
except:
pass
list_of_song.append(url)
try:
while True:
with YoutubeDL(YDL_OPTIONS) as ydl:
info = ydl.extract_info(list_of_song[0], download=False)
URL = info['url']
voice.play(discord.FFmpegPCMAudio(executable="ffmpeg\\ffmpeg.exe", source=URL, **FFMPEG_OPTIONS))
await ctx.send(':musical_note: `Музика програється` :notes:')
while voice.is_playing():
await asyncio.sleep(1)
if not voice.is_playing():
if voice.pause():
pass
else:
list_of_song.pop(0)
except:
pass
Заранее спасибо