Add live now indicator to playlists

This commit is contained in:
Omar Roth 2019-03-24 09:10:14 -05:00
parent 847ee61bf4
commit a3b767bb13

View File

@ -8,6 +8,7 @@ class PlaylistVideo
published: Time, published: Time,
playlists: Array(String), playlists: Array(String),
index: Int32, index: Int32,
live_now: Bool,
}) })
end end
@ -101,8 +102,10 @@ def extract_playlist(plid, nodeset, index)
anchor = video.xpath_node(%q(.//td[@class="pl-video-time"]/div/div[1])) anchor = video.xpath_node(%q(.//td[@class="pl-video-time"]/div/div[1]))
if anchor && !anchor.content.empty? if anchor && !anchor.content.empty?
length_seconds = decode_length_seconds(anchor.content) length_seconds = decode_length_seconds(anchor.content)
live_now = false
else else
length_seconds = 0 length_seconds = 0
live_now = true
end end
videos << PlaylistVideo.new( videos << PlaylistVideo.new(
@ -114,6 +117,7 @@ def extract_playlist(plid, nodeset, index)
published: Time.now, published: Time.now,
playlists: [plid], playlists: [plid],
index: index + offset, index: index + offset,
live_now: live_now
) )
end end