mirror of
https://github.com/iv-org/invidious.git
synced 2024-08-30 18:23:25 +00:00
Fix content-type for captions
This commit is contained in:
parent
1eaa377583
commit
8b50c8515f
@ -3065,7 +3065,7 @@ get "/api/v1/stats" do |env|
|
|||||||
statistics.to_json
|
statistics.to_json
|
||||||
end
|
end
|
||||||
|
|
||||||
# YouTube provides "storyboards", which are sprites containing of x * y
|
# YouTube provides "storyboards", which are sprites containing x * y
|
||||||
# preview thumbnails for individual scenes in a video.
|
# preview thumbnails for individual scenes in a video.
|
||||||
# See https://support.jwplayer.com/articles/how-to-add-preview-thumbnails
|
# See https://support.jwplayer.com/articles/how-to-add-preview-thumbnails
|
||||||
get "/api/v1/storyboards/:id" do |env|
|
get "/api/v1/storyboards/:id" do |env|
|
||||||
@ -3153,6 +3153,14 @@ get "/api/v1/captions/:id" do |env|
|
|||||||
id = env.params.url["id"]
|
id = env.params.url["id"]
|
||||||
region = env.params.query["region"]?
|
region = env.params.query["region"]?
|
||||||
|
|
||||||
|
# See https://github.com/ytdl-org/youtube-dl/blob/6ab30ff50bf6bd0585927cb73c7421bef184f87a/youtube_dl/extractor/youtube.py#L1354
|
||||||
|
# It is possible to use `/api/timedtext?type=list&v=#{id}` and
|
||||||
|
# `/api/timedtext?type=track&v=#{id}&lang=#{lang_code}` directly,
|
||||||
|
# but this does not provide links for auto-generated captions.
|
||||||
|
#
|
||||||
|
# In future this should be investigated as an alternative, since it does not require
|
||||||
|
# getting video info.
|
||||||
|
|
||||||
client = make_client(YT_URL)
|
client = make_client(YT_URL)
|
||||||
begin
|
begin
|
||||||
video = get_video(id, PG_DB, proxies, region: region)
|
video = get_video(id, PG_DB, proxies, region: region)
|
||||||
@ -3189,7 +3197,7 @@ get "/api/v1/captions/:id" do |env|
|
|||||||
next response
|
next response
|
||||||
end
|
end
|
||||||
|
|
||||||
env.response.content_type = "text/vtt"
|
env.response.content_type = "text/vtt; charset=UTF-8"
|
||||||
|
|
||||||
caption = captions.select { |caption| caption.name.simpleText == label }
|
caption = captions.select { |caption| caption.name.simpleText == label }
|
||||||
|
|
||||||
|
@ -825,17 +825,17 @@ struct Video
|
|||||||
end
|
end
|
||||||
|
|
||||||
struct Caption
|
struct Caption
|
||||||
JSON.mapping(
|
json_mapping({
|
||||||
name: CaptionName,
|
name: CaptionName,
|
||||||
baseUrl: String,
|
baseUrl: String,
|
||||||
languageCode: String
|
languageCode: String,
|
||||||
)
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
struct CaptionName
|
struct CaptionName
|
||||||
JSON.mapping(
|
json_mapping({
|
||||||
simpleText: String,
|
simpleText: String,
|
||||||
)
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
class VideoRedirect < Exception
|
class VideoRedirect < Exception
|
||||||
|
Loading…
Reference in New Issue
Block a user