Skip to content

Commit 1c91110

Browse files
committed
Fix some 'Lint/ShadowingOuterLocalVar' warnings reported by ameba
1 parent 4cd7a3e commit 1c91110

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

src/invidious/routes/api/v1/authenticated.cr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ module Invidious::Routes::API::V1::Authenticated
138138
return error_json(400, "Invalid title.")
139139
end
140140

141-
privacy = env.params.json["privacy"]?.try { |privacy| PlaylistPrivacy.parse(privacy.as(String).downcase) }
141+
privacy = env.params.json["privacy"]?.try { |p| PlaylistPrivacy.parse(p.as(String).downcase) }
142142
if !privacy
143143
return error_json(400, "Invalid privacy setting.")
144144
end
@@ -175,7 +175,7 @@ module Invidious::Routes::API::V1::Authenticated
175175
end
176176

177177
title = env.params.json["title"].try &.as(String).delete("<>").byte_slice(0, 150) || playlist.title
178-
privacy = env.params.json["privacy"]?.try { |privacy| PlaylistPrivacy.parse(privacy.as(String).downcase) } || playlist.privacy
178+
privacy = env.params.json["privacy"]?.try { |p| PlaylistPrivacy.parse(p.as(String).downcase) } || playlist.privacy
179179
description = env.params.json["description"]?.try &.as(String).delete("\r") || playlist.description
180180

181181
if title != playlist.title ||

src/invidious/routes/api/v1/videos.cr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ module Invidious::Routes::API::V1::Videos
7171
env.response.content_type = "text/vtt; charset=UTF-8"
7272

7373
if lang
74-
caption = captions.select { |caption| caption.language_code == lang }
74+
caption = captions.select(&.language_code.== lang)
7575
else
76-
caption = captions.select { |caption| caption.name == label }
76+
caption = captions.select(&.name.== label)
7777
end
7878

7979
if caption.empty?
@@ -179,7 +179,7 @@ module Invidious::Routes::API::V1::Videos
179179

180180
env.response.content_type = "text/vtt"
181181

182-
storyboard = storyboards.select { |storyboard| width == "#{storyboard[:width]}" || height == "#{storyboard[:height]}" }
182+
storyboard = storyboards.select { |sb| width == "#{sb[:width]}" || height == "#{sb[:height]}" }
183183

184184
if storyboard.empty?
185185
haltf env, 404

src/invidious/routes/video_playback.cr

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,16 @@ module Invidious::Routes::VideoPlayback
7575
end
7676

7777
begin
78-
client.get(url, headers) do |response|
79-
response.headers.each do |key, value|
78+
client.get(url, headers) do |resp|
79+
resp.headers.each do |key, value|
8080
if !RESPONSE_HEADERS_BLACKLIST.includes?(key.downcase)
8181
env.response.headers[key] = value
8282
end
8383
end
8484

8585
env.response.headers["Access-Control-Allow-Origin"] = "*"
8686

87-
if location = response.headers["Location"]?
87+
if location = resp.headers["Location"]?
8888
location = URI.parse(location)
8989
location = "#{location.request_target}&host=#{location.host}"
9090

@@ -95,7 +95,7 @@ module Invidious::Routes::VideoPlayback
9595
return env.redirect location
9696
end
9797

98-
IO.copy(response.body_io, env.response)
98+
IO.copy(resp.body_io, env.response)
9999
end
100100
rescue ex
101101
end
@@ -132,23 +132,23 @@ module Invidious::Routes::VideoPlayback
132132
headers["Range"] = "bytes=#{chunk_start}-#{chunk_end}"
133133

134134
begin
135-
client.get(url, headers) do |response|
135+
client.get(url, headers) do |resp|
136136
if first_chunk
137-
if !env.request.headers["Range"]? && response.status_code == 206
137+
if !env.request.headers["Range"]? && resp.status_code == 206
138138
env.response.status_code = 200
139139
else
140-
env.response.status_code = response.status_code
140+
env.response.status_code = resp.status_code
141141
end
142142

143-
response.headers.each do |key, value|
143+
resp.headers.each do |key, value|
144144
if !RESPONSE_HEADERS_BLACKLIST.includes?(key.downcase) && key.downcase != "content-range"
145145
env.response.headers[key] = value
146146
end
147147
end
148148

149149
env.response.headers["Access-Control-Allow-Origin"] = "*"
150150

151-
if location = response.headers["Location"]?
151+
if location = resp.headers["Location"]?
152152
location = URI.parse(location)
153153
location = "#{location.request_target}&host=#{location.host}#{region ? "&region=#{region}" : ""}"
154154

@@ -161,8 +161,8 @@ module Invidious::Routes::VideoPlayback
161161
env.response.headers["Content-Disposition"] = "attachment; filename=\"#{URI.encode_www_form(title)}\"; filename*=UTF-8''#{URI.encode_www_form(title)}"
162162
end
163163

164-
if !response.headers.includes_word?("Transfer-Encoding", "chunked")
165-
content_length = response.headers["Content-Range"].split("/")[-1].to_i64
164+
if !resp.headers.includes_word?("Transfer-Encoding", "chunked")
165+
content_length = resp.headers["Content-Range"].split("/")[-1].to_i64
166166
if env.request.headers["Range"]?
167167
env.response.headers["Content-Range"] = "bytes #{range_start}-#{range_end || (content_length - 1)}/#{content_length}"
168168
env.response.content_length = ((range_end.try &.+ 1) || content_length) - range_start
@@ -172,7 +172,7 @@ module Invidious::Routes::VideoPlayback
172172
end
173173
end
174174

175-
proxy_file(response, env)
175+
proxy_file(resp, env)
176176
end
177177
rescue ex
178178
if ex.message != "Error reading socket: Connection reset by peer"

0 commit comments

Comments
 (0)