diff options
author | James Taylor <user234683@users.noreply.github.com> | 2021-01-13 13:12:02 -0800 |
---|---|---|
committer | Jesús <heckyel@hyperbola.info> | 2021-01-13 18:07:00 -0500 |
commit | 52ca49628fe189b44c4812178cb3a8084a878317 (patch) | |
tree | 942f1bd6c3e1b26f8f7cfecde9255211a8e533fa | |
parent | 8cc721b4ec239b3caaf3351157a05e74aa1ad707 (diff) | |
download | yt-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>
-rw-r--r-- | youtube/util.py | 4 |
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) |