|
|
@ -93,6 +93,10 @@ module Invidious::Routes::API::V1::Videos
|
|
|
|
# as well as some other markup that makes it cumbersome, so we try to fix that here
|
|
|
|
# as well as some other markup that makes it cumbersome, so we try to fix that here
|
|
|
|
if caption.name.includes? "auto-generated"
|
|
|
|
if caption.name.includes? "auto-generated"
|
|
|
|
caption_xml = YT_POOL.client &.get(url).body
|
|
|
|
caption_xml = YT_POOL.client &.get(url).body
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if caption_xml.starts_with?("<?xml")
|
|
|
|
|
|
|
|
webvtt = caption.timedtext_to_vtt(caption_xml, tlang)
|
|
|
|
|
|
|
|
else
|
|
|
|
caption_xml = XML.parse(caption_xml)
|
|
|
|
caption_xml = XML.parse(caption_xml)
|
|
|
|
|
|
|
|
|
|
|
|
webvtt = String.build do |str|
|
|
|
|
webvtt = String.build do |str|
|
|
|
@ -134,15 +138,21 @@ module Invidious::Routes::API::V1::Videos
|
|
|
|
END_CUE
|
|
|
|
END_CUE
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
else
|
|
|
|
else
|
|
|
|
# Some captions have "align:[start/end]" and "position:[num]%"
|
|
|
|
# Some captions have "align:[start/end]" and "position:[num]%"
|
|
|
|
# attributes. Those are causing issues with VideoJS, which is unable
|
|
|
|
# attributes. Those are causing issues with VideoJS, which is unable
|
|
|
|
# to properly align the captions on the video, so we remove them.
|
|
|
|
# to properly align the captions on the video, so we remove them.
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# See: https://github.com/iv-org/invidious/issues/2391
|
|
|
|
# See: https://github.com/iv-org/invidious/issues/2391
|
|
|
|
|
|
|
|
webvtt = YT_POOL.client &.get("#{url}&format=vtt").body
|
|
|
|
|
|
|
|
if webvtt.starts_with?("<?xml")
|
|
|
|
|
|
|
|
webvtt = caption.timedtext_to_vtt(webvtt)
|
|
|
|
|
|
|
|
else
|
|
|
|
webvtt = YT_POOL.client &.get("#{url}&format=vtt").body
|
|
|
|
webvtt = YT_POOL.client &.get("#{url}&format=vtt").body
|
|
|
|
.gsub(/([0-9:.]{12} --> [0-9:.]{12}).+/, "\\1")
|
|
|
|
.gsub(/([0-9:.]{12} --> [0-9:.]{12}).+/, "\\1")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
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/
|
|
|
|