mirror of
https://github.com/iv-org/invidious.git
synced 2024-12-23 00:29:53 +05:30
Add support for different signature functions
This commit is contained in:
parent
42df0df5a0
commit
1d301a5055
@ -175,15 +175,40 @@ def search(query, client)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def decrypt_signature(a)
|
def swap(a, b)
|
||||||
|
c = a[0]
|
||||||
|
a[0] = a[b % a.size]
|
||||||
|
a[b % a.size] = c
|
||||||
|
return a
|
||||||
|
end
|
||||||
|
|
||||||
|
def decrypt_signature(a, base)
|
||||||
|
if a && base
|
||||||
a = a.split("")
|
a = a.split("")
|
||||||
|
|
||||||
|
if base == "vflG9lb96"
|
||||||
|
a = swap(a, 26)
|
||||||
|
a.reverse!
|
||||||
|
a = swap(a, 8)
|
||||||
|
a = swap(a, 61)
|
||||||
|
elsif base == "vflxuxnEY"
|
||||||
a.delete_at(0..2)
|
a.delete_at(0..2)
|
||||||
a = a.reverse
|
a.reverse!
|
||||||
c = a[0]
|
c = a[0]
|
||||||
a[0] = a[49 % a.size]
|
a[0] = a[49 % a.size]
|
||||||
a[49] = c
|
a[49] = c
|
||||||
|
elsif base == "vflAXQwEj"
|
||||||
|
a = swap(a, 26)
|
||||||
|
a.reverse!
|
||||||
|
a = swap(a, 8)
|
||||||
|
a = swap(a, 61)
|
||||||
|
else
|
||||||
|
raise "Could not decrypt signature for player #{base}"
|
||||||
|
end
|
||||||
|
|
||||||
return a.join("")
|
return a.join("")
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def rank_videos(db, n)
|
def rank_videos(db, n)
|
||||||
top = [] of {Float64, String}
|
top = [] of {Float64, String}
|
||||||
|
@ -168,12 +168,32 @@ get "/watch" do |env|
|
|||||||
fmt_stream << HTTP::Params.parse(string)
|
fmt_stream << HTTP::Params.parse(string)
|
||||||
end
|
end
|
||||||
|
|
||||||
if fmt_stream[0]?
|
base = nil
|
||||||
if fmt_stream[0]["s"]?
|
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
|
||||||
|
base = base["src"]
|
||||||
|
base = base.split("/")[3].split("-")[1]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
begin
|
||||||
fmt_stream.each do |fmt|
|
fmt_stream.each do |fmt|
|
||||||
fmt["url"] = "#{fmt["url"]}&signature=#{decrypt_signature(fmt["s"])}"
|
if fmt["s"]? && !base
|
||||||
|
File.write("info/#{id}.html", video.html)
|
||||||
|
raise "Could not find signature for #{video.id}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
fmt["url"] = "#{fmt["url"]}&signature=#{decrypt_signature(fmt["s"]?, base)}"
|
||||||
end
|
end
|
||||||
|
rescue ex
|
||||||
|
error_message = ex
|
||||||
|
next templated "error"
|
||||||
end
|
end
|
||||||
|
|
||||||
# We want lowest quality first
|
# We want lowest quality first
|
||||||
@ -186,12 +206,8 @@ get "/watch" do |env|
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if adaptive_fmts[0]?
|
|
||||||
if adaptive_fmts[0]["s"]?
|
|
||||||
adaptive_fmts.each do |fmt|
|
adaptive_fmts.each do |fmt|
|
||||||
fmt["url"] = "#{fmt["url"]}&signature=#{decrypt_signature(fmt["s"])}"
|
fmt["url"] = "#{fmt["url"]}&signature=#{decrypt_signature(fmt["s"]?, base)}"
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
rvs = [] of Hash(String, String)
|
rvs = [] of Hash(String, String)
|
||||||
@ -209,6 +225,7 @@ get "/watch" do |env|
|
|||||||
rating = video.info["avg_rating"].to_f64
|
rating = video.info["avg_rating"].to_f64
|
||||||
|
|
||||||
engagement = ((video.dislikes.to_f + video.likes.to_f)/video.views * 100)
|
engagement = ((video.dislikes.to_f + video.likes.to_f)/video.views * 100)
|
||||||
|
|
||||||
if video.likes > 0 || video.dislikes > 0
|
if video.likes > 0 || video.dislikes > 0
|
||||||
calculated_rating = (video.likes.to_f/(video.likes.to_f + video.dislikes.to_f) * 4 + 1)
|
calculated_rating = (video.likes.to_f/(video.likes.to_f + video.dislikes.to_f) * 4 + 1)
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user