Remove useless 'locale = env.get...' from many routes

This commit is contained in:
Samantaz Fox 2022-01-20 16:03:04 +01:00
parent fa99c9aa85
commit 4cd7a3e83f
No known key found for this signature in database
GPG Key ID: F42821059186176E
4 changed files with 1 additions and 24 deletions

View File

@ -115,8 +115,6 @@ module Invidious::Routes::API::V1::Authenticated
end end
def self.list_playlists(env) def self.list_playlists(env)
locale = env.get("preferences").as(Preferences).locale
env.response.content_type = "application/json" env.response.content_type = "application/json"
user = env.get("user").as(User) user = env.get("user").as(User)
@ -134,7 +132,6 @@ module Invidious::Routes::API::V1::Authenticated
def self.create_playlist(env) def self.create_playlist(env)
env.response.content_type = "application/json" env.response.content_type = "application/json"
user = env.get("user").as(User) 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) title = env.params.json["title"]?.try &.as(String).delete("<>").byte_slice(0, 150)
if !title if !title
@ -160,8 +157,6 @@ module Invidious::Routes::API::V1::Authenticated
end end
def self.update_playlist_attribute(env) def self.update_playlist_attribute(env)
locale = env.get("preferences").as(Preferences).locale
env.response.content_type = "application/json" env.response.content_type = "application/json"
user = env.get("user").as(User) user = env.get("user").as(User)
@ -197,8 +192,6 @@ module Invidious::Routes::API::V1::Authenticated
end end
def self.delete_playlist(env) def self.delete_playlist(env)
locale = env.get("preferences").as(Preferences).locale
env.response.content_type = "application/json" env.response.content_type = "application/json"
user = env.get("user").as(User) user = env.get("user").as(User)
@ -219,8 +212,6 @@ module Invidious::Routes::API::V1::Authenticated
end end
def self.insert_video_into_playlist(env) def self.insert_video_into_playlist(env)
locale = env.get("preferences").as(Preferences).locale
env.response.content_type = "application/json" env.response.content_type = "application/json"
user = env.get("user").as(User) user = env.get("user").as(User)
@ -274,8 +265,6 @@ module Invidious::Routes::API::V1::Authenticated
end end
def self.delete_video_in_playlist(env) def self.delete_video_in_playlist(env)
locale = env.get("preferences").as(Preferences).locale
env.response.content_type = "application/json" env.response.content_type = "application/json"
user = env.get("user").as(User) user = env.get("user").as(User)
@ -389,8 +378,8 @@ module Invidious::Routes::API::V1::Authenticated
end end
def self.unregister_token(env) def self.unregister_token(env)
locale = env.get("preferences").as(Preferences).locale
env.response.content_type = "application/json" env.response.content_type = "application/json"
user = env.get("user").as(User) user = env.get("user").as(User)
scopes = env.get("scopes").as(Array(String)) scopes = env.get("scopes").as(Array(String))

View File

@ -1,7 +1,6 @@
module Invidious::Routes::API::V1::Misc module Invidious::Routes::API::V1::Misc
# Stats API endpoint for Invidious # Stats API endpoint for Invidious
def self.stats(env) def self.stats(env)
locale = env.get("preferences").as(Preferences).locale
env.response.content_type = "application/json" env.response.content_type = "application/json"
if !CONFIG.statistics_enabled 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 # user playlists and Invidious playlists. This means that we can't
# reasonably split them yet. This should be addressed in APIv2 # reasonably split them yet. This should be addressed in APIv2
def self.get_playlist(env : HTTP::Server::Context) def self.get_playlist(env : HTTP::Server::Context)
locale = env.get("preferences").as(Preferences).locale
env.response.content_type = "application/json" env.response.content_type = "application/json"
plid = env.params.url["plid"] plid = env.params.url["plid"]

View File

@ -20,8 +20,6 @@ module Invidious::Routes::API::V1::Videos
end end
def self.captions(env) def self.captions(env)
locale = env.get("preferences").as(Preferences).locale
env.response.content_type = "application/json" env.response.content_type = "application/json"
id = env.params.url["id"] id = env.params.url["id"]
@ -149,8 +147,6 @@ module Invidious::Routes::API::V1::Videos
# thumbnails for individual scenes in a video. # thumbnails for individual scenes in a video.
# See https://support.jwplayer.com/articles/how-to-add-preview-thumbnails # See https://support.jwplayer.com/articles/how-to-add-preview-thumbnails
def self.storyboards(env) def self.storyboards(env)
locale = env.get("preferences").as(Preferences).locale
env.response.content_type = "application/json" env.response.content_type = "application/json"
id = env.params.url["id"] id = env.params.url["id"]
@ -223,8 +219,6 @@ module Invidious::Routes::API::V1::Videos
end end
def self.annotations(env) def self.annotations(env)
locale = env.get("preferences").as(Preferences).locale
env.response.content_type = "text/xml" env.response.content_type = "text/xml"
id = env.params.url["id"] id = env.params.url["id"]

View File

@ -2,8 +2,6 @@
module Invidious::Routes::Embed module Invidious::Routes::Embed
def self.redirect(env) def self.redirect(env)
locale = env.get("preferences").as(Preferences).locale
if plid = env.params.query["list"]?.try &.gsub(/[^a-zA-Z0-9_-]/, "") if plid = env.params.query["list"]?.try &.gsub(/[^a-zA-Z0-9_-]/, "")
begin begin
playlist = get_playlist(plid) playlist = get_playlist(plid)
@ -26,7 +24,6 @@ module Invidious::Routes::Embed
end end
def self.show(env) def self.show(env)
locale = env.get("preferences").as(Preferences).locale
id = env.params.url["id"] id = env.params.url["id"]
plid = env.params.query["list"]?.try &.gsub(/[^a-zA-Z0-9_-]/, "") plid = env.params.query["list"]?.try &.gsub(/[^a-zA-Z0-9_-]/, "")