【问题标题】:youtube-dl only extract playlist infoyoutube-dl 仅提取播放列表信息
【发布时间】:2016-12-07 02:13:24
【问题描述】:
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 播放列表信息 我的问题是如何获取播放列表的上传者、缩略图、所有视频缩略图、视频标题、播放列表标题等。

【问题讨论】:

  • 您的r 是播放列表,而不是视频,因此它没有uploader 属性(您的错误告诉您这一点)。您可以通过将quiet 选项作为参数传递给YoutubeDL 来抑制不需要的输出。
  • 我找到了这个链接stackoverflow.com/questions/44183473/…希望这可以解决。

标签: python youtube-dl python-embedding


【解决方案1】:

你可以导入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只包含信息

【讨论】:

    猜你喜欢
    • 2018-07-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-11
    • 2014-06-04
    • 2014-01-19
    • 2021-07-13
    相关资源
    最近更新 更多