Skip to content

Commit

Permalink
throw error if the videoID returned is different
Browse files Browse the repository at this point in the history
  • Loading branch information
unixfox committed Aug 23, 2022
1 parent 4c1a5f8 commit 389e491
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/invidious/exceptions.cr
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@ end
# Exception threw when an element is not found.
class NotFoundException < InfoException
end

class VideoNotAvailableException < Exception
end
4 changes: 4 additions & 0 deletions src/invidious/videos.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 389e491

Please sign in to comment.