Only modify cues for auto-generated captions

This commit is contained in:
Omar Roth 2019-05-18 20:27:19 -05:00
parent ab4df7e078
commit 5730280325
No known key found for this signature in database
GPG key ID: B8254FB7EC3D37F2

View file

@ -3203,7 +3203,12 @@ get "/api/v1/captions/:id" do |env|
caption = caption[0] caption = caption[0]
end 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) caption_xml = XML.parse(caption_xml)
webvtt = <<-END_VTT webvtt = <<-END_VTT
@ -3243,6 +3248,10 @@ get "/api/v1/captions/:id" do |env|
END_CUE END_CUE
end end
else
url += "&format=vtt"
webvtt = client.get(url).body
end
if title = env.params.query["title"]? if title = env.params.query["title"]?
# https://blog.fastmail.com/2011/06/24/download-non-english-filenames/ # https://blog.fastmail.com/2011/06/24/download-non-english-filenames/