【发布时间】:2021-02-07 20:06:28
【问题描述】:
错误:
youtube_dl.utils.DownloadError: ERROR: query "song": 无法解析 JSON(由 JSONDecodeError('Expecting value: line 1 column 1 (char 0)') 引起)
播放命令:
@commands.command(name='play',aliases=['p'] )
async def _play(self, ctx: commands.Context, *, search: str):
async with ctx.typing():
try:
source = await YTDLSource.create_source(ctx, search, loop=self.bot.loop)
except YTDLError as e:
await ctx.send('Error: {}'.format(str(e)))
else:
song = Song(source)
await ctx.voice_state.songs.put(song)
Youtube-DL 类:
class YTDLSource(discord.PCMVolumeTransformer):
YTDL_OPTIONS = {
'format': 'bestaudio/best',
'extractaudio': True,
'audioformat': 'mp3',
'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',
}
FFMPEG_OPTIONS = {
'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5',
'options': '-vn',
}
ytdl = youtube_dl.YoutubeDL(YTDL_OPTIONS)
请指导我如何解决这个错误 这个错误是上周开始的,我的 youtube_dl 也更新了
如果您需要其他代码,请告诉我,但请解决我的问题
我也不知道如何获取包括堆栈跟踪在内的错误消息
【问题讨论】:
标签: python discord discord.py youtube-dl ytdl