mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2022-08-14.git
synced 2024-08-15 00:53:20 +00:00
Only modify cues for auto-generated captions
This commit is contained in:
parent
ab4df7e078
commit
5730280325
1 changed files with 35 additions and 26 deletions
|
@ -3203,7 +3203,12 @@ get "/api/v1/captions/:id" do |env|
|
|||
caption = caption[0]
|
||||
end
|
||||
|
||||
caption_xml = client.get(caption.baseUrl + "&tlang=#{tlang}").body
|
||||
url = caption.baseUrl + "&tlang=#{tlang}"
|
||||
|
||||
# Auto-generated captions often have cues that aren't aligned properly with the video,
|
||||
# as well as some other markup that makes it cumbersome, so we try to fix that here
|
||||
if caption.name.simpleText.includes? "auto-generated"
|
||||
caption_xml = client.get(url).body
|
||||
caption_xml = XML.parse(caption_xml)
|
||||
|
||||
webvtt = <<-END_VTT
|
||||
|
@ -3243,6 +3248,10 @@ get "/api/v1/captions/:id" do |env|
|
|||
|
||||
END_CUE
|
||||
end
|
||||
else
|
||||
url += "&format=vtt"
|
||||
webvtt = client.get(url).body
|
||||
end
|
||||
|
||||
if title = env.params.query["title"]?
|
||||
# https://blog.fastmail.com/2011/06/24/download-non-english-filenames/
|
||||
|
|
Loading…
Reference in a new issue