这是ytdl选项:
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': False,
'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)
为了提取我尝试过的信息:
with youtube_dl.YoutubeDL(self.YDL_OPTIONS) as ydl:
info = ydl.extract_info(url, download=False)
就像这样:
data = await self.client.loop.run_in_executor(None, lambda: ytdl.extract_info(url, download=False))
但在这两种情况下,加载非常慢,它需要2分钟来加载一个100首歌曲的播放列表。所以我想提取第一首歌并播放它,同时开始下载剩下的播放列表,但我不知道怎么做,我不知道如何在ytdl的第一首就说“停止”。我听说ytdlp更快,但是我在安装上有问题,在网上找不到任何解决方案
我发现的最有趣的例子,也是许多人推荐的例子是这,它说,不是直接下载歌曲,而是通过编程实现相同的功能,即设置下载= False
这是我在安装ytdlp时遇到的错误:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MT -DPYCRYPTO_LITTLE_ENDIAN -DSYS_BITS=64 -DLTC_NO_ASM -Isrc/ -IC:\Users\Gian\PycharmProjects\provabot\venv\include -IC:
\Users\Gian\Anaconda3\include -IC:\Users\Gian\Anaconda3\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\include" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um" /Tcsrc/MD2.c /Fobuild\temp.win-amd64-3.6
\Release\src/MD2.obj
MD2.c
C:\Users\Gian\AppData\Local\Temp\pip-install-2_upmt2u\pycryptodomex\src\common.h(34): fatal error C1083: Cannot open include file: 'stdio.h': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.25.28610\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2
----------------------------------------
Command "C:\Users\Gian\PycharmProjects\provabot\venv\Scripts\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Gian\\AppData\\Local\\Temp\\pip-install-2_upmt2u\\pycryptodomex\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace
('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\Gian\AppData\Local\Temp\pip-record-19077se_\install-record.txt --single-version-externally-managed --compile --install-headers C:\Users\Gian\PycharmProjects\provabot\venv\include
\site\python3.6\pycryptodomex" failed with error code 1 in C:\Users\Gian\AppData\Local\Temp\pip-install-2_upmt2u\pycryptodomex\
发布于 2021-12-26 16:23:19
我用ytdl而不是ytdlp解决了我的问题。基本上,要打开youtube链接,可以使用以下参数
{'extract_flat': True, 'skip_download': True}
这样,除了id、title等信息外,您什么也不下载。只需获取播放列表中的所有id,然后将该id与youtube链接的第一部分连接起来即可。
"https://www.youtube.com/watch?v="+id
https://stackoverflow.com/questions/70421642
复制相似问题