aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--youtube/watch.py27
1 files changed, 22 insertions, 5 deletions
diff --git a/youtube/watch.py b/youtube/watch.py
index 9e24ae7..3aaac13 100644
--- a/youtube/watch.py
+++ b/youtube/watch.py
@@ -217,6 +217,13 @@ def decrypt_signatures(info, video_id):
return err
+def _add_to_error(info, key, additional_message):
+ if key in info and info[key]:
+ info[key] += additional_message
+ else:
+ info[key] = additional_message
+
+
def extract_info(video_id, use_invidious, playlist_id=None, index=None):
# bpctr=9999999999 will bypass are-you-sure dialogs for controversial
# videos
@@ -241,11 +248,21 @@ def extract_info(video_id, use_invidious, playlist_id=None, index=None):
'video_id': video_id,
'eurl': 'https://youtube.googleapis.com/v/' + video_id,
}
- url = 'https://www.youtube.com/get_video_info?' + urllib.parse.urlencode(data)
- video_info_page = util.fetch_url(
- url, headers=watch_headers, debug_name='get_video_info',
- report_text='Fetched get_video_info page').decode('utf-8')
- yt_data_extract.update_with_age_restricted_info(info, video_info_page)
+ url = 'https://www.youtube.com/get_video_info?html5=1&'
+ url += urllib.parse.urlencode(data)
+ try:
+ video_info_page = util.fetch_url(
+ url, headers=watch_headers, debug_name='get_video_info',
+ report_text='Fetched get_video_info page').decode('utf-8')
+ except util.FetchError as e:
+ if e.code == '404':
+ _add_to_error(info, 'playability_error',
+ '\n\nget_video_info not available (404).')
+ else:
+ raise
+ else:
+ yt_data_extract.update_with_age_restricted_info(info,
+ video_info_page)
# signature decryption
decryption_error = decrypt_signatures(info, video_id)