summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/invidious/channels/about.cr5
-rw-r--r--src/invidious/helpers/i18n.cr4
-rw-r--r--src/invidious/helpers/json_filter.cr4
-rw-r--r--src/invidious/helpers/static_file_handler.cr6
-rw-r--r--src/invidious/helpers/tokens.cr3
-rw-r--r--src/invidious/helpers/utils.cr4
-rw-r--r--src/invidious/playlists.cr4
-rw-r--r--src/invidious/routes/api/manifest.cr2
-rw-r--r--src/invidious/routes/login.cr4
-rw-r--r--src/invidious/videos.cr4
10 files changed, 22 insertions, 18 deletions
diff --git a/src/invidious/channels/about.cr b/src/invidious/channels/about.cr
index 8cae7ae2..0f3928f5 100644
--- a/src/invidious/channels/about.cr
+++ b/src/invidious/channels/about.cr
@@ -96,7 +96,7 @@ def get_about_info(ucid, locale) : AboutChannel
total_views = channel_about_meta["viewCountText"]?.try &.["simpleText"]?.try &.as_s.gsub(/\D/, "").to_i64? || 0_i64
# The joined text is split to several sub strings. The reduce joins those strings before parsing the date.
- joined = channel_about_meta["joinedDateText"]?.try &.["runs"]?.try &.as_a.reduce("") { |acc, node| acc + node["text"].as_s }
+ joined = channel_about_meta["joinedDateText"]?.try &.["runs"]?.try &.as_a.reduce("") { |acc, nd| acc + nd["text"].as_s }
.try { |text| Time.parse(text, "Joined %b %-d, %Y", Time::Location.local) } || Time.unix(0)
# Normal Auto-generated channels
@@ -136,7 +136,8 @@ def fetch_related_channels(about_channel : AboutChannel) : Array(AboutRelatedCha
channels = YoutubeAPI.browse(browse_id: about_channel.ucid, params: "EghjaGFubmVscw%3D%3D")
tabs = channels.dig?("contents", "twoColumnBrowseResultsRenderer", "tabs").try(&.as_a?) || [] of JSON::Any
- tab = tabs.find { |tab| tab.dig?("tabRenderer", "title").try(&.as_s?) == "Channels" }
+ tab = tabs.find(&.dig?("tabRenderer", "title").try(&.as_s?).try(&.== "Channels"))
+
return [] of AboutRelatedChannel if tab.nil?
items = tab.dig?("tabRenderer", "content", "sectionListRenderer", "contents", 0, "itemSectionRenderer", "contents", 0, "gridRenderer", "items").try(&.as_a?) || [] of JSON::Any
diff --git a/src/invidious/helpers/i18n.cr b/src/invidious/helpers/i18n.cr
index e88e4491..3cf9ad1c 100644
--- a/src/invidious/helpers/i18n.cr
+++ b/src/invidious/helpers/i18n.cr
@@ -94,8 +94,8 @@ def translate(locale : String?, key : String, text : String | Nil = nil) : Strin
translation = ""
match_length = 0
- raw_data.as_h.each do |key, value|
- if md = text.try &.match(/#{key}/)
+ raw_data.as_h.each do |hash_key, value|
+ if md = text.try &.match(/#{hash_key}/)
if md[0].size >= match_length
translation = value.as_s
match_length = md[0].size
diff --git a/src/invidious/helpers/json_filter.cr b/src/invidious/helpers/json_filter.cr
index e4b57cea..b8e8f96d 100644
--- a/src/invidious/helpers/json_filter.cr
+++ b/src/invidious/helpers/json_filter.cr
@@ -98,9 +98,9 @@ module JSONFilter
end
end
- group_name.split('/').each do |group_name|
+ group_name.split('/').each do |name|
nest_stack.push({
- group_name: group_name,
+ group_name: name,
closing_bracket_index: closing_bracket_index,
})
end
diff --git a/src/invidious/helpers/static_file_handler.cr b/src/invidious/helpers/static_file_handler.cr
index 630c2fd2..6b3cd22e 100644
--- a/src/invidious/helpers/static_file_handler.cr
+++ b/src/invidious/helpers/static_file_handler.cr
@@ -175,9 +175,9 @@ module Kemal
if @cached_files.sum(&.[1][:data].bytesize) + (size = File.size(file_path)) < CACHE_LIMIT
data = Bytes.new(size)
- File.open(file_path) do |file|
- file.read(data)
- end
+
+ File.open(file_path) { |f| f.read(data) }
+
filestat = File.info(file_path)
@cached_files[file_path] = {data: data, filestat: filestat}
diff --git a/src/invidious/helpers/tokens.cr b/src/invidious/helpers/tokens.cr
index 8b076e39..9b664646 100644
--- a/src/invidious/helpers/tokens.cr
+++ b/src/invidious/helpers/tokens.cr
@@ -42,6 +42,9 @@ end
def sign_token(key, hash)
string_to_sign = [] of String
+ # TODO: figure out which "key" variable is used
+ # Ameba reports a warning for "Lint/ShadowingOuterLocalVar" on this
+ # variable, but its preferrable to not touch that (works fine atm).
hash.each do |key, value|
next if key == "signature"
diff --git a/src/invidious/helpers/utils.cr b/src/invidious/helpers/utils.cr
index 09181c10..3ab9a0fc 100644
--- a/src/invidious/helpers/utils.cr
+++ b/src/invidious/helpers/utils.cr
@@ -292,8 +292,8 @@ def parse_range(range)
end
ranges = range.lchop("bytes=").split(',')
- ranges.each do |range|
- start_range, end_range = range.split('-')
+ ranges.each do |r|
+ start_range, end_range = r.split('-')
start_range = start_range.to_i64? || 0_i64
end_range = end_range.to_i64?
diff --git a/src/invidious/playlists.cr b/src/invidious/playlists.cr
index afbc8624..177cee0f 100644
--- a/src/invidious/playlists.cr
+++ b/src/invidious/playlists.cr
@@ -202,8 +202,8 @@ struct InvidiousPlaylist
end
videos = get_playlist_videos(self, offset: offset, video_id: video_id)
- videos.each_with_index do |video, index|
- video.to_json(json, offset + index)
+ videos.each_with_index do |video, idx|
+ video.to_json(json, offset + idx)
end
end
end
diff --git a/src/invidious/routes/api/manifest.cr b/src/invidious/routes/api/manifest.cr
index b6183001..ca429df5 100644
--- a/src/invidious/routes/api/manifest.cr
+++ b/src/invidious/routes/api/manifest.cr
@@ -98,7 +98,7 @@ module Invidious::Routes::API::Manifest
height = fmt["height"].as_i
# Resolutions reported by YouTube player (may not accurately reflect source)
- height = potential_heights.min_by { |i| (height - i).abs }
+ height = potential_heights.min_by { |x| (height - x).abs }
next if unique_res && heights.includes? height
heights << height
diff --git a/src/invidious/routes/login.cr b/src/invidious/routes/login.cr
index 64da3e4e..f4859e6f 100644
--- a/src/invidious/routes/login.cr
+++ b/src/invidious/routes/login.cr
@@ -425,9 +425,9 @@ module Invidious::Routes::Login
found_valid_captcha = false
error_exception = Exception.new
- tokens.each do |token|
+ tokens.each do |tok|
begin
- validate_request(token, answer, env.request, HMAC_KEY, locale)
+ validate_request(tok, answer, env.request, HMAC_KEY, locale)
found_valid_captcha = true
rescue ex
error_exception = ex
diff --git a/src/invidious/videos.cr b/src/invidious/videos.cr
index 499ed94d..5cec1175 100644
--- a/src/invidious/videos.cr
+++ b/src/invidious/videos.cr
@@ -661,8 +661,8 @@ struct Video
url = URI.parse(storyboards.shift)
params = HTTP::Params.parse(url.query || "")
- storyboards.each_with_index do |storyboard, i|
- width, height, count, storyboard_width, storyboard_height, interval, _, sigh = storyboard.split("#")
+ storyboards.each_with_index do |sb, i|
+ width, height, count, storyboard_width, storyboard_height, interval, _, sigh = sb.split("#")
params["sigh"] = sigh
url.query = params.to_s