summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSamantaz Fox <coding@samantaz.fr>2022-02-03 00:10:32 +0100
committerSamantaz Fox <coding@samantaz.fr>2022-02-03 01:37:30 +0100
commit99091e919c9af56c27ca8aebd790c3b64b564f78 (patch)
tree68b26e792865e9258131f5872b6b045e919b6a08 /src
parent6ddbccbc958d7925951ab6a1d035b3764f402759 (diff)
downloadinvidious-99091e919c9af56c27ca8aebd790c3b64b564f78.tar.gz
invidious-99091e919c9af56c27ca8aebd790c3b64b564f78.tar.bz2
invidious-99091e919c9af56c27ca8aebd790c3b64b564f78.zip
video parsing: raise if major root element is missing
Diffstat (limited to 'src')
-rw-r--r--src/invidious/videos.cr20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/invidious/videos.cr b/src/invidious/videos.cr
index d77d56d2..b0d8b4d1 100644
--- a/src/invidious/videos.cr
+++ b/src/invidious/videos.cr
@@ -885,16 +885,24 @@ def extract_video_info(video_id : String, proxy_region : String? = nil, context_
# Top level elements
- primary_results = player_response
- .dig?("contents", "twoColumnWatchNextResults", "results", "results", "contents")
+ main_results = player_response.dig?("contents", "twoColumnWatchNextResults")
+
+ raise BrokenTubeException.new("twoColumnWatchNextResults") if !main_results
+
+ primary_results = main_results.dig?("results", "results", "contents")
+
+ raise BrokenTubeException.new("results") if !primary_results
video_primary_renderer = primary_results
- .try &.as_a.find(&.["videoPrimaryInfoRenderer"]?)
- .try &.["videoPrimaryInfoRenderer"]
+ .as_a.find(&.["videoPrimaryInfoRenderer"]?)
+ .try &.["videoPrimaryInfoRenderer"]
video_secondary_renderer = primary_results
- .try &.as_a.find(&.["videoSecondaryInfoRenderer"]?)
- .try &.["videoSecondaryInfoRenderer"]
+ .as_a.find(&.["videoSecondaryInfoRenderer"]?)
+ .try &.["videoSecondaryInfoRenderer"]
+
+ raise BrokenTubeException.new("videoPrimaryInfoRenderer") if !video_primary_renderer
+ raise BrokenTubeException.new("videoSecondaryInfoRenderer") if !video_secondary_renderer
# Likes/dislikes