aboutsummaryrefslogtreecommitdiffstats
path: root/youtube/util.py
diff options
context:
space:
mode:
authorJames Taylor <user234683@users.noreply.github.com>2021-01-13 13:12:02 -0800
committerJesús <heckyel@hyperbola.info>2021-01-13 18:07:00 -0500
commit52ca49628fe189b44c4812178cb3a8084a878317 (patch)
tree942f1bd6c3e1b26f8f7cfecde9255211a8e533fa /youtube/util.py
parent8cc721b4ec239b3caaf3351157a05e74aa1ad707 (diff)
downloadyt-local-52ca49628fe189b44c4812178cb3a8084a878317.tar.lz
yt-local-52ca49628fe189b44c4812178cb3a8084a878317.tar.xz
yt-local-52ca49628fe189b44c4812178cb3a8084a878317.zip
fetch_url: 429: get new identity regardless of page content
New 429 captcha page doesn't have IP. This new page appears to match the 429 code plus the json of {"redirect": ...} which would be occasionally received when the pbj json endpoint was used in the past. Closes #22 Signed-off-by: Jesús <heckyel@hyperbola.info>
Diffstat (limited to 'youtube/util.py')
-rw-r--r--youtube/util.py4
1 files changed, 1 insertions, 3 deletions
diff --git a/youtube/util.py b/youtube/util.py
index fd6ca1a..44ae1ba 100644
--- a/youtube/util.py
+++ b/youtube/util.py
@@ -292,9 +292,7 @@ def fetch_url(url, headers=(), timeout=15, report_text=None, data=None,
content,
response.getheader('Content-Encoding', default='identity'))
- if (response.status == 429
- and content.startswith(b'<!DOCTYPE')
- and b'Our systems have detected unusual traffic' in content):
+ if response.status == 429:
ip = re.search(
br'IP address: ((?:[\da-f]*:)+[\da-f]+|(?:\d+\.)+\d+)',
content)