diff options
author | Émilien Devos <contact@emiliendevos.be> | 2022-08-25 08:25:26 +0000 |
---|---|---|
committer | Émilien Devos <contact@emiliendevos.be> | 2022-08-25 08:32:40 +0000 |
commit | bb7f7bb4d10950a3daad69d3ab7f18b44f6cd1ca (patch) | |
tree | b029ad6e850e1f98bb41e2b4c0d0ff6caa801664 | |
parent | 389e49183c076362bb79ad377b227257488e2bce (diff) |
add check video id for android client toothrow-error-wrong-video
-rw-r--r-- | src/invidious/videos.cr | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/invidious/videos.cr b/src/invidious/videos.cr index 5ed57727..c0ed6e85 100644 --- a/src/invidious/videos.cr +++ b/src/invidious/videos.cr | |||
@@ -912,7 +912,7 @@ def extract_video_info(video_id : String, proxy_region : String? = nil, context_ | |||
912 | elsif video_id != player_response.dig("videoDetails", "videoId") | 912 | elsif video_id != player_response.dig("videoDetails", "videoId") |
913 | # YouTube may return a different video player response than expected. | 913 | # YouTube may return a different video player response than expected. |
914 | # See: https://github.com/TeamNewPipe/NewPipe/issues/8713 | 914 | # See: https://github.com/TeamNewPipe/NewPipe/issues/8713 |
915 | raise VideoNotAvailableException.new("The video returned by YouTube isn't the requested one.") | 915 | raise VideoNotAvailableException.new("The video returned by YouTube isn't the requested one. (WEB client)") |
916 | else | 916 | else |
917 | reason = nil | 917 | reason = nil |
918 | end | 918 | end |
@@ -937,10 +937,14 @@ def extract_video_info(video_id : String, proxy_region : String? = nil, context_ | |||
937 | end | 937 | end |
938 | android_player = YoutubeAPI.player(video_id: video_id, params: "", client_config: client_config) | 938 | android_player = YoutubeAPI.player(video_id: video_id, params: "", client_config: client_config) |
939 | 939 | ||
940 | # Sometime, the video is available from the web client, but not on Android, so check | 940 | # Sometimes, the video is available from the web client, but not on Android, so check |
941 | # that here, and fallback to the streaming data from the web client if needed. | 941 | # that here, and fallback to the streaming data from the web client if needed. |
942 | # See: https://github.com/iv-org/invidious/issues/2549 | 942 | # See: https://github.com/iv-org/invidious/issues/2549 |
943 | if android_player["playabilityStatus"]["status"] == "OK" | 943 | if video_id != android_player.dig("videoDetails", "videoId") |
944 | # YouTube may return a different video player response than expected. | ||
945 | # See: https://github.com/TeamNewPipe/NewPipe/issues/8713 | ||
946 | raise VideoNotAvailableException.new("The video returned by YouTube isn't the requested one. (ANDROID client)") | ||
947 | elsif android_player["playabilityStatus"]["status"] == "OK" | ||
944 | params["streamingData"] = android_player["streamingData"]? || JSON::Any.new("") | 948 | params["streamingData"] = android_player["streamingData"]? || JSON::Any.new("") |
945 | else | 949 | else |
946 | params["streamingData"] = player_response["streamingData"]? || JSON::Any.new("") | 950 | params["streamingData"] = player_response["streamingData"]? || JSON::Any.new("") |