From 9859c5485e09b5593a3abcf41222ef5bdd7bc159 Mon Sep 17 00:00:00 2001 From: Jesus E Date: Sun, 28 May 2023 21:32:37 -0400 Subject: Only use android URLs if encrypted; they randomly go 403 Android URLs now begin returning 403s mid playback at random. --- youtube/watch.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'youtube') diff --git a/youtube/watch.py b/youtube/watch.py index c38a3f5..46cfdf5 100644 --- a/youtube/watch.py +++ b/youtube/watch.py @@ -431,13 +431,18 @@ def extract_info(video_id, use_invidious, playlist_id=None, index=None): # couldn't be decrypted with the base.js from the web page for some # reason # https://github.com/yt-dlp/yt-dlp/issues/574#issuecomment-887171136 + + # Update 4/26/23, these URLs will randomly start returning 403 + # mid-playback and I'm not sure why gevent.spawn(fetch_player_response, 'android', video_id) ) gevent.joinall(tasks) util.check_gevent_exceptions(*tasks) info, player_response = tasks[0].value, tasks[1].value - yt_data_extract.update_with_new_urls(info, player_response) + if yt_data_extract.requires_decryption(info): + print('Encrypted. Replacing with URLs from Android client') + yt_data_extract.update_with_new_urls(info, player_response) # Age restricted video, retry if info['age_restricted'] or info['player_urls_missing']: -- cgit v1.2.3