From d3467adf27bcc3748b8efad0b35800f22c89c35a Mon Sep 17 00:00:00 2001 From: Emilien <4016501+unixfox@users.noreply.github.com> Date: Fri, 8 Nov 2024 20:47:40 +0100 Subject: [PATCH] exclusively use WEB client + force inv_sig_helper usage --- src/invidious/config.cr | 7 +++++++ src/invidious/videos/parser.cr | 29 ++++------------------------- 2 files changed, 11 insertions(+), 25 deletions(-) diff --git a/src/invidious/config.cr b/src/invidious/config.cr index c1766fbb3..a4cd09907 100644 --- a/src/invidious/config.cr +++ b/src/invidious/config.cr @@ -220,6 +220,13 @@ class Config end {% end %} + # inv_sig_helper is now mandatory due to exclusive usage of WEB + if !config.signature_server + puts "Config: inv_sig_helper is mandatory. Please configure it by following \ + the official documentation: https://docs.invidious.io/installation/" + exit(1) + end + # HMAC_key is mandatory # See: https://github.com/iv-org/invidious/issues/3854 if config.hmac_key.empty? diff --git a/src/invidious/videos/parser.cr b/src/invidious/videos/parser.cr index 19fb7dbfb..9b9e4c750 100644 --- a/src/invidious/videos/parser.cr +++ b/src/invidious/videos/parser.cr @@ -53,10 +53,8 @@ end def extract_video_info(video_id : String) # Init client config for the API client_config = YoutubeAPI::ClientConfig.new - # Use the WEB_CREATOR when po_token is configured because it fully only works on this client - if CONFIG.po_token - client_config.client_type = YoutubeAPI::ClientType::WebCreator - end + # Exclusively use WEB now + client_config.client_type = YoutubeAPI::ClientType::Web # Fetch data from the player endpoint player_response = YoutubeAPI.player(video_id: video_id, params: "2AMB", client_config: client_config) @@ -106,32 +104,13 @@ def extract_video_info(video_id : String) new_player_response = nil - # Second try in case WEB_CREATOR doesn't work with po_token. - # Only trigger if reason found and po_token configured. + # Second try in case WEB doesn't work. + # Only trigger if reason found . if reason && CONFIG.po_token client_config.client_type = YoutubeAPI::ClientType::WebEmbeddedPlayer new_player_response = try_fetch_streaming_data(video_id, client_config) end - # Don't use Android client if po_token is passed because po_token doesn't - # work for Android client. - if reason.nil? && CONFIG.po_token.nil? - # Fetch the video streams using an Android client in order to get the - # decrypted URLs and maybe fix throttling issues (#2194). See the - # following issue for an explanation about decrypted URLs: - # https://github.com/TeamNewPipe/NewPipeExtractor/issues/562 - client_config.client_type = YoutubeAPI::ClientType::Android - new_player_response = try_fetch_streaming_data(video_id, client_config) - end - - # Last hope - # Only trigger if reason found or didn't work wth Android client. - # TvHtml5ScreenEmbed now requires sig helper for it to work but doesn't work with po_token. - if reason && CONFIG.po_token.nil? - client_config.client_type = YoutubeAPI::ClientType::TvHtml5ScreenEmbed - new_player_response = try_fetch_streaming_data(video_id, client_config) - end - # Replace player response and reset reason if !new_player_response.nil? # Preserve captions & storyboard data before replacement