mirror of
https://github.com/ytdl-org/youtube-dl
synced 2024-12-23 12:40:11 +09:00
[cnn] Improve thumbnail extraction
This commit is contained in:
parent
d551980823
commit
be6d722904
@ -719,6 +719,8 @@ class YoutubeDL(object):
|
|||||||
|
|
||||||
thumbnails = info_dict.get('thumbnails')
|
thumbnails = info_dict.get('thumbnails')
|
||||||
if thumbnails:
|
if thumbnails:
|
||||||
|
thumbnails.sort(key=lambda t: (
|
||||||
|
t.get('width'), t.get('height'), t.get('url')))
|
||||||
for t in thumbnails:
|
for t in 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'])
|
||||||
|
@ -79,8 +79,11 @@ class CNNIE(InfoExtractor):
|
|||||||
|
|
||||||
self._sort_formats(formats)
|
self._sort_formats(formats)
|
||||||
|
|
||||||
thumbnails = sorted([((int(t.attrib['height']),int(t.attrib['width'])), t.text) for t in info.findall('images/image')])
|
thumbnails = [{
|
||||||
thumbs_dict = [{'resolution': res, 'url': t_url} for (res, t_url) in thumbnails]
|
'height': int(t.attrib['height']),
|
||||||
|
'width': int(t.attrib['width']),
|
||||||
|
'url': t.text,
|
||||||
|
} for t in info.findall('images/image')]
|
||||||
|
|
||||||
metas_el = info.find('metas')
|
metas_el = info.find('metas')
|
||||||
upload_date = (
|
upload_date = (
|
||||||
@ -93,8 +96,7 @@ class CNNIE(InfoExtractor):
|
|||||||
'id': info.attrib['id'],
|
'id': info.attrib['id'],
|
||||||
'title': info.find('headline').text,
|
'title': info.find('headline').text,
|
||||||
'formats': formats,
|
'formats': formats,
|
||||||
'thumbnail': thumbnails[-1][1],
|
'thumbnails': thumbnails,
|
||||||
'thumbnails': thumbs_dict,
|
|
||||||
'description': info.find('description').text,
|
'description': info.find('description').text,
|
||||||
'duration': duration,
|
'duration': duration,
|
||||||
'upload_date': upload_date,
|
'upload_date': upload_date,
|
||||||
|
Loading…
Reference in New Issue
Block a user