From 4cd7a3e83f904f763497f214c52d52237d99228b Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Thu, 20 Jan 2022 16:03:04 +0100 Subject: [PATCH] Remove useless 'locale = env.get...' from many routes --- src/invidious/routes/api/v1/authenticated.cr | 13 +------------ src/invidious/routes/api/v1/misc.cr | 3 --- src/invidious/routes/api/v1/videos.cr | 6 ------ src/invidious/routes/embed.cr | 3 --- 4 files changed, 1 insertion(+), 24 deletions(-) diff --git a/src/invidious/routes/api/v1/authenticated.cr b/src/invidious/routes/api/v1/authenticated.cr index 19c0ee3f..5d2b4c1c 100644 --- a/src/invidious/routes/api/v1/authenticated.cr +++ b/src/invidious/routes/api/v1/authenticated.cr @@ -115,8 +115,6 @@ module Invidious::Routes::API::V1::Authenticated end def self.list_playlists(env) - locale = env.get("preferences").as(Preferences).locale - env.response.content_type = "application/json" user = env.get("user").as(User) @@ -134,7 +132,6 @@ module Invidious::Routes::API::V1::Authenticated def self.create_playlist(env) env.response.content_type = "application/json" user = env.get("user").as(User) - locale = env.get("preferences").as(Preferences).locale title = env.params.json["title"]?.try &.as(String).delete("<>").byte_slice(0, 150) if !title @@ -160,8 +157,6 @@ module Invidious::Routes::API::V1::Authenticated end def self.update_playlist_attribute(env) - locale = env.get("preferences").as(Preferences).locale - env.response.content_type = "application/json" user = env.get("user").as(User) @@ -197,8 +192,6 @@ module Invidious::Routes::API::V1::Authenticated end def self.delete_playlist(env) - locale = env.get("preferences").as(Preferences).locale - env.response.content_type = "application/json" user = env.get("user").as(User) @@ -219,8 +212,6 @@ module Invidious::Routes::API::V1::Authenticated end def self.insert_video_into_playlist(env) - locale = env.get("preferences").as(Preferences).locale - env.response.content_type = "application/json" user = env.get("user").as(User) @@ -274,8 +265,6 @@ module Invidious::Routes::API::V1::Authenticated end def self.delete_video_in_playlist(env) - locale = env.get("preferences").as(Preferences).locale - env.response.content_type = "application/json" user = env.get("user").as(User) @@ -389,8 +378,8 @@ module Invidious::Routes::API::V1::Authenticated end def self.unregister_token(env) - locale = env.get("preferences").as(Preferences).locale env.response.content_type = "application/json" + user = env.get("user").as(User) scopes = env.get("scopes").as(Array(String)) diff --git a/src/invidious/routes/api/v1/misc.cr b/src/invidious/routes/api/v1/misc.cr index d10f4fcc..a1ce0cbc 100644 --- a/src/invidious/routes/api/v1/misc.cr +++ b/src/invidious/routes/api/v1/misc.cr @@ -1,7 +1,6 @@ module Invidious::Routes::API::V1::Misc # Stats API endpoint for Invidious def self.stats(env) - locale = env.get("preferences").as(Preferences).locale env.response.content_type = "application/json" if !CONFIG.statistics_enabled @@ -15,8 +14,6 @@ module Invidious::Routes::API::V1::Misc # user playlists and Invidious playlists. This means that we can't # reasonably split them yet. This should be addressed in APIv2 def self.get_playlist(env : HTTP::Server::Context) - locale = env.get("preferences").as(Preferences).locale - env.response.content_type = "application/json" plid = env.params.url["plid"] diff --git a/src/invidious/routes/api/v1/videos.cr b/src/invidious/routes/api/v1/videos.cr index 3a013ba0..be0f699b 100644 --- a/src/invidious/routes/api/v1/videos.cr +++ b/src/invidious/routes/api/v1/videos.cr @@ -20,8 +20,6 @@ module Invidious::Routes::API::V1::Videos end def self.captions(env) - locale = env.get("preferences").as(Preferences).locale - env.response.content_type = "application/json" id = env.params.url["id"] @@ -149,8 +147,6 @@ module Invidious::Routes::API::V1::Videos # thumbnails for individual scenes in a video. # See https://support.jwplayer.com/articles/how-to-add-preview-thumbnails def self.storyboards(env) - locale = env.get("preferences").as(Preferences).locale - env.response.content_type = "application/json" id = env.params.url["id"] @@ -223,8 +219,6 @@ module Invidious::Routes::API::V1::Videos end def self.annotations(env) - locale = env.get("preferences").as(Preferences).locale - env.response.content_type = "text/xml" id = env.params.url["id"] diff --git a/src/invidious/routes/embed.cr b/src/invidious/routes/embed.cr index 0e9701f0..207970b0 100644 --- a/src/invidious/routes/embed.cr +++ b/src/invidious/routes/embed.cr @@ -2,8 +2,6 @@ module Invidious::Routes::Embed def self.redirect(env) - locale = env.get("preferences").as(Preferences).locale - if plid = env.params.query["list"]?.try &.gsub(/[^a-zA-Z0-9_-]/, "") begin playlist = get_playlist(plid) @@ -26,7 +24,6 @@ module Invidious::Routes::Embed end def self.show(env) - locale = env.get("preferences").as(Preferences).locale id = env.params.url["id"] plid = env.params.query["list"]?.try &.gsub(/[^a-zA-Z0-9_-]/, "")