WebVTT::Builder: rename #line to #cue

This commit is contained in:
syeopite 2023-08-24 15:42:42 -07:00
parent 0cb7d0b441
commit d371eb50f2
No known key found for this signature in database
GPG key ID: A73C186DA3955A1A
5 changed files with 10 additions and 10 deletions

View file

@ -18,7 +18,7 @@ Spectator.describe "WebVTT::Builder" do
it "correctly builds a vtt file" do it "correctly builds a vtt file" do
result = WebVTT.build do |vtt| result = WebVTT.build do |vtt|
MockLines.each do |line| MockLines.each do |line|
vtt.line(line["start_time"], line["end_time"], line["text"]) vtt.cue(line["start_time"], line["end_time"], line["text"])
end end
end end
@ -43,7 +43,7 @@ Spectator.describe "WebVTT::Builder" do
result = WebVTT.build(setting_fields) do |vtt| result = WebVTT.build(setting_fields) do |vtt|
MockLines.each do |line| MockLines.each do |line|
vtt.line(line["start_time"], line["end_time"], line["text"]) vtt.cue(line["start_time"], line["end_time"], line["text"])
end end
end end

View file

@ -7,8 +7,8 @@ module WebVTT
def initialize(@io : IO) def initialize(@io : IO)
end end
# Writes an vtt line with the specified time stamp and contents # Writes an vtt cue with the specified time stamp and contents
def line(start_time : Time::Span, end_time : Time::Span, text : String) def cue(start_time : Time::Span, end_time : Time::Span, text : String)
timestamp(start_time, end_time) timestamp(start_time, end_time)
@io << text @io << text
@io << "\n\n" @io << "\n\n"
@ -48,8 +48,8 @@ module WebVTT
# #
# ``` # ```
# string = WebVTT.build do |io| # string = WebVTT.build do |io|
# vtt.line(Time::Span.new(seconds: 1), Time::Span.new(seconds: 2), "Line 1") # vtt.cue(Time::Span.new(seconds: 1), Time::Span.new(seconds: 2), "Line 1")
# vtt.line(Time::Span.new(seconds: 2), Time::Span.new(seconds: 3), "Line 2") # vtt.cue(Time::Span.new(seconds: 2), Time::Span.new(seconds: 3), "Line 2")
# end # end
# #
# string # => "WEBVTT\n\n00:00:01.000 --> 00:00:02.000\nLine 1\n\n00:00:02.000 --> 00:00:03.000\nLine 2\n\n" # string # => "WEBVTT\n\n00:00:01.000 --> 00:00:02.000\nLine 1\n\n00:00:02.000 --> 00:00:03.000\nLine 2\n\n"

View file

@ -131,7 +131,7 @@ module Invidious::Routes::API::V1::Videos
text = "<v #{md["name"]}>#{md["text"]}</v>" text = "<v #{md["name"]}>#{md["text"]}</v>"
end end
webvtt.line(start_time, end_time, text) webvtt.cue(start_time, end_time, text)
end end
end end
end end
@ -217,7 +217,7 @@ module Invidious::Routes::API::V1::Videos
storyboard[:storyboard_height].times do |j| storyboard[:storyboard_height].times do |j|
storyboard[:storyboard_width].times do |k| storyboard[:storyboard_width].times do |k|
current_cue_url = "#{url}#xywh=#{storyboard[:width] * k},#{storyboard[:height] * j},#{storyboard[:width] - 2},#{storyboard[:height]}" current_cue_url = "#{url}#xywh=#{storyboard[:width] * k},#{storyboard[:height] * j},#{storyboard[:width] - 2},#{storyboard[:height]}"
vtt.line(start_time, end_time, current_cue_url) vtt.cue(start_time, end_time, current_cue_url)
start_time += storyboard[:interval].milliseconds start_time += storyboard[:interval].milliseconds
end_time += storyboard[:interval].milliseconds end_time += storyboard[:interval].milliseconds

View file

@ -78,7 +78,7 @@ module Invidious::Videos
end end
end end
vtt.line(start_time, end_time, text) vtt.cue(start_time, end_time, text)
end end
end end

View file

@ -42,7 +42,7 @@ module Invidious::Videos
# Taken from Invidious::Videos::Captions::Metadata.timedtext_to_vtt() # Taken from Invidious::Videos::Captions::Metadata.timedtext_to_vtt()
vtt = WebVTT.build(settings_field) do |vtt| vtt = WebVTT.build(settings_field) do |vtt|
lines.each do |line| lines.each do |line|
vtt.line(line.start_ms, line.end_ms, line.line) vtt.cue(line.start_ms, line.end_ms, line.line)
end end
end end