diff --git a/src/invidious.cr b/src/invidious.cr index 6f69d045..a823b69d 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -279,6 +279,12 @@ get "/watch" do |env| rating = video.info["avg_rating"].to_f64 engagement = ((video.dislikes.to_f + video.likes.to_f)/video.views * 100) + playability_status = video.player_response["playabilityStatus"]? + if playability_status && playability_status["status"] == "LIVE_STREAM_OFFLINE" + reason = playability_status["reason"]?.try &.as_s + end + reason ||= "" + templated "watch" end diff --git a/src/invidious/videos.cr b/src/invidious/videos.cr index 74a1b2c4..ee9be2c1 100644 --- a/src/invidious/videos.cr +++ b/src/invidious/videos.cr @@ -228,6 +228,8 @@ VIDEO_FORMATS = { } class Video + property player_json : JSON::Any? + module HTTPParamConverter def self.from_rs(rs) HTTP::Params.parse(rs.read(String)) @@ -287,9 +289,15 @@ class Video return audio_streams end - def captions - player_response = JSON.parse(self.info["player_response"]) + def player_response + if !@player_json + @player_json = JSON.parse(@info["player_response"]) + end + return @player_json.not_nil! + end + + def captions captions = [] of Caption if player_response["captions"]? caption_list = player_response["captions"]["playerCaptionsTracklistRenderer"]["captionTracks"]?.try &.as_a diff --git a/src/invidious/views/watch.ecr b/src/invidious/views/watch.ecr index ca5e9372..4b795b45 100644 --- a/src/invidious/views/watch.ecr +++ b/src/invidious/views/watch.ecr @@ -196,6 +196,9 @@ get_youtube_comments(); <% end %> +<% if !reason.empty? %> +