Workaround: Make invidious use HTML5 innertube client if the Android client fails

This commit is contained in:
techmetx11 2024-03-31 12:38:08 +00:00
parent 99a5e9cbc4
commit 1e338a51c8
No known key found for this signature in database
GPG Key ID: 20E0C88A0E7E5AF2

View File

@ -102,6 +102,7 @@ def extract_video_info(video_id : String, proxy_region : String? = nil)
new_player_response = nil
begin
if reason.nil?
# Fetch the video streams using an Android client in order to get the
# decrypted URLs and maybe fix throttling issues (#2194). See the
@ -114,6 +115,13 @@ def extract_video_info(video_id : String, proxy_region : String? = nil)
client_config.client_type = YoutubeAPI::ClientType::AndroidScreenEmbed
new_player_response = try_fetch_streaming_data(video_id, client_config)
end
rescue VideoNotAvailableException
# YouTube returns the "Video Not Available" video data instead of the
# video itself, but not on HTML5
Log.warn { "YouTube's Android client did not return the video we were looking for, Falling back on HTML5 client" }
client_config.client_type = YoutubeAPI::ClientType::TvHtml5ScreenEmbed
new_player_response = try_fetch_streaming_data(video_id, client_config)
end
# Last hope
if new_player_response.nil?