mirror of
https://git.nadeko.net/Fijxu/invidious.git
synced 2025-12-28 02:21:24 +00:00
Remove user supplied po_token and visitor_data
This commit is contained in:
@@ -50,17 +50,17 @@ def parse_related_video(related : JSON::Any) : Hash(String, JSON::Any)?
|
||||
}
|
||||
end
|
||||
|
||||
def extract_video_info(video_id : String, user_po_token, user_visitor_data)
|
||||
def extract_video_info(video_id : String)
|
||||
# Init client config for the API
|
||||
client_config = YoutubeAPI::ClientConfig.new
|
||||
|
||||
redis_po_token, redis_visitor_data = Tokens.get_tokens
|
||||
|
||||
po_token = (user_po_token if !user_po_token.empty?) || redis_po_token || CONFIG.po_token
|
||||
visitor_data = (user_visitor_data if !user_visitor_data.empty?) || redis_visitor_data || CONFIG.visitor_data
|
||||
po_token = redis_po_token || CONFIG.po_token
|
||||
visitor_data = redis_visitor_data || CONFIG.visitor_data
|
||||
|
||||
# Fetch data from the player endpoint
|
||||
player_response = YoutubeAPI.player(video_id: video_id, params: "2AMB", client_config: client_config, po_token: po_token, visitor_data: visitor_data)
|
||||
player_response = YoutubeAPI.player(video_id: video_id, params: "2AMB", client_config: client_config)
|
||||
|
||||
playability_status = player_response.dig?("playabilityStatus", "status").try &.as_s
|
||||
|
||||
@@ -115,7 +115,7 @@ def extract_video_info(video_id : String, user_po_token, user_visitor_data)
|
||||
# following issue for an explanation about decrypted URLs:
|
||||
# https://github.com/TeamNewPipe/NewPipeExtractor/issues/562
|
||||
client_config.client_type = YoutubeAPI::ClientType::AndroidTestSuite
|
||||
new_player_response = try_fetch_streaming_data(video_id, client_config, po_token, visitor_data)
|
||||
new_player_response = try_fetch_streaming_data(video_id, client_config)
|
||||
end
|
||||
|
||||
# Replace player response and reset reason
|
||||
@@ -136,7 +136,7 @@ def extract_video_info(video_id : String, user_po_token, user_visitor_data)
|
||||
if streaming_data = player_response["streamingData"]?
|
||||
%w[formats adaptiveFormats].each do |key|
|
||||
streaming_data.as_h[key]?.try &.as_a.each do |format|
|
||||
format.as_h["url"] = JSON::Any.new(convert_url(format, po_token))
|
||||
format.as_h["url"] = JSON::Any.new(convert_url(format))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -149,9 +149,9 @@ def extract_video_info(video_id : String, user_po_token, user_visitor_data)
|
||||
return params
|
||||
end
|
||||
|
||||
def try_fetch_streaming_data(id : String, client_config : YoutubeAPI::ClientConfig, po_token, visitor_data) : Hash(String, JSON::Any)?
|
||||
def try_fetch_streaming_data(id : String, client_config : YoutubeAPI::ClientConfig) : Hash(String, JSON::Any)?
|
||||
LOGGER.debug("try_fetch_streaming_data: [#{id}] Using #{client_config.client_type} client.")
|
||||
response = YoutubeAPI.player(video_id: id, params: "2AMB", client_config: client_config, po_token: po_token, visitor_data: visitor_data)
|
||||
response = YoutubeAPI.player(video_id: id, params: "2AMB", client_config: client_config)
|
||||
|
||||
playability_status = response["playabilityStatus"]["status"]
|
||||
LOGGER.debug("try_fetch_streaming_data: [#{id}] Got playabilityStatus == #{playability_status}.")
|
||||
@@ -460,7 +460,7 @@ def parse_video_info(video_id : String, player_response : Hash(String, JSON::Any
|
||||
return params
|
||||
end
|
||||
|
||||
private def convert_url(fmt, po_token)
|
||||
private def convert_url(fmt)
|
||||
if cfr = fmt["signatureCipher"]?.try { |json| HTTP::Params.parse(json.as_s) }
|
||||
sp = cfr["sp"]
|
||||
url = URI.parse(cfr["url"])
|
||||
@@ -478,9 +478,7 @@ private def convert_url(fmt, po_token)
|
||||
n = DECRYPT_FUNCTION.try &.decrypt_nsig(params["n"])
|
||||
params["n"] = n if n
|
||||
|
||||
if !po_token.nil?
|
||||
params["pot"] = po_token
|
||||
elsif token = CONFIG.po_token
|
||||
if token = CONFIG.po_token
|
||||
params["pot"] = token
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user