mirror of https://github.com/iv-org/invidious.git
Use Time::Span for timestamps in chapter struct
This commit is contained in:
parent
b0e0e19017
commit
2744ea2244
|
@ -1,6 +1,6 @@
|
|||
# Namespace for methods and objects relating to chapters
|
||||
module Invidious::Videos::Chapters
|
||||
record Chapter, start_ms : Int32, end_ms : Int32, title : String, thumbnails : Array(Hash(String, Int32 | String))
|
||||
record Chapter, start_ms : Time::Span, end_ms : Time::Span, title : String, thumbnails : Array(Hash(String, Int32 | String))
|
||||
|
||||
# Parse raw chapters data into an array of Chapter structs
|
||||
#
|
||||
|
@ -37,8 +37,8 @@ module Invidious::Videos::Chapters
|
|||
end
|
||||
|
||||
segments << Chapter.new(
|
||||
start_ms: start_ms,
|
||||
end_ms: end_ms,
|
||||
start_ms: start_ms.milliseconds,
|
||||
end_ms: end_ms.milliseconds,
|
||||
title: title,
|
||||
thumbnails: thumbnails,
|
||||
)
|
||||
|
@ -51,7 +51,7 @@ module Invidious::Videos::Chapters
|
|||
def self.chapters_to_vtt(chapters : Array(Chapter))
|
||||
vtt = WebVTT.build do |build|
|
||||
chapters.each do |chapter|
|
||||
build.cue(chapter.start_ms.milliseconds, chapter.end_ms.milliseconds, chapter.title)
|
||||
build.cue(chapter.start_ms, chapter.end_ms, chapter.title)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -63,8 +63,8 @@ module Invidious::Videos::Chapters
|
|||
chapters.each do |chapter|
|
||||
json.object do
|
||||
json.field "title", chapter.title
|
||||
json.field "startMs", chapter.start_ms
|
||||
json.field "endMs", chapter.end_ms
|
||||
json.field "startMs", chapter.start_ms.total_milliseconds
|
||||
json.field "endMs", chapter.end_ms.total_milliseconds
|
||||
|
||||
json.field "thumbnails" do
|
||||
json.array do
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
<div class="description-chapters-content-container">
|
||||
<% chapters.each do | chapter | %>
|
||||
<%- start_in_seconds = chapter.start_ms.milliseconds.total_seconds.to_i %>
|
||||
<%- start_in_seconds = chapter.start_ms.total_seconds.to_i %>
|
||||
<a href="/watch?v=<%-= video.id %>&t=<%=start_in_seconds %>">
|
||||
<div class="chapter" data-onclick="jump_to_time" data-jump-time="<%=start_in_seconds%>">
|
||||
<div class="thumbnail">
|
||||
|
|
Loading…
Reference in New Issue