From 389e49183c076362bb79ad377b227257488e2bce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milien=20Devos?= Date: Tue, 23 Aug 2022 09:50:57 +0000 Subject: [PATCH] throw error if the videoID returned is different --- src/invidious/exceptions.cr | 3 +++ src/invidious/videos.cr | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/src/invidious/exceptions.cr b/src/invidious/exceptions.cr index 05be73a6..425c08da 100644 --- a/src/invidious/exceptions.cr +++ b/src/invidious/exceptions.cr @@ -30,3 +30,6 @@ end # Exception threw when an element is not found. class NotFoundException < InfoException end + +class VideoNotAvailableException < Exception +end diff --git a/src/invidious/videos.cr b/src/invidious/videos.cr index cb1d1acf..5ed57727 100644 --- a/src/invidious/videos.cr +++ b/src/invidious/videos.cr @@ -909,6 +909,10 @@ def extract_video_info(video_id : String, proxy_region : String? = nil, context_ "reason" => JSON::Any.new(reason), } end + elsif video_id != player_response.dig("videoDetails", "videoId") + # YouTube may return a different video player response than expected. + # See: https://github.com/TeamNewPipe/NewPipe/issues/8713 + raise VideoNotAvailableException.new("The video returned by YouTube isn't the requested one.") else reason = nil end