Add note for livestreams that haven't started

このコミットが含まれているのは:
Omar Roth 2018-08-18 11:47:16 -05:00
コミット 55f8fd0b58
3個のファイルの変更19行の追加2行の削除

ファイルの表示

@ -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

ファイルの表示

@ -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

ファイルの表示

@ -196,6 +196,9 @@ get_youtube_comments();
</a>
<% end %>
</h1>
<% if !reason.empty? %>
<h3><%= reason %></h3>
<% end %>
</div>
<div class="pure-g">