From 1ec02199ea002827a787d3ec16b9f2f672396a95 Mon Sep 17 00:00:00 2001 From: James Taylor Date: Thu, 25 Feb 2021 20:20:49 -0800 Subject: Update max_replies when there's a continuation for the replies MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Because of the new ctoken methodology for getting comment replies, the more comments button automatically works inside the comment reply thread when there are more replies than the limit (250). This commit also updates the max_replies for that ctoken so the next 250 replies will be retrieved for the more comments ctoken. Signed-off-by: Jesús --- youtube/comments.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'youtube') diff --git a/youtube/comments.py b/youtube/comments.py index 66b5353..a4a4f73 100644 --- a/youtube/comments.py +++ b/youtube/comments.py @@ -125,13 +125,22 @@ def post_process_comments_info(comments_info): comments_info['include_avatars'] = settings.enable_comment_avatars if comments_info['ctoken']: - replies_param = '&replies=1' if comments_info['is_replies'] else '' + ctoken = comments_info['ctoken'] + if comments_info['is_replies']: + replies_param = '&replies=1' + # change max_replies field to 250 in ctoken + new_ctoken, err = proto.set_protobuf_value( + ctoken, + 'base64p', 6, 3, 9, value=250) + if err: + print('Error setting ctoken value:') + print(err) + else: + ctoken = new_ctoken + else: + replies_param = '' comments_info['more_comments_url'] = concat_or_none( - util.URL_ORIGIN, - '/comments?ctoken=', - comments_info['ctoken'], - replies_param - ) + util.URL_ORIGIN, '/comments?ctoken=', ctoken, replies_param) comments_info['page_number'] = page_number = str(int(comments_info['offset']/20) + 1) -- cgit v1.2.3