1
1
mirror of https://github.com/ytdl-org/youtube-dl synced 2024-11-27 17:26:51 +01:00

[instagram] Fix comment count extraction

This commit is contained in:
Sergey M․ 2020-12-26 22:58:27 +07:00
parent 46cffb0c47
commit 12053450dc
No known key found for this signature in database
GPG Key ID: 2C393E0F18A9236D

View File

@ -164,12 +164,18 @@ class InstagramIE(InfoExtractor):
uploader = media.get('owner', {}).get('full_name') uploader = media.get('owner', {}).get('full_name')
uploader_id = media.get('owner', {}).get('username') uploader_id = media.get('owner', {}).get('username')
def get_count(key, kind): def get_count(keys, kind):
return int_or_none(try_get( if not isinstance(keys, (list, tuple)):
media, (lambda x: x['edge_media_%s' % key]['count'], keys = [keys]
lambda x: x['%ss' % kind]['count']))) for key in keys:
count = int_or_none(try_get(
media, (lambda x: x['edge_media_%s' % key]['count'],
lambda x: x['%ss' % kind]['count'])))
if count is not None:
return count
like_count = get_count('preview_like', 'like') like_count = get_count('preview_like', 'like')
comment_count = get_count('to_comment', 'comment') comment_count = get_count(
('preview_comment', 'to_comment', 'to_parent_comment'), 'comment')
comments = [{ comments = [{
'author': comment.get('user', {}).get('username'), 'author': comment.get('user', {}).get('username'),