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>
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user