mirror of
https://git.nadeko.net/Fijxu/invidious.git
synced 2025-12-14 17:15:09 +00:00
Add invidious companion support (#4985)
* add support for invidious companion * redirect latest_version and dash manifest to invidious companion * fix Shadowing outer local variable `response` * fixing condition for Content-Security-Policy * throw error if inv_sig_helper and invidious_companion used same time * Use sample instead of Random.rand Co-authored-by: syeopite <70992037+syeopite@users.noreply.github.com> * Remove debug puts functions Co-authored-by: syeopite <70992037+syeopite@users.noreply.github.com> * modify the description for config.example.yaml about invidious companion * move config checks for invidious companion * separate invidious_companion logic + better config.yaml config * fixing "end" misplacement * fix linting + use .empty? * crystal handle decompression already by itself * fix download function when invidious companion used * fix linting * invidious companion always used so always add CSP and redirect latest_version * apply all the suggestions + rework invidious_companion parameter * format watch.cr * fix ameba Redundant use of `Object#to_s` in interpolation * add ability for invidious companion to check request from invidious * Better document private_url and public_url * Better doc for invidious_companion_key * !empty? to present? * skip proxy for invidious companion * fixing format * missing , * add companion pooling http * fix: don't use http proxy when sending requests to companion * fix: logic where we want to have the invidious logic if companion is not used * chore: remove baseurl usage from invidious companion * chore: change from inv-sig-helper to companion for required playback * fix: use puts + add warning for inv-sig-helper deprecated --------- Co-authored-by: syeopite <70992037+syeopite@users.noreply.github.com>
This commit is contained in:
@@ -383,3 +383,22 @@ def parse_link_endpoint(endpoint : JSON::Any, text : String, video_id : String)
|
||||
end
|
||||
return text
|
||||
end
|
||||
|
||||
def encrypt_ecb_without_salt(data, key)
|
||||
cipher = OpenSSL::Cipher.new("aes-128-ecb")
|
||||
cipher.encrypt
|
||||
cipher.key = key
|
||||
|
||||
io = IO::Memory.new
|
||||
io.write(cipher.update(data))
|
||||
io.write(cipher.final)
|
||||
io.rewind
|
||||
|
||||
return io
|
||||
end
|
||||
|
||||
def invidious_companion_encrypt(data)
|
||||
timestamp = Time.utc.to_unix
|
||||
encrypted_data = encrypt_ecb_without_salt("#{timestamp}|#{data}", CONFIG.invidious_companion_key)
|
||||
return Base64.urlsafe_encode(encrypted_data)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user