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