summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSamantaz Fox <coding@samantaz.fr>2022-02-10 18:38:59 +0100
committerGitHub <noreply@github.com>2022-02-10 18:38:59 +0100
commitda10cdd5ab43e204115c696c43068020fcd3f220 (patch)
tree0e3e7fa4f4b9cfddeef6d7fe75332de8bdc3668a /src
parent83de3a51ea822b99341368f3e8002c0f5adb99c9 (diff)
parentd12dff9dcfd2d85405375f6ab8282acd19b90035 (diff)
downloadinvidious-da10cdd5ab43e204115c696c43068020fcd3f220.tar.gz
invidious-da10cdd5ab43e204115c696c43068020fcd3f220.tar.bz2
invidious-da10cdd5ab43e204115c696c43068020fcd3f220.zip
Merge pull request #2872 from SamantazFox/misaligned-captions
Use a regex to fix badly aligned captions
Diffstat (limited to 'src')
-rw-r--r--src/invidious/routes/api/v1/videos.cr6
1 files changed, 6 insertions, 0 deletions
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"]?