Skip to content

Invidious is an alternative front-end to YouTube

chore: lint and remove unused variables

Fijxue4ad826f1fcc
diff --git a/src/invidious/routes/api/manifest.cr b/src/invidious/routes/api/manifest.cr
index c27caad7..88430029 100644
--- a/src/invidious/routes/api/manifest.cr
+++ b/src/invidious/routes/api/manifest.cr
@@ -81,7 +81,6 @@ module Invidious::Routes::API::Manifest
xml.element("AdaptationSet", id: i, mimeType: mime_type, startWithSAP: 1, subsegmentAlignment: true, label: "#{displayname} [#{bitrate}k]", lang: lang) do
codecs = fmt["mimeType"].as_s.split("codecs=")[1].strip('"')
bandwidth = fmt["bitrate"].as_i
- itag = fmt["itag"].as_i
url = fmt["url"].as_s
xml.element("Role", schemeIdUri: "urn:mpeg:dash:role:2011", value: is_default ? "main" : "alternate")
diff --git a/src/invidious/routes/api/v1/authenticated.cr b/src/invidious/routes/api/v1/authenticated.cr
index ebbbc2a7..da706a9e 100644
--- a/src/invidious/routes/api/v1/authenticated.cr
+++ b/src/invidious/routes/api/v1/authenticated.cr
@@ -380,7 +380,6 @@ module Invidious::Routes::API::V1::Authenticated
def self.get_tokens(env)
env.response.content_type = "application/json"
user = env.get("user").as(User)
- scopes = env.get("scopes").as(Array(String))
tokens = Invidious::Database::SessionIDs.select_all(user.email)
@@ -398,6 +397,8 @@ module Invidious::Routes::API::V1::Authenticated
def self.register_token(env)
user = env.get("user").as(User)
+ # Used by template bellow.
+ # ameba:disable Lint/UselessAssign
locale = env.get("preferences").as(Preferences).locale
case env.request.headers["Content-Type"]?
@@ -424,6 +425,8 @@ module Invidious::Routes::API::V1::Authenticated
if sid = env.get?("sid").try &.as(String)
env.response.content_type = "text/html"
+ # Used by template bellow.
+ # ameba:disable Lint/UselessAssign
csrf_token = generate_response(sid, {":authorize_token"}, HMAC_KEY, use_nonce: true)
return templated "user/authorize_token"
else
@@ -462,7 +465,6 @@ module Invidious::Routes::API::V1::Authenticated
def self.unregister_token(env)
env.response.content_type = "application/json"
- user = env.get("user").as(User)
scopes = env.get("scopes").as(Array(String))
session = env.params.json["session"]?.try &.as(String)
@@ -484,7 +486,7 @@ module Invidious::Routes::API::V1::Authenticated
env.response.content_type = "text/event-stream"
raw_topics = env.params.body["topics"]? || env.params.query["topics"]?
- topics = raw_topics.try &.split(",").uniq.first(1000)
+ topics = raw_topics.try &.split(",").uniq!.first(1000)
topics ||= [] of String
Helpers.create_notification_stream(env, topics, CONNECTION_CHANNEL)
diff --git a/src/invidious/routes/api/v1/channels.cr b/src/invidious/routes/api/v1/channels.cr
index b72aa6cf..8c21fe19 100644
--- a/src/invidious/routes/api/v1/channels.cr
+++ b/src/invidious/routes/api/v1/channels.cr
@@ -35,7 +35,6 @@ module Invidious::Routes::API::V1::Channels
# playlist doesnt exist.
videos = [] of PlaylistVideo
end
- next_continuation = nil
else
begin
videos, _ = Channel::Tabs.get_videos(channel, sort_by: sort_by)
diff --git a/src/invidious/routes/api/v1/feeds.cr b/src/invidious/routes/api/v1/feeds.cr
index fea2993c..46618008 100644
--- a/src/invidious/routes/api/v1/feeds.cr
+++ b/src/invidious/routes/api/v1/feeds.cr
@@ -8,7 +8,7 @@ module Invidious::Routes::API::V1::Feeds
trending_type = env.params.query["type"]?
begin
- trending, plid = fetch_trending(trending_type, region, locale)
+ trending, _ = fetch_trending(trending_type, region, locale)
rescue ex
return error_json(500, ex)
end
diff --git a/src/invidious/routes/api/v1/videos.cr b/src/invidious/routes/api/v1/videos.cr
index 5600e30d..14221ed0 100644
--- a/src/invidious/routes/api/v1/videos.cr
+++ b/src/invidious/routes/api/v1/videos.cr
@@ -340,6 +340,9 @@ module Invidious::Routes::API::V1::Videos
format ||= "json"
action = env.params.query["action"]?
+ # 2026-09-14 TODO: Check if action is or can be used somewhere
+ # as is unused currently, but for some reason is it here.
+ # ameba:disable Lint/UselessAssign
action ||= "action_get_comments"
continuation = env.params.query["continuation"]?
diff --git a/src/invidious/yt_backend/youtube_api.cr b/src/invidious/yt_backend/youtube_api.cr
index c40133ed..6a38ded6 100644
--- a/src/invidious/yt_backend/youtube_api.cr
+++ b/src/invidious/yt_backend/youtube_api.cr
@@ -696,7 +696,7 @@ module YoutubeAPI
# Multiple encodings can be combined, and are listed in the order
# in which they were applied. E.g: "deflate, gzip" means that the
# content must be first "gunzipped", then "defated".
- encodings.split(',').reverse.each do |enc|
+ encodings.split(',').reverse!.each do |enc|
case enc.strip(' ')
when "gzip"
body_io = Compress::Gzip::Reader.new(body_io, sync_close: true)