youtube-dl only extract playlist info

送分小仙女□ 提交于 2020-08-04 23:19:02

问题


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'])

code output like this

[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'

but i want only youtube playlist info my question is how can i get playlist's uploader ,thumnail,all videos thumbnails,videos titles,playlist title etc.


回答1:


You can import youtube_dl,invoke youtube_dl as ydl and set download=False, here is an example

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)

you can use 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)

you will see the ie_result only contain information



来源:https://stackoverflow.com/questions/38708313/youtube-dl-only-extract-playlist-info

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!