嗨,我的不和谐音乐机器人有问题
@client.command()
async def play(ctx,*,songname):
html = urllib.request.urlopen(f"https://www.youtube.com/results?search_query={songname}")
video_ids = re.findall(r"watch\?v=(\S{11})", html.read().decode())
FFMPEG_OPTIONS = {'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5', 'options': '-vn'}
YDL_OPTIONS = {'format':"bestaudio"}
URL =f"https://www.youtube.com/watch?v={video_ids[1]}"
vc = ctx.voice_client
with youtube_dl.YoutubeDL(YDL_OPTIONS) as ydl:
info = ydl.extract_info("https://www.youtube.com/watch?v=" + video_ids[0],download=False)
url2 = info['formats'][0]['url']
source = await discord.FFmpegOpusAudio.from_probe(url2, **FFMPEG_OPTIONS)
vc.play(source)
await ctx.send(f'~(0o0*)~ **playing**:\n{URL}')
每当我在2分钟后播放一首歌时,它就会停止播放并变得柔和
这可能与此无关,但最近youtube已经关闭了很多音乐机器人,因此可能在一些新的服务条款中,不和谐只是不允许从那里播放音乐。