forked from midou/invidious
Fix some 'Lint/ShadowingOuterLocalVar' warnings reported by ameba
This commit is contained in:
parent
4cd7a3e83f
commit
1c91110464
@ -138,7 +138,7 @@ module Invidious::Routes::API::V1::Authenticated
|
|||||||
return error_json(400, "Invalid title.")
|
return error_json(400, "Invalid title.")
|
||||||
end
|
end
|
||||||
|
|
||||||
privacy = env.params.json["privacy"]?.try { |privacy| PlaylistPrivacy.parse(privacy.as(String).downcase) }
|
privacy = env.params.json["privacy"]?.try { |p| PlaylistPrivacy.parse(p.as(String).downcase) }
|
||||||
if !privacy
|
if !privacy
|
||||||
return error_json(400, "Invalid privacy setting.")
|
return error_json(400, "Invalid privacy setting.")
|
||||||
end
|
end
|
||||||
@ -175,7 +175,7 @@ module Invidious::Routes::API::V1::Authenticated
|
|||||||
end
|
end
|
||||||
|
|
||||||
title = env.params.json["title"].try &.as(String).delete("<>").byte_slice(0, 150) || playlist.title
|
title = env.params.json["title"].try &.as(String).delete("<>").byte_slice(0, 150) || playlist.title
|
||||||
privacy = env.params.json["privacy"]?.try { |privacy| PlaylistPrivacy.parse(privacy.as(String).downcase) } || playlist.privacy
|
privacy = env.params.json["privacy"]?.try { |p| PlaylistPrivacy.parse(p.as(String).downcase) } || playlist.privacy
|
||||||
description = env.params.json["description"]?.try &.as(String).delete("\r") || playlist.description
|
description = env.params.json["description"]?.try &.as(String).delete("\r") || playlist.description
|
||||||
|
|
||||||
if title != playlist.title ||
|
if title != playlist.title ||
|
||||||
|
@ -71,9 +71,9 @@ module Invidious::Routes::API::V1::Videos
|
|||||||
env.response.content_type = "text/vtt; charset=UTF-8"
|
env.response.content_type = "text/vtt; charset=UTF-8"
|
||||||
|
|
||||||
if lang
|
if lang
|
||||||
caption = captions.select { |caption| caption.language_code == lang }
|
caption = captions.select(&.language_code.== lang)
|
||||||
else
|
else
|
||||||
caption = captions.select { |caption| caption.name == label }
|
caption = captions.select(&.name.== label)
|
||||||
end
|
end
|
||||||
|
|
||||||
if caption.empty?
|
if caption.empty?
|
||||||
@ -179,7 +179,7 @@ module Invidious::Routes::API::V1::Videos
|
|||||||
|
|
||||||
env.response.content_type = "text/vtt"
|
env.response.content_type = "text/vtt"
|
||||||
|
|
||||||
storyboard = storyboards.select { |storyboard| width == "#{storyboard[:width]}" || height == "#{storyboard[:height]}" }
|
storyboard = storyboards.select { |sb| width == "#{sb[:width]}" || height == "#{sb[:height]}" }
|
||||||
|
|
||||||
if storyboard.empty?
|
if storyboard.empty?
|
||||||
haltf env, 404
|
haltf env, 404
|
||||||
|
@ -75,8 +75,8 @@ module Invidious::Routes::VideoPlayback
|
|||||||
end
|
end
|
||||||
|
|
||||||
begin
|
begin
|
||||||
client.get(url, headers) do |response|
|
client.get(url, headers) do |resp|
|
||||||
response.headers.each do |key, value|
|
resp.headers.each do |key, value|
|
||||||
if !RESPONSE_HEADERS_BLACKLIST.includes?(key.downcase)
|
if !RESPONSE_HEADERS_BLACKLIST.includes?(key.downcase)
|
||||||
env.response.headers[key] = value
|
env.response.headers[key] = value
|
||||||
end
|
end
|
||||||
@ -84,7 +84,7 @@ module Invidious::Routes::VideoPlayback
|
|||||||
|
|
||||||
env.response.headers["Access-Control-Allow-Origin"] = "*"
|
env.response.headers["Access-Control-Allow-Origin"] = "*"
|
||||||
|
|
||||||
if location = response.headers["Location"]?
|
if location = resp.headers["Location"]?
|
||||||
location = URI.parse(location)
|
location = URI.parse(location)
|
||||||
location = "#{location.request_target}&host=#{location.host}"
|
location = "#{location.request_target}&host=#{location.host}"
|
||||||
|
|
||||||
@ -95,7 +95,7 @@ module Invidious::Routes::VideoPlayback
|
|||||||
return env.redirect location
|
return env.redirect location
|
||||||
end
|
end
|
||||||
|
|
||||||
IO.copy(response.body_io, env.response)
|
IO.copy(resp.body_io, env.response)
|
||||||
end
|
end
|
||||||
rescue ex
|
rescue ex
|
||||||
end
|
end
|
||||||
@ -132,15 +132,15 @@ module Invidious::Routes::VideoPlayback
|
|||||||
headers["Range"] = "bytes=#{chunk_start}-#{chunk_end}"
|
headers["Range"] = "bytes=#{chunk_start}-#{chunk_end}"
|
||||||
|
|
||||||
begin
|
begin
|
||||||
client.get(url, headers) do |response|
|
client.get(url, headers) do |resp|
|
||||||
if first_chunk
|
if first_chunk
|
||||||
if !env.request.headers["Range"]? && response.status_code == 206
|
if !env.request.headers["Range"]? && resp.status_code == 206
|
||||||
env.response.status_code = 200
|
env.response.status_code = 200
|
||||||
else
|
else
|
||||||
env.response.status_code = response.status_code
|
env.response.status_code = resp.status_code
|
||||||
end
|
end
|
||||||
|
|
||||||
response.headers.each do |key, value|
|
resp.headers.each do |key, value|
|
||||||
if !RESPONSE_HEADERS_BLACKLIST.includes?(key.downcase) && key.downcase != "content-range"
|
if !RESPONSE_HEADERS_BLACKLIST.includes?(key.downcase) && key.downcase != "content-range"
|
||||||
env.response.headers[key] = value
|
env.response.headers[key] = value
|
||||||
end
|
end
|
||||||
@ -148,7 +148,7 @@ module Invidious::Routes::VideoPlayback
|
|||||||
|
|
||||||
env.response.headers["Access-Control-Allow-Origin"] = "*"
|
env.response.headers["Access-Control-Allow-Origin"] = "*"
|
||||||
|
|
||||||
if location = response.headers["Location"]?
|
if location = resp.headers["Location"]?
|
||||||
location = URI.parse(location)
|
location = URI.parse(location)
|
||||||
location = "#{location.request_target}&host=#{location.host}#{region ? "®ion=#{region}" : ""}"
|
location = "#{location.request_target}&host=#{location.host}#{region ? "®ion=#{region}" : ""}"
|
||||||
|
|
||||||
@ -161,8 +161,8 @@ module Invidious::Routes::VideoPlayback
|
|||||||
env.response.headers["Content-Disposition"] = "attachment; filename=\"#{URI.encode_www_form(title)}\"; filename*=UTF-8''#{URI.encode_www_form(title)}"
|
env.response.headers["Content-Disposition"] = "attachment; filename=\"#{URI.encode_www_form(title)}\"; filename*=UTF-8''#{URI.encode_www_form(title)}"
|
||||||
end
|
end
|
||||||
|
|
||||||
if !response.headers.includes_word?("Transfer-Encoding", "chunked")
|
if !resp.headers.includes_word?("Transfer-Encoding", "chunked")
|
||||||
content_length = response.headers["Content-Range"].split("/")[-1].to_i64
|
content_length = resp.headers["Content-Range"].split("/")[-1].to_i64
|
||||||
if env.request.headers["Range"]?
|
if env.request.headers["Range"]?
|
||||||
env.response.headers["Content-Range"] = "bytes #{range_start}-#{range_end || (content_length - 1)}/#{content_length}"
|
env.response.headers["Content-Range"] = "bytes #{range_start}-#{range_end || (content_length - 1)}/#{content_length}"
|
||||||
env.response.content_length = ((range_end.try &.+ 1) || content_length) - range_start
|
env.response.content_length = ((range_end.try &.+ 1) || content_length) - range_start
|
||||||
@ -172,7 +172,7 @@ module Invidious::Routes::VideoPlayback
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
proxy_file(response, env)
|
proxy_file(resp, env)
|
||||||
end
|
end
|
||||||
rescue ex
|
rescue ex
|
||||||
if ex.message != "Error reading socket: Connection reset by peer"
|
if ex.message != "Error reading socket: Connection reset by peer"
|
||||||
|
Loading…
Reference in New Issue
Block a user