Skip to content

Commit

Permalink
exclusively use WEB client + force inv_sig_helper usage
Browse files Browse the repository at this point in the history
  • Loading branch information
unixfox committed Nov 8, 2024
1 parent 012d20c commit d3467ad
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 25 deletions.
7 changes: 7 additions & 0 deletions src/invidious/config.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
29 changes: 4 additions & 25 deletions src/invidious/videos/parser.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d3467ad

Please sign in to comment.