From 00ef1c862744ec00886bc3fa4b95fdfc6c151866 Mon Sep 17 00:00:00 2001 From: James Taylor Date: Thu, 25 Feb 2021 15:55:23 -0800 Subject: Fix comment replies MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Comment reply protobuf now requires the channel id of the uploader of the video. Otherwise the endpoint returns 500. Instead of making the protobuf ourselves and passing this data around through query parameters, just use the ctoken provided to us but modify the max_replies field from 10 to 250. Fixes #53 Signed-off-by: Jesús --- youtube/yt_data_extract/everything_else.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'youtube/yt_data_extract') diff --git a/youtube/yt_data_extract/everything_else.py b/youtube/yt_data_extract/everything_else.py index ae8715f..197cf88 100644 --- a/youtube/yt_data_extract/everything_else.py +++ b/youtube/yt_data_extract/everything_else.py @@ -251,13 +251,19 @@ def extract_comments_info(polymer_json): info['video_title'] = extract_str(comment_thread.get('commentTargetTitle')) if 'replies' not in comment_thread: comment_info['reply_count'] = 0 + comment_info['reply_ctoken'] = None else: comment_info['reply_count'] = extract_int(deep_get(comment_thread, 'replies', 'commentRepliesRenderer', 'moreText' ), default=1) # With 1 reply, the text reads "View reply" + comment_info['reply_ctoken'] = deep_get(comment_thread, + 'replies', 'commentRepliesRenderer', 'continuations', 0, + 'nextContinuationData', 'continuation' + ) comment_renderer = deep_get(comment_thread, 'comment', 'commentRenderer', default={}) elif 'commentRenderer' in comment: # replies comment_info['reply_count'] = 0 # replyCount, below, not present for replies even if the reply has further replies to it + comment_info['reply_ctoken'] = None conservative_update(info, 'is_replies', True) comment_renderer = comment['commentRenderer'] else: -- cgit v1.2.3