Skip to content

Commit

Permalink
Storyboards: Fix some small logic mistakes
Browse files Browse the repository at this point in the history
  • Loading branch information
SamantazFox committed Dec 16, 2023
1 parent bc709bf commit b18c6a8
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/invidious/videos/storyboard.cr
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module Invidious::Videos
authority = /(i\d?).ytimg.com/.match(@url.host.not_nil!).not_nil![1]?

@proxied_url = URI.parse(HOST_URL)
@proxied_url.path = "/sb/#{authority}#{@url.path}"
@proxied_url.path = "/sb/#{authority}/#{@url.path.lchop("/sb/")}"
@proxied_url.query = @url.query
end

Expand Down Expand Up @@ -60,8 +60,7 @@ module Invidious::Videos
return [] of Storyboard if !storyboards

# The base URL is the first chunk
url = URI.parse(storyboards.shift)
params = url.query_params
base_url = URI.parse(storyboards.shift)

return storyboards.map_with_index do |sb, i|
# Separate the different storyboard parameters:
Expand All @@ -81,9 +80,13 @@ module Invidious::Videos
columns = columns.to_i
rows = rows.to_i

# Copy base URL object, so that we can modify it
url = base_url.dup

# Add the signature to the URL
params = url.query_params
params["sigh"] = sigh
url.query = params.to_s
url.query_params = params

# Replace the template parts with what we have
url.path = url.path.sub("$L", i).sub("$N", name)
Expand Down

0 comments on commit b18c6a8

Please sign in to comment.