mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2023-06-08.git
synced 2024-08-15 00:53:38 +00:00
Add fix for subtitles without duration
This commit is contained in:
parent
8fbc066df1
commit
4cc2cf46aa
1 changed files with 3 additions and 1 deletions
|
@ -485,7 +485,9 @@ get "/api/v1/captions/:id" do |env|
|
|||
|
||||
track_xml.xpath_nodes("//transcript/text").each do |node|
|
||||
start_time = node["start"].to_f.seconds
|
||||
end_time = start_time + node["dur"].to_f.seconds
|
||||
duration = node["dur"]?.try &.to_f.seconds
|
||||
duration ||= start_time
|
||||
end_time = start_time + duration
|
||||
|
||||
start_time = "#{start_time.hours.to_s.rjust(2, '0')}:#{start_time.minutes.to_s.rjust(2, '0')}:#{start_time.seconds.to_s.rjust(2, '0')}.#{start_time.milliseconds.to_s.rjust(3, '0')}"
|
||||
end_time = "#{end_time.hours.to_s.rjust(2, '0')}:#{end_time.minutes.to_s.rjust(2, '0')}:#{end_time.seconds.to_s.rjust(2, '0')}.#{end_time.milliseconds.to_s.rjust(3, '0')}"
|
||||
|
|
Loading…
Reference in a new issue