mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2022-08-14.git
synced 2024-08-15 00:53:20 +00:00
Update error messages for video extractor
This commit is contained in:
parent
bcdb8cd770
commit
0e1d6aa85c
1 changed files with 7 additions and 10 deletions
|
@ -1137,8 +1137,11 @@ def extract_player_config(body, html)
|
||||||
error_message = html.xpath_node(%q(//h1[@id="unavailable-message"]))
|
error_message = html.xpath_node(%q(//h1[@id="unavailable-message"]))
|
||||||
if error_message
|
if error_message
|
||||||
params["reason"] = error_message.content.strip
|
params["reason"] = error_message.content.strip
|
||||||
|
elsif body.includes?("To continue with your YouTube experience, please fill out the form below.") ||
|
||||||
|
body.includes?("https://www.google.com/sorry/index")
|
||||||
|
params["reason"] = "Could not extract video info. Instance is likely blocked."
|
||||||
else
|
else
|
||||||
params["reason"] = "Could not extract video info."
|
params["reason"] = "Video unavailable."
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1192,19 +1195,13 @@ def fetch_video(id, region)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if !info["player_response"]? || info["errorcode"]?.try &.== "2"
|
if info["reason"]? && !info["player_response"]?
|
||||||
raise "Video unavailable."
|
|
||||||
end
|
|
||||||
|
|
||||||
if info["reason"]? && !info["player_response"]["videoDetails"]?
|
|
||||||
raise info["reason"]
|
raise info["reason"]
|
||||||
end
|
end
|
||||||
|
|
||||||
player_json = JSON.parse(info["player_response"])
|
player_json = JSON.parse(info["player_response"])
|
||||||
|
if reason = player_json["playabilityStatus"]?.try &.["reason"]?.try &.as_s
|
||||||
reason = player_json["playabilityStatus"]?.try &.["reason"]?.try &.as_s
|
raise reason
|
||||||
if reason == "This video is not available."
|
|
||||||
raise "This video is not available."
|
|
||||||
end
|
end
|
||||||
|
|
||||||
title = player_json["videoDetails"]["title"].as_s
|
title = player_json["videoDetails"]["title"].as_s
|
||||||
|
|
Loading…
Reference in a new issue