gpt4 book ai didi

python - 使用 youtube_dl 在 discord.py bot 上播放音乐时出现错误代码 1

转载 作者:太空宇宙 更新时间:2023-11-04 01:50:54 25 4
gpt4 key购买 nike

上下文:我正在尝试创建一个 ;play <youtubeURL>我的 disord.py 机器人的命令

问题:我无法播放音乐

代码:

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'
}

ytdl = youtube_dl.YoutubeDL(ytdl_format_options)

@client.command()
async def play(ctx, url):

#I have code here that makes sure the bot is in the correct VC

guild = ctx.message.guild
voice_client = guild.voice_client

song_info = ytdl.extract_info(url, download=False)
filename = ytdl.prepare_filename(song_info)
song = discord.FFmpegPCMAudio(filename)
player = voice_client.play(song)

错误: 使用标准的 python IDE,我没有收到任何错误。但是,使用日志记录模块。我收到错误代码 1:

INFO:discord.player:Preparing to terminate ffmpeg process 21972.
INFO:discord.player:ffmpeg process 21972 successfully terminated with return code of 1.

如果您能提供任何帮助/解决方案,我们将不胜感激。

最佳答案

您要使用的文件目前不存在,因为您没有下载它,因为 extract_info 中的 download=False 参数。

关于python - 使用 youtube_dl 在 discord.py bot 上播放音乐时出现错误代码 1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58049360/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com