fixup! Feat: User supplied po_token and visitor_data
All checks were successful
Invidious CI / build (push) Successful in 5m2s
All checks were successful
Invidious CI / build (push) Successful in 5m2s
This commit is contained in:
parent
e78f7e5430
commit
62d64ca814
4 changed files with 14 additions and 14 deletions
|
@ -67,11 +67,11 @@ REDIS_DB = Redis::PooledClient.new(unixsocket: CONFIG.redis_socket || nil, url:
|
||||||
if REDIS_DB.ping
|
if REDIS_DB.ping
|
||||||
puts "Connected to redis"
|
puts "Connected to redis"
|
||||||
end
|
end
|
||||||
ARCHIVE_URL = URI.parse("https://archive.org")
|
ARCHIVE_URL = URI.parse("https://archive.org")
|
||||||
PUBSUB_URL = URI.parse("https://pubsubhubbub.appspot.com")
|
PUBSUB_URL = URI.parse("https://pubsubhubbub.appspot.com")
|
||||||
REDDIT_URL = URI.parse("https://www.reddit.com")
|
REDDIT_URL = URI.parse("https://www.reddit.com")
|
||||||
YT_URL = URI.parse("https://www.youtube.com")
|
YT_URL = URI.parse("https://www.youtube.com")
|
||||||
HOST_URL = make_host_url(Kemal.config)
|
HOST_URL = make_host_url(Kemal.config)
|
||||||
EXT_VIDEOP_LIST = gen_videoplayback_proxy_list()
|
EXT_VIDEOP_LIST = gen_videoplayback_proxy_list()
|
||||||
|
|
||||||
CHARS_SAFE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"
|
CHARS_SAFE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"
|
||||||
|
|
|
@ -384,7 +384,7 @@ def parse_link_endpoint(endpoint : JSON::Any, text : String, video_id : String)
|
||||||
return text
|
return text
|
||||||
end
|
end
|
||||||
|
|
||||||
# Generates a list of external videoplayback proxies for
|
# Generates a list of external videoplayback proxies for
|
||||||
# CSP
|
# CSP
|
||||||
def gen_videoplayback_proxy_list
|
def gen_videoplayback_proxy_list
|
||||||
if !CONFIG.external_videoplayback_proxy.empty?
|
if !CONFIG.external_videoplayback_proxy.empty?
|
||||||
|
|
|
@ -294,7 +294,7 @@ struct Video
|
||||||
predicate_bool upcoming, isUpcoming
|
predicate_bool upcoming, isUpcoming
|
||||||
end
|
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 (video = Invidious::Database::Videos.select(id)) && !region
|
||||||
# If record was last updated over 10 minutes ago, or video has since premiered,
|
# If record was last updated over 10 minutes ago, or video has since premiered,
|
||||||
# refresh (expire param in response lasts for 6 hours)
|
# refresh (expire param in response lasts for 6 hours)
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
module YoutubeAPI
|
module YoutubeAPI
|
||||||
|
@@visitor_data : String = ""
|
||||||
|
|
||||||
extend self
|
extend self
|
||||||
|
|
||||||
# For Android versions, see https://en.wikipedia.org/wiki/Android_version_history
|
# 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).
|
# (this is passed as the `gl` parameter).
|
||||||
property region : String | Nil
|
property region : String | Nil
|
||||||
|
|
||||||
@@visitor_data : String | Nil
|
|
||||||
|
|
||||||
# Initialization function
|
# Initialization function
|
||||||
def initialize(
|
def initialize(
|
||||||
*,
|
*,
|
||||||
|
@ -322,8 +322,8 @@ module YoutubeAPI
|
||||||
client_context["client"]["platform"] = platform
|
client_context["client"]["platform"] = platform
|
||||||
end
|
end
|
||||||
|
|
||||||
if !@@visitor_data.not_nil!.empty?
|
if !@@visitor_data.empty?
|
||||||
client_context["client"]["visitorData"] = @@visitor_data.not_nil!
|
client_context["client"]["visitorData"] = @@visitor_data
|
||||||
elsif CONFIG.visitor_data.is_a?(String)
|
elsif CONFIG.visitor_data.is_a?(String)
|
||||||
client_context["client"]["visitorData"] = CONFIG.visitor_data.as(String)
|
client_context["client"]["visitorData"] = CONFIG.visitor_data.as(String)
|
||||||
end
|
end
|
||||||
|
@ -461,7 +461,7 @@ module YoutubeAPI
|
||||||
params : String,
|
params : String,
|
||||||
client_config : ClientConfig | Nil = nil,
|
client_config : ClientConfig | Nil = nil,
|
||||||
po_token : String,
|
po_token : String,
|
||||||
visitor_data : String | Nil
|
visitor_data : String
|
||||||
)
|
)
|
||||||
if visitor_data
|
if visitor_data
|
||||||
@@visitor_data = visitor_data
|
@@visitor_data = visitor_data
|
||||||
|
@ -625,8 +625,8 @@ module YoutubeAPI
|
||||||
headers["User-Agent"] = user_agent
|
headers["User-Agent"] = user_agent
|
||||||
end
|
end
|
||||||
|
|
||||||
if !@@visitor_data.not_nil!.empty?
|
if !@@visitor_data.empty?
|
||||||
headers["X-Goog-Visitor-Id"] = @@visitor_data.not_nil!
|
headers["X-Goog-Visitor-Id"] = @@visitor_data
|
||||||
elsif CONFIG.visitor_data.is_a?(String)
|
elsif CONFIG.visitor_data.is_a?(String)
|
||||||
headers["X-Goog-Visitor-Id"] = CONFIG.visitor_data.as(String)
|
headers["X-Goog-Visitor-Id"] = CONFIG.visitor_data.as(String)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue