sta*_*low 5 python python-embedding youtube-dl
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'])
Run Code Online (Sandbox Code Playgroud)
代码输出是这样的
[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'
Run Code Online (Sandbox Code Playgroud)
但我只想要 youtube 播放列表信息,我的问题是如何获取播放列表的上传器、缩略图、所有视频缩略图、视频标题、播放列表标题等。
您可以将youtube_dl\xef\xbc\x8cinvoke youtube_dl 导入为 ydl 并设置 download=False,这是一个示例
download = False \nydl_opts = {\n \'outtmpl\': fileName, // output filename\n \'writesubtitles\': True,\n \'format\': \'mp4\',\n \'writethumbnail\': True\n}\n\nwith youtube_dl.YoutubeDL(ydl_opts) as ydl:\n ie_result = ydl.extract_info(url, download)\nRun Code Online (Sandbox Code Playgroud)\n\n您可以使用https://github.com/daomanlet/freesea/blob/master/sites/downloader.py
\n\nimport youtube_dl\nfrom freesea import Download\nsrv = DownloadService()\nie_result = srv.downloadVideo(\'https://www.youtube.com/channel/UCaO6VoaYJv4kS-TQO_M-N_g\',\'./\',False)\nprint(ie_result)\nRun Code Online (Sandbox Code Playgroud)\n\n你会看到 ie_result 仅包含信息
\n