mirror of
https://git.sr.ht/~cadence/cloudtube
synced 2024-12-22 13:07:00 +00:00
Implement video captions
Proxy requests to NewLeaf/Invidious backend so captions are served on the same domain
This commit is contained in:
parent
dbbe950832
commit
500aa820bc
13
api/captions.js
Normal file
13
api/captions.js
Normal file
@ -0,0 +1,13 @@
|
||||
const {getUser} = require("../utils/getuser")
|
||||
const constants = require("../utils/constants.js")
|
||||
const {proxy} = require("pinski/plugins")
|
||||
|
||||
module.exports = [
|
||||
{
|
||||
route: `/api/v1/captions/(${constants.regex.video_id})`, methods: ["GET"], code: async ({req, fill, url}) => {
|
||||
const instanceOrigin = getUser(req).getSettingsOrDefaults().instance
|
||||
const fetchURL = new URL(`${url.pathname}${url.search}`, instanceOrigin)
|
||||
return proxy(fetchURL.toString())
|
||||
}
|
||||
}
|
||||
]
|
@ -20,6 +20,8 @@ block content
|
||||
if format
|
||||
video(controls preload="auto" width=format.second__width height=format.second__height data-itag=format.itag)#video.video
|
||||
source(src=format.url+mediaFragment type=format.type)
|
||||
each t in video.captions
|
||||
track(label=t.label kind="subtitles" srclang=t.languageCode src=t.url)
|
||||
else
|
||||
video(src="")#video.video
|
||||
.stream-notice The server provided no playback streams.
|
||||
|
Loading…
Reference in New Issue
Block a user