Skip to content

Commit

Permalink
fetch_url: 429: get new identity regardless of page content
Browse files Browse the repository at this point in the history
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
  • Loading branch information
user234683 committed Jan 13, 2021
1 parent a056fe1 commit c8dd26b
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions youtube/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,9 +283,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)
Expand Down

0 comments on commit c8dd26b

Please sign in to comment.