diff options
author | James Taylor <user234683@users.noreply.github.com> | 2020-12-21 17:03:41 -0800 |
---|---|---|
committer | Jesús <heckyel@hyperbola.info> | 2020-12-21 21:28:17 -0500 |
commit | dcfa2700efcd876c1853c1cf0b08fa7c391a3329 (patch) | |
tree | 20c6fb67162117020ecdda9731b7523b2a35ee08 | |
parent | 35b2b3e97327c2e304beff66c40c7b76ec0a32d2 (diff) | |
download | yt-local-dcfa2700efcd876c1853c1cf0b08fa7c391a3329.tar.lz yt-local-dcfa2700efcd876c1853c1cf0b08fa7c391a3329.tar.xz yt-local-dcfa2700efcd876c1853c1cf0b08fa7c391a3329.zip |
request_comments: remove obsolete retrying code
The issue that code was working around happened with an older
request format (the ajax format) that was removed. The issue
does not happen with the newer polymer format.
Signed-off-by: Jesús <heckyel@hyperbola.info>
-rw-r--r-- | youtube/comments.py | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/youtube/comments.py b/youtube/comments.py index c19a70a..fff7cb5 100644 --- a/youtube/comments.py +++ b/youtube/comments.py @@ -69,17 +69,12 @@ def request_comments(ctoken, replies=False): base_url = "https://m.youtube.com/watch_comment?action_get_comments=1&ctoken=" url = base_url + ctoken.replace("=", "%3D") + "&pbj=1" - for i in range(0, 8): # don't retry more than 8 times - content = util.fetch_url(url, headers=mobile_headers, report_text="Retrieved comments", debug_name='request_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 - content = b'' - print("got <!DOCTYPE>, retrying") - continue - break - - polymer_json = json.loads(util.uppercase_escape(content.decode('utf-8'))) + content = util.fetch_url( + url, headers=mobile_headers, + report_text='Retrieved comments', debug_name='request_comments') + content = content.decode('utf-8') + + polymer_json = json.loads(content) return polymer_json |