1
0
mirror of https://github.com/ytdl-org/youtube-dl.git synced 2024-11-24 15:50:26 +01:00

[YoutubeDL] Calculate thumbnail IDs automatically

This commit is contained in:
Philipp Hagemeister 2015-02-03 10:52:22 +01:00
parent d862042301
commit f6c24009be

View File

@ -964,9 +964,11 @@ class YoutubeDL(object):
thumbnails.sort(key=lambda t: ( thumbnails.sort(key=lambda t: (
t.get('preference'), t.get('width'), t.get('height'), t.get('preference'), t.get('width'), t.get('height'),
t.get('id'), t.get('url'))) t.get('id'), t.get('url')))
for t in thumbnails: for i, t in enumerate(thumbnails):
if 'width' in t and 'height' in t: if 'width' in t and 'height' in t:
t['resolution'] = '%dx%d' % (t['width'], t['height']) t['resolution'] = '%dx%d' % (t['width'], t['height'])
if t.get('id') is None:
t['id'] = '%d' % i
if thumbnails and 'thumbnail' not in info_dict: if thumbnails and 'thumbnail' not in info_dict:
info_dict['thumbnail'] = thumbnails[-1]['url'] info_dict['thumbnail'] = thumbnails[-1]['url']