0

这可能是一个非常简单的问题,但我想知道如果backround我要在我的代码中使用 a 是否有类似的选项ydl_opts,例如:

    else:
        ydl_opts = {
            'format': 'bestaudio',
            'restrictfilenames': False,
            'noplaylist': True,
            'nocheckcertificate': True,
            'no_warnings': True,
            'default_search': 'auto',
            'source_address': '0.0.0.0',
            # like about here i would love to have a "backround" option
        }

        try:
            with youtube_dl.YoutubeDL(ydl_opts) as ydl:
                ydl.download([query])
                query_id = os.popen(f'youtube-dl --get-id "ytsearch:{query}"').read()
                title = os.popen(f'youtube-dl --get-title "ytsearch:{query_id}"').read()
                thumbnail_embed = os.popen(f'youtube-dl --get-thumbnail "ytsearch:{query_id}"').read()
                duration_embed = os.popen(f'youtube-dl --get-duration "ytsearch:{query_id}"').read()
                embed = discord.Embed(title="Now Playing", color=0xa00000)
                embed.set_thumbnail(url=thumbnail_embed)
                embed.add_field(name=title, value=f"`0:00 / {duration_embed}`", inline=True)
                embed.set_footer(text=f"Requested by {ctx.message.author}")
                await ctx.send(embed=embed)

        except:
            return

我真正想要的只是让它作为后台任务运行,我在文档上找不到任何关于它的内容。

感谢您的帮助!——雅各布·尚克曼

4

0 回答 0