mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-12-22 18:17:17 -05:00
[instagram] Fix comments extraction (#660)
Authored-by: u-spec-png <miloradkalabasdt@gmail.com>
This commit is contained in:
parent
bc8745480e
commit
60c8fc73c6
@ -195,18 +195,23 @@ class InstagramIE(InfoExtractor):
|
|||||||
lambda x: x['%ss' % kind]['count'])))
|
lambda x: x['%ss' % kind]['count'])))
|
||||||
if count is not None:
|
if count is not None:
|
||||||
return count
|
return count
|
||||||
|
|
||||||
like_count = get_count('preview_like', 'like')
|
like_count = get_count('preview_like', 'like')
|
||||||
comment_count = get_count(
|
comment_count = get_count(
|
||||||
('preview_comment', 'to_comment', 'to_parent_comment'), 'comment')
|
('preview_comment', 'to_comment', 'to_parent_comment'), 'comment')
|
||||||
|
|
||||||
comments = [{
|
comments = []
|
||||||
'author': comment.get('user', {}).get('username'),
|
for comment in try_get(media, lambda x: x['edge_media_to_parent_comment']['edges']):
|
||||||
'author_id': comment.get('user', {}).get('id'),
|
comment_dict = comment.get('node', {})
|
||||||
'id': comment.get('id'),
|
comment_text = comment_dict.get('text')
|
||||||
'text': comment.get('text'),
|
if comment_text:
|
||||||
'timestamp': int_or_none(comment.get('created_at')),
|
comments.append({
|
||||||
} for comment in media.get(
|
'author': try_get(comment_dict, lambda x: x['owner']['username']),
|
||||||
'comments', {}).get('nodes', []) if comment.get('text')]
|
'author_id': try_get(comment_dict, lambda x: x['owner']['id']),
|
||||||
|
'id': comment_dict.get('id'),
|
||||||
|
'text': comment_text,
|
||||||
|
'timestamp': int_or_none(comment_dict.get('created_at')),
|
||||||
|
})
|
||||||
if not video_url:
|
if not video_url:
|
||||||
edges = try_get(
|
edges = try_get(
|
||||||
media, lambda x: x['edge_sidecar_to_children']['edges'],
|
media, lambda x: x['edge_sidecar_to_children']['edges'],
|
||||||
|
Loading…
Reference in New Issue
Block a user