From d12dff9dcfd2d85405375f6ab8282acd19b90035 Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Mon, 7 Feb 2022 22:18:24 +0100 Subject: [PATCH] Use a regex to fix badly aligned captions --- src/invidious/routes/api/v1/videos.cr | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/invidious/routes/api/v1/videos.cr b/src/invidious/routes/api/v1/videos.cr index 86eb26ee..2b23d2ad 100644 --- a/src/invidious/routes/api/v1/videos.cr +++ b/src/invidious/routes/api/v1/videos.cr @@ -130,7 +130,13 @@ module Invidious::Routes::API::V1::Videos end end else + # Some captions have "align:[start/end]" and "position:[num]%" + # attributes. Those are causing issues with VideoJS, which is unable + # to properly align the captions on the video, so we remove them. + # + # See: https://github.com/iv-org/invidious/issues/2391 webvtt = YT_POOL.client &.get("#{url}&format=vtt").body + .gsub(/([0-9:.]+ --> [0-9:.]+).+/, "\\1") end if title = env.params.query["title"]?