[youtube] Always extract maxresdefault thumbnail

Fixes: https://github.com/ytdl-org/youtube-dl/issues/29049
This commit is contained in:
pukkandan 2021-05-18 19:15:11 +05:30
parent abcdd12b26
commit ff2751ac9c
No known key found for this signature in database
GPG Key ID: 0F00D95A001F4698
2 changed files with 17 additions and 8 deletions

View File

@ -1944,7 +1944,8 @@ def sanitize_numeric_fields(info):
t.get('preference') if t.get('preference') is not None else -1, t.get('preference') if t.get('preference') is not None else -1,
t.get('width') if t.get('width') is not None else -1, t.get('width') if t.get('width') is not None else -1,
t.get('height') if t.get('height') is not None else -1, t.get('height') if t.get('height') is not None else -1,
t.get('id') if t.get('id') is not None else '', t.get('url'))) t.get('id') if t.get('id') is not None else '',
t.get('url')))
for i, t in enumerate(thumbnails): for i, t in enumerate(thumbnails):
t['url'] = sanitize_url(t['url']) t['url'] = sanitize_url(t['url'])
if t.get('width') and t.get('height'): if t.get('width') and t.get('height'):

View File

@ -2169,16 +2169,24 @@ def feed_entry(name):
if 'maxresdefault' in thumbnail_url: if 'maxresdefault' in thumbnail_url:
thumbnail_url = thumbnail_url.split('?')[0] thumbnail_url = thumbnail_url.split('?')[0]
thumbnails.append({ thumbnails.append({
'height': int_or_none(thumbnail.get('height')),
'url': thumbnail_url, 'url': thumbnail_url,
'height': int_or_none(thumbnail.get('height')),
'width': int_or_none(thumbnail.get('width')), 'width': int_or_none(thumbnail.get('width')),
'preference': 1 if 'maxresdefault' in thumbnail_url else -1
}) })
if thumbnails: thumbnail_url = search_meta(['og:image', 'twitter:image'])
break if thumbnail_url:
else: thumbnails.append({
thumbnail = search_meta(['og:image', 'twitter:image']) 'url': thumbnail_url,
if thumbnail: 'preference': 1 if 'maxresdefault' in thumbnail_url else -1
thumbnails = [{'url': thumbnail}] })
# All videos have a maxresdefault thumbnail, but sometimes it does not appear in the webpage
# See: https://github.com/ytdl-org/youtube-dl/issues/29049
thumbnails.append({
'url': 'https://i.ytimg.com/vi/%s/maxresdefault.jpg' % video_id,
'preference': 1,
})
self._remove_duplicate_formats(thumbnails)
category = microformat.get('category') or search_meta('genre') category = microformat.get('category') or search_meta('genre')
channel_id = video_details.get('channelId') \ channel_id = video_details.get('channelId') \