kopia lustrzana https://github.com/iv-org/invidious
Replace signature function with generic catchall
rodzic
225625a0fb
commit
13ef4440d0
|
@ -175,54 +175,24 @@ def search(query, client)
|
|||
end
|
||||
end
|
||||
|
||||
def swap(a, b)
|
||||
def splice(a, b)
|
||||
c = a[0]
|
||||
a[0] = a[b % a.size]
|
||||
a[b % a.size] = c
|
||||
return a
|
||||
end
|
||||
|
||||
def decrypt_signature(a, base)
|
||||
def decrypt_signature(a)
|
||||
a = a.split("")
|
||||
|
||||
case base
|
||||
when "vflG9lb96"
|
||||
a = swap(a, 26)
|
||||
a.reverse!
|
||||
a = swap(a, 8)
|
||||
a = swap(a, 61)
|
||||
when "vflxuxnEY"
|
||||
a.delete_at(0..2)
|
||||
a.reverse!
|
||||
c = a[0]
|
||||
a[0] = a[49 % a.size]
|
||||
a[49] = c
|
||||
when "vflAXQwEj"
|
||||
a = swap(a, 26)
|
||||
a.reverse!
|
||||
a = swap(a, 8)
|
||||
a = swap(a, 61)
|
||||
when "vflNpPGQq"
|
||||
a = swap(a, 26)
|
||||
a.reverse!
|
||||
a = swap(a, 8)
|
||||
a = swap(a, 61)
|
||||
when "vflCCoUi2"
|
||||
a = swap(a, 26)
|
||||
a.reverse!
|
||||
a = swap(a, 8)
|
||||
a = swap(a, 61)
|
||||
when "vflg4IfMn"
|
||||
a = swap(a, 6)
|
||||
a = swap(a, 64)
|
||||
a = swap(a, 25)
|
||||
a = swap(a, 53)
|
||||
a.delete_at(0..1)
|
||||
a.reverse!
|
||||
a.delete_at(0..2)
|
||||
else
|
||||
raise "Could not decrypt signature for player #{base}"
|
||||
end
|
||||
a.delete_at(0..1)
|
||||
a = splice(a, 2)
|
||||
a = splice(a, 51)
|
||||
a = splice(a, 9)
|
||||
a.delete_at(0..1)
|
||||
a.reverse!
|
||||
a = splice(a, 15)
|
||||
a.delete_at(0..2)
|
||||
|
||||
return a.join("")
|
||||
end
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue