Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[ndr:base:embed] Improve thumbnails extraction (closes #23731)
  • Loading branch information
Sergey M․ committed Jan 14, 2020
1 parent bd2c211 commit 3fc5663
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions youtube_dl/extractor/ndr.py
Expand Up @@ -9,6 +9,8 @@
int_or_none,
parse_iso8601,
qualities,
try_get,
urljoin,
)


Expand Down Expand Up @@ -220,11 +222,17 @@ def _real_extract(self, url):
upload_date = ppjson.get('config', {}).get('publicationDate')
duration = int_or_none(config.get('duration'))

thumbnails = [{
'id': thumbnail.get('quality') or thumbnail_id,
'url': thumbnail['src'],
'preference': quality_key(thumbnail.get('quality')),
} for thumbnail_id, thumbnail in config.get('poster', {}).items() if thumbnail.get('src')]
thumbnails = []
poster = try_get(config, lambda x: x['poster'], dict) or {}
for thumbnail_id, thumbnail in poster.items():
thumbnail_url = urljoin(url, thumbnail.get('src'))
if not thumbnail_url:
continue
thumbnails.append({
'id': thumbnail.get('quality') or thumbnail_id,
'url': thumbnail_url,
'preference': quality_key(thumbnail.get('quality')),
})

return {
'id': video_id,
Expand Down

0 comments on commit 3fc5663

Please sign in to comment.