mirror of
https://github.com/iv-org/invidious.git
synced 2025-06-06 22:19:03 -04:00
added config option for token updater
This commit is contained in:
parent
27d66259b8
commit
030b301fcc
4 changed files with 53 additions and 6 deletions
|
@ -210,6 +210,14 @@ http_proxy:
|
||||||
# po_token: ""
|
# po_token: ""
|
||||||
# visitor_data: ""
|
# visitor_data: ""
|
||||||
|
|
||||||
|
##
|
||||||
|
## Monitor config for tokens each 1 minute
|
||||||
|
##
|
||||||
|
## Accepted values: true, false
|
||||||
|
## Default: true
|
||||||
|
##
|
||||||
|
tokenmon_enabled : true
|
||||||
|
|
||||||
# -----------------------------
|
# -----------------------------
|
||||||
# Logging
|
# Logging
|
||||||
# -----------------------------
|
# -----------------------------
|
||||||
|
|
|
@ -196,7 +196,9 @@ Invidious::Jobs.register Invidious::Jobs::NotificationJob.new(CONNECTION_CHANNEL
|
||||||
|
|
||||||
Invidious::Jobs.register Invidious::Jobs::ClearExpiredItemsJob.new
|
Invidious::Jobs.register Invidious::Jobs::ClearExpiredItemsJob.new
|
||||||
|
|
||||||
Invidious::Jobs.register Invidious::Jobs::MonitorCfgTokensJob.new()
|
if CONFIG.tokenmon_enabled
|
||||||
|
Invidious::Jobs.register Invidious::Jobs::MonitorCfgTokensJob.new()
|
||||||
|
end
|
||||||
|
|
||||||
Invidious::Jobs.register Invidious::Jobs::InstanceListRefreshJob.new
|
Invidious::Jobs.register Invidious::Jobs::InstanceListRefreshJob.new
|
||||||
|
|
||||||
|
|
|
@ -99,6 +99,7 @@ class Config
|
||||||
property hmac_key : String = ""
|
property hmac_key : String = ""
|
||||||
# Domain to be used for links to resources on the site where an absolute URL is required
|
# Domain to be used for links to resources on the site where an absolute URL is required
|
||||||
property domain : String?
|
property domain : String?
|
||||||
|
property tokenmon_enabled : Bool = true
|
||||||
# Subscribe to channels using PubSubHubbub (requires domain, hmac_key)
|
# Subscribe to channels using PubSubHubbub (requires domain, hmac_key)
|
||||||
property use_pubsub_feeds : Bool | Int32 = false
|
property use_pubsub_feeds : Bool | Int32 = false
|
||||||
property popular_enabled : Bool = true
|
property popular_enabled : Bool = true
|
||||||
|
|
|
@ -23,6 +23,9 @@ module YoutubeAPI
|
||||||
|
|
||||||
private WINDOWS_VERSION = "10.0"
|
private WINDOWS_VERSION = "10.0"
|
||||||
|
|
||||||
|
pot = ""
|
||||||
|
vdata = ""
|
||||||
|
|
||||||
# Enumerate used to select one of the clients supported by the API
|
# Enumerate used to select one of the clients supported by the API
|
||||||
enum ClientType
|
enum ClientType
|
||||||
Web
|
Web
|
||||||
|
@ -273,6 +276,17 @@ module YoutubeAPI
|
||||||
# youtube API endpoints.
|
# youtube API endpoints.
|
||||||
#
|
#
|
||||||
private def make_context(client_config : ClientConfig | Nil, video_id = "dQw4w9WgXcQ") : Hash
|
private def make_context(client_config : ClientConfig | Nil, video_id = "dQw4w9WgXcQ") : Hash
|
||||||
|
# determine po_token and visitor_data
|
||||||
|
if CONFIG.tokenmon_enabled
|
||||||
|
# get the pot/vdata for usage later
|
||||||
|
pot = ReloadTokens.pot.as(String)
|
||||||
|
vdata = ReloadTokens.vdata.as(String)
|
||||||
|
else
|
||||||
|
# Use the configured pot
|
||||||
|
pot = CONFIG.po_token.as(String)
|
||||||
|
vdata = CONFIG.visitor_data.as(String)
|
||||||
|
end
|
||||||
|
|
||||||
# Use the default client config if nil is passed
|
# Use the default client config if nil is passed
|
||||||
client_config ||= DEFAULT_CLIENT_CONFIG
|
client_config ||= DEFAULT_CLIENT_CONFIG
|
||||||
|
|
||||||
|
@ -320,8 +334,8 @@ module YoutubeAPI
|
||||||
client_context["client"]["platform"] = platform
|
client_context["client"]["platform"] = platform
|
||||||
end
|
end
|
||||||
|
|
||||||
if ReloadTokens.vdata.is_a?(String)
|
if vdata.is_a?(String)
|
||||||
client_context["client"]["visitorData"] = ReloadTokens.vdata.as(String)
|
client_context["client"]["visitorData"] = vdata
|
||||||
end
|
end
|
||||||
|
|
||||||
return client_context
|
return client_context
|
||||||
|
@ -469,6 +483,17 @@ module YoutubeAPI
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# determine po_token and visitor_data
|
||||||
|
if CONFIG.tokenmon_enabled
|
||||||
|
# get the pot/vdata for usage later
|
||||||
|
pot = ReloadTokens.pot.as(String)
|
||||||
|
vdata = ReloadTokens.vdata.as(String)
|
||||||
|
else
|
||||||
|
# Use the configured pot
|
||||||
|
pot = CONFIG.po_token.as(String)
|
||||||
|
vdata = CONFIG.visitor_data.as(String)
|
||||||
|
end
|
||||||
|
|
||||||
# JSON Request data, required by the API
|
# JSON Request data, required by the API
|
||||||
data = {
|
data = {
|
||||||
"contentCheckOk" => true,
|
"contentCheckOk" => true,
|
||||||
|
@ -482,7 +507,7 @@ module YoutubeAPI
|
||||||
"contentPlaybackContext" => playback_ctx,
|
"contentPlaybackContext" => playback_ctx,
|
||||||
},
|
},
|
||||||
"serviceIntegrityDimensions" => {
|
"serviceIntegrityDimensions" => {
|
||||||
"poToken" => ReloadTokens.pot.as(String),
|
"poToken" => pot,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -616,8 +641,19 @@ module YoutubeAPI
|
||||||
headers["User-Agent"] = user_agent
|
headers["User-Agent"] = user_agent
|
||||||
end
|
end
|
||||||
|
|
||||||
if ReloadTokens.vdata.is_a?(String)
|
# determine po_token and visitor_data
|
||||||
headers["X-Goog-Visitor-Id"] = ReloadTokens.vdata.as(String)
|
if CONFIG.tokenmon_enabled
|
||||||
|
# get the pot/vdata for usage later
|
||||||
|
pot = ReloadTokens.pot.as(String)
|
||||||
|
vdata = ReloadTokens.vdata.as(String)
|
||||||
|
else
|
||||||
|
# Use the configured pot
|
||||||
|
pot = CONFIG.po_token.as(String)
|
||||||
|
vdata = CONFIG.visitor_data.as(String)
|
||||||
|
end
|
||||||
|
|
||||||
|
if vdata.is_a?(String)
|
||||||
|
headers["X-Goog-Visitor-Id"] = vdata
|
||||||
end
|
end
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue