gpt4 book ai didi

python - youtube-dl 只提取播放列表信息

转载 作者:行者123 更新时间:2023-12-03 17:05:38 24 4
gpt4 key购买 nike

ydl = youtube_dl.YoutubeDL()
with ydl:
r = ydl.extract_info("myplaylist", download=False) # don't download, much faster

print(r['uploader'],r['title'],r['thumbnail'])

代码输出是这样的
[youtube:playlist] Downloading playlist playlistidhere - add --no-playlist to just download video videoid
[youtube:playlist] playlistidhere: Downloading webpage
[download] Downloading playlist: playlistnamehere
[youtube:playlist] playlist Spotlight On: June Recap: Downloading 39 videos
[download] Downloading video 1 of 39
[youtube] video_id: Downloading webpage
[youtube] video_id: Downloading video info webpage
[youtube] video_id: Extracting video information
[download] Downloading video 2 of 39
[youtube] video_id2: Downloading webpage
[youtube] video_id2: Downloading video info webpage
[youtube] video_id2: Extracting video information
[download] Downloading video 3 of 39
[youtube] video_id3: Downloading webpage
[youtube] video_id3: Downloading video info webpage
[youtube] video_id3: Extracting video information
[download] Downloading video 4 of 39
[download] Downloading video 39 of 39
[youtube] video_id4: Downloading webpage
[youtube] video_id4: Downloading video info webpage
[youtube] video_id4: Extracting video information
Traceback (most recent call last):
File "<input>", line 5, in <module>
KeyError: 'uploader'

但我只想要 YouTube 播放列表信息
我的问题是如何获得播放列表的上传器、缩略图、所有视频缩略图、视频标题、播放列表标题等。

最佳答案

您可以导入 youtube_dl ,调用 youtube_dl 为 ydl 并设置 download=False,这里是一个例子

download = False 
ydl_opts = {
'outtmpl': fileName, // output filename
'writesubtitles': True,
'format': 'mp4',
'writethumbnail': True
}

with youtube_dl.YoutubeDL(ydl_opts) as ydl:
ie_result = ydl.extract_info(url, download)

您可以使用 https://github.com/daomanlet/freesea/blob/master/sites/downloader.py
import youtube_dl
from freesea import Download
srv = DownloadService()
ie_result = srv.downloadVideo('https://www.youtube.com/channel/UCaO6VoaYJv4kS-TQO_M-N_g','./',False)
print(ie_result)

你会看到 ie_result 只包含信息

关于python - youtube-dl 只提取播放列表信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38708313/

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