Get video information from a list of playlist with youtube-dl

帅比萌擦擦* 提交于 2019-12-08 18:36:26

The variable you call video actually holds the playlist information, not the video information. You can find a list of the individual video information in the playlist's entries attribute.

See below for a possible fix. I renamed your video variable to playlist and took the freedom to rewrite it a bit and add output:

ydl_opts = {
    'ignoreerrors': True,
    'quiet': True
}

input_file = open("url")

for playlist in input_file:

    with youtube_dl.YoutubeDL(ydl_opts) as ydl:

        playlist_dict = ydl.extract_info(playlist, download=False)

        for video in playlist_dict['entries']:

            print()

            if not video:
                print('ERROR: Unable to get info. Continuing...')
                continue

            for property in ['thumbnail', 'id', 'title', 'description', 'duration']:
                print(property, '--', video.get(property))
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!