aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Taylor <user234683@users.noreply.github.com>2021-02-25 20:20:49 -0800
committerJesús <heckyel@hyperbola.info>2021-02-26 12:11:32 -0500
commit1ec02199ea002827a787d3ec16b9f2f672396a95 (patch)
tree7509a0ff043b7f1888090e524bcd5c4efb2d4034
parent3a73953e6c219d693853dc3497b77f02d16162e6 (diff)
downloadyt-local-1ec02199ea002827a787d3ec16b9f2f672396a95.tar.lz
yt-local-1ec02199ea002827a787d3ec16b9f2f672396a95.tar.xz
yt-local-1ec02199ea002827a787d3ec16b9f2f672396a95.zip
Update max_replies when there's a continuation for the replies
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 <heckyel@hyperbola.info>
-rw-r--r--youtube/comments.py21
1 files changed, 15 insertions, 6 deletions
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)