mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-07 20:30:41 -05:00
[Instagram] Improve thumbnail extraction (#1496)
Authored by: u-spec-png
This commit is contained in:
parent
a4211baff5
commit
22cd06c452
1 changed files with 10 additions and 2 deletions
|
@ -234,7 +234,9 @@ def _real_extract(self, url):
|
||||||
media, lambda x: x['edge_media_to_caption']['edges'][0]['node']['text'],
|
media, lambda x: x['edge_media_to_caption']['edges'][0]['node']['text'],
|
||||||
compat_str) or media.get('caption')
|
compat_str) or media.get('caption')
|
||||||
title = media.get('title')
|
title = media.get('title')
|
||||||
thumbnail = media.get('display_src') or media.get('display_url')
|
display_resources = media.get('display_resources')
|
||||||
|
if not display_resources:
|
||||||
|
display_resources = [{'src': media.get('display_src')}, {'src': media.get('display_url')}]
|
||||||
duration = float_or_none(media.get('video_duration'))
|
duration = float_or_none(media.get('video_duration'))
|
||||||
timestamp = int_or_none(media.get('taken_at_timestamp') or media.get('date'))
|
timestamp = int_or_none(media.get('taken_at_timestamp') or media.get('date'))
|
||||||
uploader = try_get(media, lambda x: x['owner']['full_name'])
|
uploader = try_get(media, lambda x: x['owner']['full_name'])
|
||||||
|
@ -252,6 +254,12 @@ def get_count(keys, kind):
|
||||||
comment_count = get_count(
|
comment_count = get_count(
|
||||||
('preview_comment', 'to_comment', 'to_parent_comment'), 'comment')
|
('preview_comment', 'to_comment', 'to_parent_comment'), 'comment')
|
||||||
|
|
||||||
|
thumbnails = [{
|
||||||
|
'url': thumbnail['src'],
|
||||||
|
'width': thumbnail.get('config_width'),
|
||||||
|
'height': thumbnail.get('config_height'),
|
||||||
|
} for thumbnail in display_resources if thumbnail.get('src')]
|
||||||
|
|
||||||
comments = []
|
comments = []
|
||||||
for comment in try_get(media, lambda x: x['edge_media_to_parent_comment']['edges']):
|
for comment in try_get(media, lambda x: x['edge_media_to_parent_comment']['edges']):
|
||||||
comment_dict = comment.get('node', {})
|
comment_dict = comment.get('node', {})
|
||||||
|
@ -326,7 +334,7 @@ def get_count(keys, kind):
|
||||||
'title': title or 'Video by %s' % uploader_id,
|
'title': title or 'Video by %s' % uploader_id,
|
||||||
'description': description,
|
'description': description,
|
||||||
'duration': duration,
|
'duration': duration,
|
||||||
'thumbnail': thumbnail,
|
'thumbnails': thumbnails,
|
||||||
'timestamp': timestamp,
|
'timestamp': timestamp,
|
||||||
'uploader_id': uploader_id,
|
'uploader_id': uploader_id,
|
||||||
'uploader': uploader,
|
'uploader': uploader,
|
||||||
|
|
Loading…
Reference in a new issue