aboutsummaryrefslogtreecommitdiffstats
path: root/youtube/watch.py
diff options
context:
space:
mode:
authorJames Taylor <user234683@users.noreply.github.com>2021-05-26 21:35:48 -0700
committerJesús <heckyel@hyperbola.info>2021-06-01 11:55:05 -0500
commit9077596979843dd136ff96fec0d704d097949a34 (patch)
treed0f4bf89d0d379fd18c90b657c3734ba6eb12c27 /youtube/watch.py
parent1b860c69177a88257b841aab5511cd816fffed9b (diff)
downloadyt-local-9077596979843dd136ff96fec0d704d097949a34.tar.lz
yt-local-9077596979843dd136ff96fec0d704d097949a34.tar.xz
yt-local-9077596979843dd136ff96fec0d704d097949a34.zip
Fix 404 errors on scheduled live events and age-gate bypass
get_video_info now returns 404 error. Adding html5=1 fixes it (for now). See https://github.com/ytdl-org/youtube-dl/issues/29086#issuecomment-844892791 Also handles 404 error if it arises so it will be non-fatal Signed-off-by: Jesús <heckyel@hyperbola.info>
Diffstat (limited to 'youtube/watch.py')
-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)