From 9077596979843dd136ff96fec0d704d097949a34 Mon Sep 17 00:00:00 2001 From: James Taylor Date: Wed, 26 May 2021 21:35:48 -0700 Subject: Fix 404 errors on scheduled live events and age-gate bypass MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- youtube/watch.py | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'youtube/watch.py') 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) -- cgit v1.2.3