mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2022-08-14.git
synced 2024-08-15 00:53:20 +00:00
Replace signature function with generic catchall
This commit is contained in:
parent
225625a0fb
commit
13ef4440d0
2 changed files with 19 additions and 70 deletions
|
@ -177,34 +177,9 @@ get "/watch" do |env|
|
|||
fmt_stream << HTTP::Params.parse(string)
|
||||
end
|
||||
|
||||
base = nil
|
||||
signature = false
|
||||
if fmt_stream[0]? && fmt_stream[0]["s"]?
|
||||
base = video.html.xpath_node(%q(//script[@name="player/base"]))
|
||||
|
||||
if !base
|
||||
base = video.html.xpath_node(%q(//script[@name="player_ias/base"]))
|
||||
end
|
||||
|
||||
if !base
|
||||
error_message = "Could not find signature for #{video.id}"
|
||||
next templated "error"
|
||||
end
|
||||
|
||||
base = base["src"]
|
||||
base = base.split("/")[3].split("-")[1]
|
||||
|
||||
begin
|
||||
decrypt_signature(fmt_stream[0]["s"], base)
|
||||
rescue ex
|
||||
error_message = ex.message
|
||||
next templated "error"
|
||||
end
|
||||
end
|
||||
|
||||
fmt_stream.each do |fmt|
|
||||
if base
|
||||
fmt["url"] += "&signature=" + decrypt_signature(fmt["s"], base)
|
||||
end
|
||||
signature = true
|
||||
end
|
||||
|
||||
# We want lowest quality first
|
||||
|
@ -217,9 +192,13 @@ get "/watch" do |env|
|
|||
end
|
||||
end
|
||||
|
||||
adaptive_fmts.each do |fmt|
|
||||
if base
|
||||
fmt["url"] += "&signature=" + decrypt_signature(fmt["s"], base)
|
||||
if signature
|
||||
adaptive_fmts.each do |fmt|
|
||||
fmt["url"] += "&signature=" + decrypt_signature(fmt["s"])
|
||||
end
|
||||
|
||||
fmt_stream.each do |fmt|
|
||||
fmt["url"] += "&signature=" + decrypt_signature(fmt["s"])
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue