aboutsummaryrefslogtreecommitdiffstats
path: root/youtube
diff options
context:
space:
mode:
authorJames Taylor <user234683@users.noreply.github.com>2018-08-26 00:17:24 -0700
committerJames Taylor <user234683@users.noreply.github.com>2018-08-26 00:17:24 -0700
commitd9115ea2cf63b97f5fb24c639041c8f18f20a6cc (patch)
tree688112dd7f752f3243f30117ddd536d77adcce96 /youtube
parent97a789f81cf38a890677e9b2e042d803ec631e1a (diff)
downloadyt-local-d9115ea2cf63b97f5fb24c639041c8f18f20a6cc.tar.lz
yt-local-d9115ea2cf63b97f5fb24c639041c8f18f20a6cc.tar.xz
yt-local-d9115ea2cf63b97f5fb24c639041c8f18f20a6cc.zip
Comments: In title, indicate page number or that page contains replies
Diffstat (limited to 'youtube')
-rw-r--r--youtube/comments.py23
1 files changed, 21 insertions, 2 deletions
diff --git a/youtube/comments.py b/youtube/comments.py
index e662d19..4c9558f 100644
--- a/youtube/comments.py
+++ b/youtube/comments.py
@@ -71,6 +71,20 @@ def comment_replies_ctoken(video_id, comment_id, max_results=500):
result = proto.nested(2, proto.string(2, video_id)) + proto.uint(3,6) + proto.nested(6, params)
return base64.urlsafe_b64encode(result).decode('ascii')
+def ctoken_metadata(ctoken):
+ result = dict()
+ params = proto.parse(proto.b64_to_bytes(ctoken))
+ result['video_id'] = proto.parse(params[2])[2]
+
+ offset_information = proto.parse(params[6])
+ result['offset'] = offset_information.get(5, 0)
+
+ result['is_replies'] = False
+ if 3 in offset_information:
+ if 2 in offset_information[3]:
+ result['is_replies'] = True
+ return result
+
def get_ids(ctoken):
params = proto.parse(proto.b64_to_bytes(ctoken))
video_id = proto.parse(params[2])[2]
@@ -240,7 +254,12 @@ def get_comments_page(query_string):
ctoken = comment_replies_ctoken(video_id, parent_id)
replies = True
-
+
+ metadata = ctoken_metadata(ctoken)
+ if replies:
+ page_title = 'Replies'
+ else:
+ page_title = 'Comments page ' + str(int(metadata['offset']/20) + 1)
result = parse_comments_polymer(request_comments(ctoken, replies), replies)
comments_html, ctoken = get_comments_html(result)
if ctoken == '':
@@ -251,7 +270,7 @@ def get_comments_page(query_string):
return yt_comments_template.substitute(
header = common.get_header(),
comments = comments_html,
- page_title = 'Comments',
+ page_title = page_title,
more_comments_button=more_comments_button,
)