diff options
author | James Taylor <user234683@users.noreply.github.com> | 2018-09-15 17:54:12 -0700 |
---|---|---|
committer | James Taylor <user234683@users.noreply.github.com> | 2018-09-15 17:54:12 -0700 |
commit | 6c61472dafbfb0388a3c8c42a46afbd81a50569f (patch) | |
tree | 6df5536e9185c70fa7323c6870ada0a729f0cb35 | |
parent | 3de6c50c67f44df5e72196b2f0b060c27d36c185 (diff) | |
download | yt-local-6c61472dafbfb0388a3c8c42a46afbd81a50569f.tar.lz yt-local-6c61472dafbfb0388a3c8c42a46afbd81a50569f.tar.xz yt-local-6c61472dafbfb0388a3c8c42a46afbd81a50569f.zip |
Display latency/read-time for comment retrieval
-rw-r--r-- | youtube/comments.py | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/youtube/comments.py b/youtube/comments.py index 5bfcdbd..3e22947 100644 --- a/youtube/comments.py +++ b/youtube/comments.py @@ -118,9 +118,9 @@ def request_comments(ctoken, replies=False): else: base_url = "https://m.youtube.com/watch_comment?action_get_comments=1&ctoken=" url = base_url + ctoken.replace("=", "%3D") + "&pbj=1" - print("Sending comments ajax request") + for i in range(0,8): # don't retry more than 8 times - content = fetch_url(url, headers=mobile_headers) + content = fetch_url(url, headers=mobile_headers, report_text="Retrieved comments") if content[0:4] == b")]}'": # random closing characters included at beginning of response for some reason content = content[4:] elif content[0:10] == b'\n<!DOCTYPE': # occasionally returns html instead of json for no reason @@ -170,8 +170,7 @@ def parse_comments_ajax(content, replies=False): print('Error parsing comments: ' + str(e)) comments = () ctoken = '' - else: - print("Finished getting and parsing comments") + return {'ctoken': ctoken, 'comments': comments} reply_count_regex = re.compile(r'(\d+)') @@ -234,8 +233,7 @@ def parse_comments_polymer(content, replies=False): print('Error parsing comments: ' + str(e)) comments = () ctoken = '' - else: - print("Finished getting and parsing comments") + return {'ctoken': ctoken, 'comments': comments, 'video_title': video_title} |