From bcaec7b7d3bb6086ec2f6d0726a641e67a524789 Mon Sep 17 00:00:00 2001 From: James Taylor Date: Sun, 25 Oct 2020 10:50:33 -0700 Subject: fetch_url: move content decoding to before 429 check Content should be decoded before we try reading page to check for 429. Lucky that it worked at all before. --- youtube/util.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'youtube/util.py') diff --git a/youtube/util.py b/youtube/util.py index e468224..8d0f8ca 100644 --- a/youtube/util.py +++ b/youtube/util.py @@ -196,6 +196,9 @@ def fetch_url(url, headers=(), timeout=15, report_text=None, data=None, read_finish = time.time() cleanup_func(response) # release_connection for urllib3 + content = decode_content( + content, + response.getheader('Content-Encoding', default='identity')) if (response.status == 429 and content.startswith(b'