summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOmar Roth <omarroth@protonmail.com>2019-11-05 19:39:11 -0500
committerOmar Roth <omarroth@protonmail.com>2019-11-05 19:39:11 -0500
commit0e1d6aa85c40d071270092de0195a75f928e3506 (patch)
tree7f0b5a59d214a55c361c495ea90c5edfcc47e869
parentbcdb8cd770cfaf32c2b0a9b454d7eb04433204e2 (diff)
downloadinvidious-0e1d6aa85c40d071270092de0195a75f928e3506.tar.gz
invidious-0e1d6aa85c40d071270092de0195a75f928e3506.tar.bz2
invidious-0e1d6aa85c40d071270092de0195a75f928e3506.zip
Update error messages for video extractor
-rw-r--r--src/invidious/videos.cr17
1 files changed, 7 insertions, 10 deletions
diff --git a/src/invidious/videos.cr b/src/invidious/videos.cr
index 21233ff5..e9aee092 100644
--- a/src/invidious/videos.cr
+++ b/src/invidious/videos.cr
@@ -1137,8 +1137,11 @@ def extract_player_config(body, html)
error_message = html.xpath_node(%q(//h1[@id="unavailable-message"]))
if error_message
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
- params["reason"] = "Could not extract video info."
+ params["reason"] = "Video unavailable."
end
end
@@ -1192,19 +1195,13 @@ def fetch_video(id, region)
end
end
- if !info["player_response"]? || info["errorcode"]?.try &.== "2"
- raise "Video unavailable."
- end
-
- if info["reason"]? && !info["player_response"]["videoDetails"]?
+ if info["reason"]? && !info["player_response"]?
raise info["reason"]
end
player_json = JSON.parse(info["player_response"])
-
- reason = player_json["playabilityStatus"]?.try &.["reason"]?.try &.as_s
- if reason == "This video is not available."
- raise "This video is not available."
+ if reason = player_json["playabilityStatus"]?.try &.["reason"]?.try &.as_s
+ raise reason
end
title = player_json["videoDetails"]["title"].as_s