Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add workaround for storyboards on local instances #4040

Merged
merged 3 commits into from
Aug 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/invidious/routes/errors.cr
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
module Invidious::Routes::ErrorRoutes
def self.error_404(env)
# Workaround for #3117
if HOST_URL.empty? && env.request.path.starts_with?("/v1/storyboards/sb")
return env.redirect "#{env.request.path[15..]}?#{env.params.query}"
end

if md = env.request.path.match(/^\/(?<id>([a-zA-Z0-9_-]{11})|(\w+))$/)
item = md["id"]

Expand Down
7 changes: 4 additions & 3 deletions src/invidious/videos/parser.cr
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ def extract_video_info(video_id : String, proxy_region : String? = nil)
client_config = YoutubeAPI::ClientConfig.new(proxy_region: proxy_region)

# Fetch data from the player endpoint
# CgIQBg is a workaround for streaming URLs that returns a 403.
# See https://github.com/iv-org/invidious/issues/4027#issuecomment-1666944520
player_response = YoutubeAPI.player(video_id: video_id, params: "CgIQBg", client_config: client_config)
player_response = YoutubeAPI.player(video_id: video_id, params: "", client_config: client_config)

playability_status = player_response.dig?("playabilityStatus", "status").try &.as_s

Expand Down Expand Up @@ -120,6 +118,9 @@ def extract_video_info(video_id : String, proxy_region : String? = nil)

# Replace player response and reset reason
if !new_player_response.nil?
# Preserve storyboard data before replacement
new_player_response["storyboards"] = player_response["storyboards"] if player_response["storyboards"]?

player_response = new_player_response
params.delete("reason")
end
Expand Down