Skip to content

Invidious is an alternative front-end to YouTube

Add fix for videos that don't have captions

Omar Rothf4160f937ca3
diff --git a/src/invidious.cr b/src/invidious.cr
index 5a0853f4..c4791976 100644
--- a/src/invidious.cr
+++ b/src/invidious.cr
@@ -353,10 +353,9 @@ get "/watch" do |env|
player_response = JSON.parse(video.info["player_response"])
if player_response["captions"]?
- captions = player_response["captions"]["playerCaptionsTracklistRenderer"]["captionTracks"].as_a
- else
- captions = [] of JSON::Any
+ captions = player_response["captions"]["playerCaptionsTracklistRenderer"]["captionTracks"]?.try &.as_a
end
+ captions ||= [] of JSON::Any
rvs = [] of Hash(String, String)
if video.info.has_key?("rvs")