嗨,我的不和谐音乐机器人有问题
@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 已经取消了很多音乐机器人,所以也许在一些新的服务条款中,discord 只是不允许从那里播放音乐。
关于python - discord py音乐机器人停止播放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70414324/