aboutsummaryrefslogtreecommitdiffstats
path: root/youtube/watch.py
diff options
context:
space:
mode:
authorJames Taylor <user234683@users.noreply.github.com>2020-02-18 11:47:23 -0800
committerJames Taylor <user234683@users.noreply.github.com>2020-02-18 11:47:23 -0800
commitf25324794916dc51367e399b923e367854e5b5ee (patch)
tree5e248f912ae3131a526da9d122956dc8a7803072 /youtube/watch.py
parent8c2b81094ec277865f613aacfa6626bf271a4ab8 (diff)
downloadyt-local-f25324794916dc51367e399b923e367854e5b5ee.tar.lz
yt-local-f25324794916dc51367e399b923e367854e5b5ee.tar.xz
yt-local-f25324794916dc51367e399b923e367854e5b5ee.zip
Fix MaxRetryError when checking for video URL access
The default urllib3 max redirect amount was set to 3. Change it to 10 and do not fail if there is a problem with checking for URL access. Just print the error to the console and proceed. Also add an unrelated remark about the bcptr=9999999999 parameter in watch.py
Diffstat (limited to 'youtube/watch.py')
-rw-r--r--youtube/watch.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/youtube/watch.py b/youtube/watch.py
index 5b36462..f80229b 100644
--- a/youtube/watch.py
+++ b/youtube/watch.py
@@ -208,6 +208,8 @@ headers = (
) + util.mobile_ua
def extract_info(video_id):
+ # bpctr=9999999999 will bypass are-you-sure dialogs for controversial
+ # videos
polymer_json = util.fetch_url('https://m.youtube.com/watch?v=' + video_id + '&pbj=1&bpctr=9999999999', headers=headers, debug_name='watch').decode('utf-8')
# TODO: Decide whether this should be done in yt_data_extract.extract_watch_info
try:
@@ -237,8 +239,14 @@ def extract_info(video_id):
# check for 403
info['invidious_used'] = False
if settings.route_tor and info['formats'] and info['formats'][0]['url']:
- response = util.head(info['formats'][0]['url'],
- report_text='Checked for URL access')
+ try:
+ response = util.head(info['formats'][0]['url'],
+ report_text='Checked for URL access')
+ except urllib3.exceptions.HTTPError:
+ print('Error while checking for URL access:\n')
+ traceback.print_exc()
+ return info
+
if response.status == 403:
print(('Access denied (403) for video urls.'
' Retrieving urls from Invidious...'))
@@ -277,6 +285,8 @@ def extract_info(video_id):
+ itag + ' not found in invidious urls'))
continue
fmt['url'] = itag_to_url[itag]
+ elif 300 <= response.status < 400:
+ print('Error: exceeded max redirects while checking video URL')
return info
def video_quality_string(format):