fixup! Feat: User supplied po_token and visitor_data
All checks were successful
Invidious CI / build (push) Successful in 5m2s

This commit is contained in:
Fijxu 2024-10-11 16:50:21 -03:00
parent e78f7e5430
commit 62d64ca814
Signed by: Fijxu
GPG key ID: 32C1DDF333EDA6A4
4 changed files with 14 additions and 14 deletions

View file

@ -67,11 +67,11 @@ REDIS_DB = Redis::PooledClient.new(unixsocket: CONFIG.redis_socket || nil, url:
if REDIS_DB.ping
puts "Connected to redis"
end
ARCHIVE_URL = URI.parse("https://archive.org")
PUBSUB_URL = URI.parse("https://pubsubhubbub.appspot.com")
REDDIT_URL = URI.parse("https://www.reddit.com")
YT_URL = URI.parse("https://www.youtube.com")
HOST_URL = make_host_url(Kemal.config)
ARCHIVE_URL = URI.parse("https://archive.org")
PUBSUB_URL = URI.parse("https://pubsubhubbub.appspot.com")
REDDIT_URL = URI.parse("https://www.reddit.com")
YT_URL = URI.parse("https://www.youtube.com")
HOST_URL = make_host_url(Kemal.config)
EXT_VIDEOP_LIST = gen_videoplayback_proxy_list()
CHARS_SAFE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"

View file

@ -384,7 +384,7 @@ def parse_link_endpoint(endpoint : JSON::Any, text : String, video_id : String)
return text
end
# Generates a list of external videoplayback proxies for
# Generates a list of external videoplayback proxies for
# CSP
def gen_videoplayback_proxy_list
if !CONFIG.external_videoplayback_proxy.empty?

View file

@ -294,7 +294,7 @@ struct Video
predicate_bool upcoming, isUpcoming
end
def get_video(id, refresh = true, region = nil, force_refresh = false, po_token = "", visitor_data = nil)
def get_video(id, refresh = true, region = nil, force_refresh = false, po_token = "", visitor_data = "")
if (video = Invidious::Database::Videos.select(id)) && !region
# If record was last updated over 10 minutes ago, or video has since premiered,
# refresh (expire param in response lasts for 6 hours)

View file

@ -3,6 +3,8 @@
#
module YoutubeAPI
@@visitor_data : String = ""
extend self
# For Android versions, see https://en.wikipedia.org/wiki/Android_version_history
@ -198,8 +200,6 @@ module YoutubeAPI
# (this is passed as the `gl` parameter).
property region : String | Nil
@@visitor_data : String | Nil
# Initialization function
def initialize(
*,
@ -322,8 +322,8 @@ module YoutubeAPI
client_context["client"]["platform"] = platform
end
if !@@visitor_data.not_nil!.empty?
client_context["client"]["visitorData"] = @@visitor_data.not_nil!
if !@@visitor_data.empty?
client_context["client"]["visitorData"] = @@visitor_data
elsif CONFIG.visitor_data.is_a?(String)
client_context["client"]["visitorData"] = CONFIG.visitor_data.as(String)
end
@ -461,7 +461,7 @@ module YoutubeAPI
params : String,
client_config : ClientConfig | Nil = nil,
po_token : String,
visitor_data : String | Nil
visitor_data : String
)
if visitor_data
@@visitor_data = visitor_data
@ -625,8 +625,8 @@ module YoutubeAPI
headers["User-Agent"] = user_agent
end
if !@@visitor_data.not_nil!.empty?
headers["X-Goog-Visitor-Id"] = @@visitor_data.not_nil!
if !@@visitor_data.empty?
headers["X-Goog-Visitor-Id"] = @@visitor_data
elsif CONFIG.visitor_data.is_a?(String)
headers["X-Goog-Visitor-Id"] = CONFIG.visitor_data.as(String)
end