- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我试图制作一个供个人使用的不和谐音乐机器人,因为 groovy 和 rythm 被关闭了。
我猜它工作正常,但我遇到了 ytdl 的问题。
输入“-play”和一个 url 就像预期的那样工作,但我不能输入“-play 'song name'”。
输入“-play example”给我这个:
[download] Downloading playlist: example
[youtube:search] query "example": Downloading page 1
[youtube:search] playlist example: Downloading 1 videos
[download] Downloading video 1 of 1
[youtube] CLXt3yh2g0s: Downloading webpage
Ignoring exception in command play:
[download] Finished downloading playlist: example
Traceback (most recent call last):
File "C:\Users\Dennis\PycharmProjects\groovy's true successor\venv\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "C:\Users\Dennis\PycharmProjects\groovy's true successor\voice.py", line 53, in play
url2 = info['formats'][0]['url']
KeyError: 'formats'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\Dennis\PycharmProjects\groovy's true successor\venv\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\Dennis\PycharmProjects\groovy's true successor\venv\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\Dennis\PycharmProjects\groovy's true successor\venv\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: KeyError: 'formats'
我对编码相当陌生,所以如果有什么奇怪的理解,我很抱歉。
@client.command()
async def play(ctx, url):
channel = ctx.author.voice.channel
voice = discord.utils.get(client.voice_clients, guild=ctx.guild)
if voice and voice.is_connected():
pass
else:
await channel.connect()
ffmpeg_opts = {'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5', 'options': '-vn'}
ydl_opts = {'format': "bestaudio/best", 'default_search': 'auto'}
vc = ctx.voice_client
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
info = ydl.extract_info(url, download=False)
url2 = info['formats'][0]['url']
source = await discord.FFmpegOpusAudio.from_probe(url2, **ffmpeg_opts)
vc.play(source)
最佳答案
#takes the entire text instead of just the first word
async def play(ctx, *,url):
#i would remove 'default_search': 'auto' and do this
ydl_opts = {'format': "bestaudio/best"}
vc = ctx.voice_client
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
url = ydl.extract_info("ytsearch:%s" % name, download = False)['entries'][0]
关于python - ytdl python "KeyError: formats",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69237607/
我试图制作一个供个人使用的不和谐音乐机器人,因为 groovy 和 rythm 被关闭了。 我猜它工作正常,但我遇到了 ytdl 的问题。 输入“-play”和一个 url 就像预期的那样工作,但我不
我已经下载了 ytdl-core,我正在将它与 discord.js 一起使用。我有一个命令可以将 YouTube 视频的音频播放到语音聊天中。有谁知道我可以从链接中获取视频标题字符串的方法,或者获取
我正在使用 ytdl-core 和 node-opus 向我的机器人添加音乐功能。我也在关注教程。在我开始添加排队功能之前,该机器人运行良好。当我整合排队时,机器人仍然可以加入和离开语音 channe
我的 Discord 机器人命令之一是在当前用户的语音 channel 中播放预定义的音乐剪辑。机器人可以连接,但不是播放歌曲,而是立即离开。我已经尝试同时使用 connection.playStre
当我尝试在 ytdl-core 中从 YouTube 中提取音乐时,控制台上出现 404 错误。这个错误来自 miniget 包。 ytdl-core 正在使用 miniget。 代码: ytdl("
我正在尝试使用 ytdl-core 模块 ( https://github.com/fent/node-ytdl-core ) 下载 Youtube 视频音频。 我使用 Express 编写了一个 A
我正在尝试使用 ytdl 和 discord.js 下载并播放从 youtube 获取的音频文件: ytdl(url) .pipe(fs.createWrite
我制作了一个 api,它正在从 youtube 链接下载视频,但我无法下载其音频高于 360p 格式的视频。它只下载视频,没有音频。 有什么解决办法吗? 最佳答案 通常 1080p 或更好的视频没有用
我想让用户能够使用 node-ytdl 下载 YouTube 视频。例如,当客户端对特定路由发出 GET 请求时,应下载视频作为响应。 var ytdl = require('ytdl-core'
我使用 ytdl 构建了一个 discord bot,它工作正常但随机出现此错误,我无法找出原因:(我用 ... 截断了链接,因为它太长了) [https @ 000001ead63ee980] HT
我构建了一个简单的 youtube 下载器 cli。它看起来像这样(没有任何 arg 解析以便于复制): const ytdl = require('ytdl-core'); const config
我是一名优秀的程序员,十分优秀!