python 错误:无法提取上传者ID - Youtube,Discord.py

rekjcdws  于 2023-02-21  发布在  Python
关注(0)|答案(2)|浏览(1056)

我有一个veary powerfull bot在discord(discord.py,PYTHON),它可以播放音乐的语音通道。它从youtube(youtube_dl)的音乐。它工作完美之前,但现在它不想与任何视频工作。我试着updataing youtube_dl,但它仍然不工作我到处都找不到,但我仍然找不到一个答案,可能会帮助我。这是错误:Error: Unable to extract uploader id在错误日志之后和之前没有更多的信息。有人能帮忙吗?
我会留下一些代码,我用我的机器人... YouTube的设置设置:

youtube_dl.utils.bug_reports_message = lambda: ''

ytdl_format_options = {
    'format': 'bestaudio/best',
    'outtmpl': '%(extractor)s-%(id)s-%(title)s.%(ext)s',
    'restrictfilenames': True,
    'noplaylist': True,
    'nocheckcertificate': True,
    'ignoreerrors': False,
    'logtostderr': False,
    'quiet': True,
    'no_warnings': True,
    'default_search': 'auto',
    'source_address': '0.0.0.0',  # bind to ipv4 since ipv6 addresses cause issues sometimes
}

ffmpeg_options = {
    'options': '-vn',
}

ytdl = youtube_dl.YoutubeDL(ytdl_format_options)

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')
        self.duration = data.get('duration')
        self.image = data.get("thumbnails")[0]["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))
        #print(data)

        if 'entries' in data:
            # take first item from a playlist
            data = data['entries'][0]
        #print(data["thumbnails"][0]["url"])
        #print(data["duration"])
        filename = data['url'] if stream else ytdl.prepare_filename(data)
        return cls(discord.FFmpegPCMAudio(filename, **ffmpeg_options), data=data)

近似命令运行音频(从我的机器人):

sessionChanel = message.author.voice.channel
await sessionChannel.connect()
url = matched.group(1)
player = await YTDLSource.from_url(url, loop=client.loop, stream=True)
sessionChannel.guild.voice_client.play(player, after=lambda e: print(
                                       f'Player error: {e}') if e else None)
n9vozmp4

n9vozmp41#

他们已经意识到并修复了这个问题,你可以检查这个GitHub issue
如果你想快速修复,你可以使用this软件包,或者只是等待一个新的版本,这取决于你。

crcmnpdw

crcmnpdw2#

这是已在Master中修复的已知问题。对于临时修复,

python3 -m pip install --force-reinstall https://github.com/yt-dlp/yt-dlp/archive/master.tar.gz

相关问题