summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamantaz Fox <coding@samantaz.fr>2024-08-16 11:28:35 +0200
committerSamantaz Fox <coding@samantaz.fr>2024-08-16 11:36:01 +0200
commit5b05f3bd147c6cf9421587565dea2b11640f1206 (patch)
tree4fd1fdd0369c2ae5efe86882dd7d43dd3954bbcc
parenta335bc0814d3253852ed5b5cf58b75d9f7b6cd70 (diff)
downloadinvidious-5b05f3bd147c6cf9421587565dea2b11640f1206.tar.gz
invidious-5b05f3bd147c6cf9421587565dea2b11640f1206.tar.bz2
invidious-5b05f3bd147c6cf9421587565dea2b11640f1206.zip
Storyboards: Workarounds for videojs-vtt-thumbnails
The workarounds are as follow: * Unescape HTML entities * Always use 0:00:00.000 for cue start/end
-rw-r--r--src/invidious/routes/api/v1/videos.cr18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/invidious/routes/api/v1/videos.cr b/src/invidious/routes/api/v1/videos.cr
index fb083934..ab03df01 100644
--- a/src/invidious/routes/api/v1/videos.cr
+++ b/src/invidious/routes/api/v1/videos.cr
@@ -1,3 +1,5 @@
+require "html"
+
module Invidious::Routes::API::V1::Videos
def self.videos(env)
locale = env.get("preferences").as(Preferences).locale
@@ -216,12 +218,14 @@ module Invidious::Routes::API::V1::Videos
template_path = sb.proxied_url.path
# Initialize cue timing variables
+ # NOTE: videojs-vtt-thumbnails gets lost when the start and end times are not 0:00:000.000
+ # TODO: Use proper end time when videojs-vtt-thumbnails is fixed
time_delta = sb.interval.milliseconds
start_time = 0.milliseconds
- end_time = time_delta - 1.milliseconds
+ end_time = 0.milliseconds # time_delta - 1.milliseconds
# Build a VTT file for VideoJS-vtt plugin
- return WebVTT.build do |vtt|
+ vtt_file = WebVTT.build do |vtt|
sb.images_count.times do |i|
# Replace the variable component part of the path
work_url.path = template_path.sub("$M", i)
@@ -233,12 +237,18 @@ module Invidious::Routes::API::V1::Videos
vtt.cue(start_time, end_time, work_url.to_s)
- start_time += time_delta
- end_time += time_delta
+ # TODO: uncomment these when videojs-vtt-thumbnails is fixed
+ # start_time += time_delta
+ # end_time += time_delta
end
end
end
end
+
+ # videojs-vtt-thumbnails is not compliant to the VTT specification, it
+ # doesn't unescape the HTML entities, so we have to do it here:
+ # TODO: remove this when we migrate to VideoJS 8
+ return HTML.unescape(vtt_file)
end
def self.annotations(env)