From 8bc5f938a7b3252b37d5bc9892ef03cfa4531957 Mon Sep 17 00:00:00 2001 From: Fijxu Date: Sun, 5 Oct 2025 17:48:03 -0300 Subject: [PATCH] Remove DEPRECATED session tokens They are not used anymore at all, 100% deprecated as they are not used anymore --- src/invidious.cr | 6 ----- src/invidious/config.cr | 2 -- src/invidious/helpers/session_tokens.cr | 35 ------------------------- src/invidious/jobs/refresh_tokens.cr | 13 --------- 4 files changed, 56 deletions(-) delete mode 100644 src/invidious/helpers/session_tokens.cr delete mode 100644 src/invidious/jobs/refresh_tokens.cr diff --git a/src/invidious.cr b/src/invidious.cr index 93154b25..1e25e672 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -210,12 +210,6 @@ Invidious::Jobs.register Invidious::Jobs::ClearExpiredItemsJob.new Invidious::Jobs.register Invidious::Jobs::InstanceListRefreshJob.new -if !CONFIG.tokens_server.empty? - Invidious::Jobs.register Invidious::Jobs::RefreshSessionTokens.new -else - LOGGER.info("jobs: Disabling RefreshSessionTokens job. Invidious will use the tokens that are on the configuration file") -end - if CONFIG.invidious_companion.present? Invidious::Jobs.register Invidious::Jobs::CheckBackend.new else diff --git a/src/invidious/config.cr b/src/invidious/config.cr index 0a739b95..5dd37968 100644 --- a/src/invidious/config.cr +++ b/src/invidious/config.cr @@ -229,8 +229,6 @@ class Config property server_id_cookie_name : String = "COMPANION_ID" - property tokens_server : String = "" - property video_cache : VideoCacheConfig = VideoCacheConfig.from_yaml("") class VideoCacheConfig diff --git a/src/invidious/helpers/session_tokens.cr b/src/invidious/helpers/session_tokens.cr deleted file mode 100644 index f75ed50b..00000000 --- a/src/invidious/helpers/session_tokens.cr +++ /dev/null @@ -1,35 +0,0 @@ -module SessionTokens - extend self - @@po_token : String | Nil - @@visitor_data : String | Nil - - def refresh_tokens - begin - response = HTTP::Client.get "#{CONFIG.tokens_server}/generate" - if !response.status_code == 200 - LOGGER.error("RefreshSessionTokens: Expected response to have status code 200 but got #{response.status_code} from #{CONFIG.tokens_server}") - end - json = JSON.parse(response.body) - @@po_token = json.try &.["potoken"].as_s || nil - @@visitor_data = json.try &.["visitorData"].as_s || nil - rescue ex - LOGGER.error("RefreshSessionTokens: Failed to fetch tokens from #{CONFIG.tokens_server}: #{ex.message}") - return - end - - if !@@po_token.nil? && !@@visitor_data.nil? - set_tokens - LOGGER.debug("RefreshSessionTokens: Successfully updated po_token and visitor_data") - else - LOGGER.warn("RefreshSessionTokens: Tokens are empty!. Invidious will use the tokens that are on the configuration file") - end - LOGGER.trace("RefreshSessionTokens: Tokens are:") - LOGGER.trace("RefreshSessionTokens: po_token: #{CONFIG.po_token}") - LOGGER.trace("RefreshSessionTokens: visitor_data: #{CONFIG.visitor_data}") - end - - def set_tokens - CONFIG.po_token = @@po_token - CONFIG.visitor_data = @@visitor_data - end -end diff --git a/src/invidious/jobs/refresh_tokens.cr b/src/invidious/jobs/refresh_tokens.cr deleted file mode 100644 index 73e944b8..00000000 --- a/src/invidious/jobs/refresh_tokens.cr +++ /dev/null @@ -1,13 +0,0 @@ -class Invidious::Jobs::RefreshSessionTokens < Invidious::Jobs::BaseJob - def initialize - end - - def begin - loop do - SessionTokens.refresh_tokens - LOGGER.info("RefreshTokens: Done, sleeping for 5 seconds") - sleep 5.seconds - Fiber.yield - end - end -end