mirror of
https://github.com/iv-org/invidious.git
synced 2025-07-10 06:05:47 -05:00
Make it Crystal <=1.13.3 compatible, only add pot
if present
This commit is contained in:
parent
f5aa881324
commit
7041fdcbb6
@ -1,5 +1,3 @@
|
||||
require "uri/params/serializable"
|
||||
|
||||
# See http://www.evanmiller.org/how-not-to-sort-by-average-rating.html
|
||||
def ci_lower_bound(pos, n)
|
||||
if n == 0
|
||||
@ -411,15 +409,20 @@ def invidious_companion_encrypt(data)
|
||||
end
|
||||
|
||||
struct PrivateParams
|
||||
include URI::Params::Serializable
|
||||
include JSON::Serializable
|
||||
|
||||
property ip : String = ""
|
||||
property pot : String = ""
|
||||
property pot : String? = nil
|
||||
|
||||
def initialize(@ip, @pot)
|
||||
end
|
||||
end
|
||||
|
||||
def encrypt_query_params(query_params : URI::Params) : String
|
||||
private_params = PrivateParams.from_www_form(query_params.to_s).to_json
|
||||
private_params = PrivateParams.new(
|
||||
query_params["ip"],
|
||||
query_params["pot"]?,
|
||||
).to_json
|
||||
encrypted_data = ecb_without_salt(private_params, CONFIG.hmac_key, :encrypt)
|
||||
return Base64.urlsafe_encode(encrypted_data)
|
||||
end
|
||||
|
@ -14,7 +14,7 @@ module Invidious::HttpServer
|
||||
params["enc"] = "true"
|
||||
params["data"] = encrypted_data
|
||||
params.delete("ip")
|
||||
params.delete("pot")
|
||||
params.delete("pot") if params.has_key?("pot")
|
||||
end
|
||||
params["host"] = url.host.not_nil! # Should never be nil, in theory
|
||||
params["region"] = region if !region.nil?
|
||||
|
@ -6,8 +6,10 @@ module Invidious::Routes::VideoPlayback
|
||||
|
||||
if query_params["enc"]? == "true"
|
||||
decrypted_data = decrypt_query_params(query_params["data"])
|
||||
query_params["ip"] = decrypted_data.ip
|
||||
query_params["pot"] = decrypted_data.pot
|
||||
query_params.add("ip", decrypted_data.ip)
|
||||
if pot = decrypted_data.pot
|
||||
query_params.add("pot", pot)
|
||||
end
|
||||
query_params.delete("enc")
|
||||
query_params.delete("data")
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user