diff options
| author | Samantaz Fox <coding@samantaz.fr> | 2021-11-28 02:38:29 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-11-28 02:38:29 +0100 |
| commit | 82f3eda82b9e97a94f98e6f325b428d985d9852d (patch) | |
| tree | a2674090889821abcce10545c86b58d66e5dd06e /src | |
| parent | 05f9613e14c6faaca4fb51c9c21d5ec5ae603d64 (diff) | |
| parent | 319587e2f11abe53c507d2363ca551d8321b203f (diff) | |
| download | invidious-82f3eda82b9e97a94f98e6f325b428d985d9852d.tar.gz invidious-82f3eda82b9e97a94f98e6f325b428d985d9852d.tar.bz2 invidious-82f3eda82b9e97a94f98e6f325b428d985d9852d.zip | |
Merge pull request #2656 from SamantazFox/fix-2549
extract_video_info: Make sure that the Android player response is valid
Diffstat (limited to 'src')
| -rw-r--r-- | src/invidious/videos.cr | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/invidious/videos.cr b/src/invidious/videos.cr index d3e5800c..4406284f 100644 --- a/src/invidious/videos.cr +++ b/src/invidious/videos.cr @@ -857,8 +857,16 @@ def extract_video_info(video_id : String, proxy_region : String? = nil, context_ else client_config.client_type = YoutubeAPI::ClientType::Android end - stream_data = YoutubeAPI.player(video_id: video_id, params: "", client_config: client_config) - params["streamingData"] = stream_data["streamingData"]? || JSON::Any.new("") + android_player = YoutubeAPI.player(video_id: video_id, params: "", client_config: client_config) + + # Sometime, the video is available from the web client, but not on Android, so check + # that here, and fallback to the streaming data from the web client if needed. + # See: https://github.com/iv-org/invidious/issues/2549 + if android_player["playabilityStatus"]["status"] == "OK" + params["streamingData"] = android_player["streamingData"]? || JSON::Any.new("") + else + params["streamingData"] = player_response["streamingData"]? || JSON::Any.new("") + end end {"captions", "microformat", "playabilityStatus", "storyboards", "videoDetails"}.each do |f| |
