Skip to content

Commit d12dff9

Browse files
committed
Use a regex to fix badly aligned captions
1 parent 170e754 commit d12dff9

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/invidious/routes/api/v1/videos.cr

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,13 @@ module Invidious::Routes::API::V1::Videos
130130
end
131131
end
132132
else
133+
# Some captions have "align:[start/end]" and "position:[num]%"
134+
# attributes. Those are causing issues with VideoJS, which is unable
135+
# to properly align the captions on the video, so we remove them.
136+
#
137+
# See: https://github.com/iv-org/invidious/issues/2391
133138
webvtt = YT_POOL.client &.get("#{url}&format=vtt").body
139+
.gsub(/([0-9:.]+ --> [0-9:.]+).+/, "\\1")
134140
end
135141

136142
if title = env.params.query["title"]?

0 commit comments

Comments
 (0)