mirror of
https://github.com/iv-org/invidious.git
synced 2025-01-10 11:30:34 +05:30
!empty? to present?
This commit is contained in:
parent
e9c354d5a3
commit
f550359ae9
@ -238,13 +238,12 @@ class Config
|
|||||||
end
|
end
|
||||||
{% end %}
|
{% end %}
|
||||||
|
|
||||||
if !config.invidious_companion.empty?
|
if config.invidious_companion.present?
|
||||||
# invidious_companion and signature_server can't work together
|
# invidious_companion and signature_server can't work together
|
||||||
if config.signature_server
|
if config.signature_server
|
||||||
puts "Config: You can not run inv_sig_helper and invidious_companion at the same time."
|
puts "Config: You can not run inv_sig_helper and invidious_companion at the same time."
|
||||||
exit(1)
|
exit(1)
|
||||||
end
|
elsif config.invidious_companion_key.empty?
|
||||||
if config.invidious_companion_key.empty?
|
|
||||||
puts "Config: Please configure a key if you are using invidious companion."
|
puts "Config: Please configure a key if you are using invidious companion."
|
||||||
exit(1)
|
exit(1)
|
||||||
elsif config.invidious_companion_key == "CHANGE_ME!!"
|
elsif config.invidious_companion_key == "CHANGE_ME!!"
|
||||||
|
@ -8,7 +8,7 @@ module Invidious::Routes::API::Manifest
|
|||||||
id = env.params.url["id"]
|
id = env.params.url["id"]
|
||||||
region = env.params.query["region"]?
|
region = env.params.query["region"]?
|
||||||
|
|
||||||
if !CONFIG.invidious_companion.empty?
|
if CONFIG.invidious_companion.present?
|
||||||
invidious_companion = CONFIG.invidious_companion.sample
|
invidious_companion = CONFIG.invidious_companion.sample
|
||||||
return env.redirect "#{invidious_companion.public_url}/api/manifest/dash/id/#{id}?#{env.params.query}"
|
return env.redirect "#{invidious_companion.public_url}/api/manifest/dash/id/#{id}?#{env.params.query}"
|
||||||
end
|
end
|
||||||
|
@ -253,7 +253,7 @@ module Invidious::Routes::VideoPlayback
|
|||||||
# YouTube /videoplayback links expire after 6 hours,
|
# YouTube /videoplayback links expire after 6 hours,
|
||||||
# so we have a mechanism here to redirect to the latest version
|
# so we have a mechanism here to redirect to the latest version
|
||||||
def self.latest_version(env)
|
def self.latest_version(env)
|
||||||
if !CONFIG.invidious_companion.empty?
|
if CONFIG.invidious_companion.present?
|
||||||
invidious_companion = CONFIG.invidious_companion.sample
|
invidious_companion = CONFIG.invidious_companion.sample
|
||||||
return env.redirect "#{invidious_companion.public_url}/latest_version?#{env.params.query}"
|
return env.redirect "#{invidious_companion.public_url}/latest_version?#{env.params.query}"
|
||||||
end
|
end
|
||||||
|
@ -333,7 +333,7 @@ module Invidious::Routes::Watch
|
|||||||
env.params.query["title"] = filename
|
env.params.query["title"] = filename
|
||||||
env.params.query["local"] = "true"
|
env.params.query["local"] = "true"
|
||||||
|
|
||||||
if (!CONFIG.invidious_companion.empty?)
|
if (CONFIG.invidious_companion.present?)
|
||||||
video = get_video(video_id)
|
video = get_video(video_id)
|
||||||
return env.redirect "#{video.invidious_companion["baseUrl"].as_s}/latest_version?#{env.params.query}"
|
return env.redirect "#{video.invidious_companion["baseUrl"].as_s}/latest_version?#{env.params.query}"
|
||||||
else
|
else
|
||||||
|
@ -100,7 +100,7 @@ def extract_video_info(video_id : String)
|
|||||||
params = parse_video_info(video_id, player_response)
|
params = parse_video_info(video_id, player_response)
|
||||||
params["reason"] = JSON::Any.new(reason) if reason
|
params["reason"] = JSON::Any.new(reason) if reason
|
||||||
|
|
||||||
if !CONFIG.invidious_companion.empty?
|
if CONFIG.invidious_companion.present?
|
||||||
new_player_response = nil
|
new_player_response = nil
|
||||||
|
|
||||||
# Don't use Android test suite client if po_token is passed because po_token doesn't
|
# Don't use Android test suite client if po_token is passed because po_token doesn't
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
src_url = "/latest_version?id=#{video.id}&itag=#{fmt["itag"]}"
|
src_url = "/latest_version?id=#{video.id}&itag=#{fmt["itag"]}"
|
||||||
src_url += "&local=true" if params.local
|
src_url += "&local=true" if params.local
|
||||||
src_url = video.invidious_companion["baseUrl"].as_s + src_url +
|
src_url = video.invidious_companion["baseUrl"].as_s + src_url +
|
||||||
"&check=#{invidious_companion_encrypt(video.id)}" if (!CONFIG.invidious_companion.empty?)
|
"&check=#{invidious_companion_encrypt(video.id)}" if (CONFIG.invidious_companion.present?)
|
||||||
|
|
||||||
bitrate = fmt["bitrate"]
|
bitrate = fmt["bitrate"]
|
||||||
mimetype = HTML.escape(fmt["mimeType"].as_s)
|
mimetype = HTML.escape(fmt["mimeType"].as_s)
|
||||||
@ -39,7 +39,7 @@
|
|||||||
<% if params.quality == "dash"
|
<% if params.quality == "dash"
|
||||||
src_url = "/api/manifest/dash/id/" + video.id + "?local=true&unique_res=1"
|
src_url = "/api/manifest/dash/id/" + video.id + "?local=true&unique_res=1"
|
||||||
src_url = video.invidious_companion["baseUrl"].as_s + src_url +
|
src_url = video.invidious_companion["baseUrl"].as_s + src_url +
|
||||||
"&check=#{invidious_companion_encrypt(video.id)}" if (!CONFIG.invidious_companion.empty?)
|
"&check=#{invidious_companion_encrypt(video.id)}" if (CONFIG.invidious_companion.present?)
|
||||||
%>
|
%>
|
||||||
<source src="<%= src_url %>" type='application/dash+xml' label="dash">
|
<source src="<%= src_url %>" type='application/dash+xml' label="dash">
|
||||||
<% end %>
|
<% end %>
|
||||||
@ -51,7 +51,7 @@
|
|||||||
src_url = "/latest_version?id=#{video.id}&itag=#{fmt["itag"]}"
|
src_url = "/latest_version?id=#{video.id}&itag=#{fmt["itag"]}"
|
||||||
src_url += "&local=true" if params.local
|
src_url += "&local=true" if params.local
|
||||||
src_url = video.invidious_companion["baseUrl"].as_s + src_url +
|
src_url = video.invidious_companion["baseUrl"].as_s + src_url +
|
||||||
"&check=#{invidious_companion_encrypt(video.id)}" if (!CONFIG.invidious_companion.empty?)
|
"&check=#{invidious_companion_encrypt(video.id)}" if (CONFIG.invidious_companion.present?)
|
||||||
|
|
||||||
quality = fmt["quality"]
|
quality = fmt["quality"]
|
||||||
mimetype = HTML.escape(fmt["mimeType"].as_s)
|
mimetype = HTML.escape(fmt["mimeType"].as_s)
|
||||||
|
@ -500,7 +500,7 @@ module YoutubeAPI
|
|||||||
data["params"] = params
|
data["params"] = params
|
||||||
end
|
end
|
||||||
|
|
||||||
if !CONFIG.invidious_companion.empty?
|
if CONFIG.invidious_companion.present?
|
||||||
return self._post_invidious_companion("/youtubei/v1/player", data)
|
return self._post_invidious_companion("/youtubei/v1/player", data)
|
||||||
else
|
else
|
||||||
return self._post_json("/youtubei/v1/player", data, client_config)
|
return self._post_json("/youtubei/v1/player", data, client_config)
|
||||||
@ -696,7 +696,7 @@ module YoutubeAPI
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
invidious_companion = CONFIG.invidious_companion.sample
|
invidious_companion = CONFIG.invidious_companion.sample
|
||||||
response = make_client(invidious_companion.private_url,
|
response = make_client(invidious_companion.private_url, use_http_proxy: false
|
||||||
&.post(endpoint, headers: headers, body: data.to_json))
|
&.post(endpoint, headers: headers, body: data.to_json))
|
||||||
body = response.body
|
body = response.body
|
||||||
if (response.status_code != 200)
|
if (response.status_code != 200)
|
||||||
|
Loading…
Reference in New Issue
Block a user