aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSsSsS <54671367+u-spec-png@users.noreply.github.com>2021-08-10 13:15:32 +0000
committerGitHub <noreply@github.com>2021-08-10 18:45:32 +0530
commit60c8fc73c6e6fe2189e0417a9847705f4baae05f (patch)
tree5f995e6ad0df20cafc1e4bad1d36a9cac99da0f2
parentbc8745480e1b0a561030dd8b7c392ef83e573c5d (diff)
downloadhypervideo-pre-60c8fc73c6e6fe2189e0417a9847705f4baae05f.tar.lz
hypervideo-pre-60c8fc73c6e6fe2189e0417a9847705f4baae05f.tar.xz
hypervideo-pre-60c8fc73c6e6fe2189e0417a9847705f4baae05f.zip
[instagram] Fix comments extraction (#660)
Authored-by: u-spec-png <miloradkalabasdt@gmail.com>
-rw-r--r--yt_dlp/extractor/instagram.py21
1 files changed, 13 insertions, 8 deletions
diff --git a/yt_dlp/extractor/instagram.py b/yt_dlp/extractor/instagram.py
index 1261f438e..d8acef5ba 100644
--- a/yt_dlp/extractor/instagram.py
+++ b/yt_dlp/extractor/instagram.py
@@ -195,18 +195,23 @@ class InstagramIE(InfoExtractor):
lambda x: x['%ss' % kind]['count'])))
if count is not None:
return count
+
like_count = get_count('preview_like', 'like')
comment_count = get_count(
('preview_comment', 'to_comment', 'to_parent_comment'), 'comment')
- comments = [{
- 'author': comment.get('user', {}).get('username'),
- 'author_id': comment.get('user', {}).get('id'),
- 'id': comment.get('id'),
- 'text': comment.get('text'),
- 'timestamp': int_or_none(comment.get('created_at')),
- } for comment in media.get(
- 'comments', {}).get('nodes', []) if comment.get('text')]
+ comments = []
+ for comment in try_get(media, lambda x: x['edge_media_to_parent_comment']['edges']):
+ comment_dict = comment.get('node', {})
+ comment_text = comment_dict.get('text')
+ if comment_text:
+ comments.append({
+ 'author': try_get(comment_dict, lambda x: x['owner']['username']),
+ '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:
edges = try_get(
media, lambda x: x['edge_sidecar_to_children']['edges'],