Merge remote-tracking branch 'companion/invidious-companion'
All checks were successful
Invidious CI / build (push) Successful in 5m10s
All checks were successful
Invidious CI / build (push) Successful in 5m10s
This commit is contained in:
commit
1100904b3e
4 changed files with 29 additions and 3 deletions
|
@ -83,6 +83,7 @@ db:
|
|||
|
||||
##
|
||||
## API key for Invidious companion
|
||||
## The size of the key needs to be more or equal to 16.
|
||||
##
|
||||
## Needed when invidious_companion is configured
|
||||
##
|
||||
|
|
|
@ -358,6 +358,9 @@ class Config
|
|||
elsif config.invidious_companion_key == "CHANGE_ME!!"
|
||||
puts "Config: The value of 'invidious_companion_key' needs to be changed!!"
|
||||
exit(1)
|
||||
elsif config.invidious_companion_key.size < 16
|
||||
puts "Config: The value of 'invidious_companion_key' needs to be a size of 16 or more."
|
||||
exit(1)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -397,3 +397,22 @@ def gen_videoplayback_proxy_list
|
|||
end
|
||||
return external_videoplayback_proxy
|
||||
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
|
||||
|
|
|
@ -22,7 +22,8 @@
|
|||
audio_streams.each_with_index do |fmt, i|
|
||||
src_url = "/latest_version?id=#{video.id}&itag=#{fmt["itag"]}"
|
||||
src_url += "&local=true" if params.local
|
||||
src_url = video.invidious_companion["baseUrl"].as_s + src_url if (!CONFIG.invidious_companion.empty?)
|
||||
src_url = video.invidious_companion["baseUrl"].as_s + src_url +
|
||||
"&check=#{invidious_companion_encrypt(video.id)}" if (!CONFIG.invidious_companion.empty?)
|
||||
|
||||
bitrate = fmt["bitrate"]
|
||||
mimetype = HTML.escape(fmt["mimeType"].as_s)
|
||||
|
@ -37,7 +38,8 @@
|
|||
<% else %>
|
||||
<% if params.quality == "dash"
|
||||
src_url = "/api/manifest/dash/id/" + video.id + "?local=true&unique_res=1"
|
||||
src_url = video.invidious_companion["baseUrl"].as_s + src_url if (!CONFIG.invidious_companion.empty?)
|
||||
src_url = video.invidious_companion["baseUrl"].as_s + src_url +
|
||||
"&check=#{invidious_companion_encrypt(video.id)}" if (!CONFIG.invidious_companion.empty?)
|
||||
%>
|
||||
<source src="<%= src_url %>" type='application/dash+xml' label="dash">
|
||||
<% end %>
|
||||
|
@ -48,7 +50,8 @@
|
|||
fmt_stream.each_with_index do |fmt, i|
|
||||
src_url = "/latest_version?id=#{video.id}&itag=#{fmt["itag"]}"
|
||||
src_url += "&local=true" if params.local
|
||||
src_url = video.invidious_companion["baseUrl"].as_s + src_url if (!CONFIG.invidious_companion.empty?)
|
||||
src_url = video.invidious_companion["baseUrl"].as_s + src_url +
|
||||
"&check=#{invidious_companion_encrypt(video.id)}" if (!CONFIG.invidious_companion.empty?)
|
||||
|
||||
quality = fmt["quality"]
|
||||
mimetype = HTML.escape(fmt["mimeType"].as_s)
|
||||
|
|
Loading…
Reference in a new issue