Python discord.py和youtube“u-dl”;“读取错误”;及;由于某种原因,该会议已无效。”;

Python discord.py和youtube“u-dl”;“读取错误”;及;由于某种原因,该会议已无效。”;,python,youtube,discord,discord.py,youtube-dl,Python,Youtube,Discord,Discord.py,Youtube Dl,我在discord.py和youtube_dl中遇到了这个问题,在队列中播放youtube链接时会出现一个错误,似乎会“滚雪球”到队列中的其他歌曲中。第一首歌通常播放得很好,但其余的歌在很短的时间内就会出现这种错误。这就是错误: [tls @ 000001e5618bc200] Error in the pull function. [matroska,webm @ 000001e5613f9740] Read error [tls @ 000001e5618bc200] The specifi

我在discord.py和youtube_dl中遇到了这个问题,在队列中播放youtube链接时会出现一个错误,似乎会“滚雪球”到队列中的其他歌曲中。第一首歌通常播放得很好,但其余的歌在很短的时间内就会出现这种错误。这就是错误:

[tls @ 000001e5618bc200] Error in the pull function.
[matroska,webm @ 000001e5613f9740] Read error
[tls @ 000001e5618bc200] The specified session has been invalidated for some reason.
Last message repeated 1 times
[really long link] I/O error
这是我的YTDL源代码和队列函数代码:

class YTDLSource(discord.PCMVolumeTransformer):
    def __init__(self, source, *, data, volume=0.5):
        super().__init__(source, volume)

        self.data = data

        self.title = data.get('title')
        self.url = data.get('url')

    @classmethod
    async def from_url(cls, url, *, loop=None, stream=False):
        loop = loop or asyncio.get_event_loop()
        data = await loop.run_in_executor(None, lambda: ytdl.extract_info(url, download=not stream))

        if 'entries' in data:
            # take first item from a playlist
            data = data['entries'][0]

        filename = data['url'] if stream else ytdl.prepare_filename(data)
        return cls(discord.FFmpegPCMAudio(filename, **ffmpeg_options), data=data)



queues = {}

class Music(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

    @commands.command()
    async def q(self, ctx, *, url):
        channel = discord.utils.get(ctx.guild.voice_channels, name="Melodies of Arts")

        if ctx.voice_client is None:
            await channel.connect()


        def check_queue(error):
            if(queues[ctx.guild.id] != []):
                player = queues[ctx.guild.id].pop(0)
                ctx.voice_client.play(player, after=check_queue)     

        async with ctx.typing():
            player = await YTDLSource.from_url(url, loop=self.bot.loop, stream=True)

            if ctx.guild.id in queues:
                queues[ctx.guild.id].append(player)
            else:
                queues[ctx.guild.id] = [player]

            await ctx.send("Video __" + str(player.title) + "__" + " queued at **Position #" + str(len(queues[ctx.guild.id])) + "**", delete_after=15)

            if(not ctx.voice_client.is_playing()):
                ctx.voice_client.play(player, after=check_queue)
                await ctx.send('***Now playing:*** __{}__'.format(player.title), delete_after=10)
一个Github发布页面建议“重新下载url”,但我正在使用youtube_dl对链接进行流式传输,如果可能的话,我希望避免下载视频。很多Github问题似乎都太过时了,所以任何和代码相关的解决方案都不再有效。如果我需要提供更多代码/信息,请告诉我

正如人们常说的,“这真的不是你的错”。这通常发生在YouTube端

看看:


另外,请检查您是否使用https进行了呼叫。YouTube不再接受
http
连接。

为确保不会发生这种情况,请在ffmpeg选项中添加此选项:

'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5'

这将使它重新连接,音乐不会停止。

这是否意味着我必须下载视频以确保不会发生此错误?是否要继续?是的,任何外部服务机构都可能决定不为您提供服务。如果你认为这只是你所说的方式,而且YouTube改变了它的术语,它就会中断,那么你可以对它进行流式处理。