This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch

[PATCH] Captions support

Message ID
DKIM signature
Download raw message
Patch: +21 -0
 api/captions.js | 19 +++++++++++++++++++
 pug/video.pug   |  2 ++
 2 files changed, 21 insertions(+)
 create mode 100644 api/captions.js

diff --git a/api/captions.js b/api/captions.js
new file mode 100644
index 0000000..d23272c
--- /dev/null
+++ b/api/captions.js
@@ -0,0 +1,19 @@
const fetch = require("node-fetch")
const {getUser} = require("../utils/getuser")
const constants = require("../utils/constants")

module.exports = [
		route: `/api/v1/captions/(${constants.regex.video_id})`, methods: ["GET"], code: async ({req, fill, url}) => {
			const instanceOrigin = getUser(req).getSettingsOrDefaults().instance 
			const videoID = fill[0]
			const lang = url.searchParams.get("lang")
			return fetch(`${instanceOrigin}/api/v1/captions/${videoID}?lang=${lang}`).then(res => {
				return {
					statusCode: 200,
					stream: res.body
diff --git a/pug/video.pug b/pug/video.pug
index 2b09e10..eef398e 100644
--- a/pug/video.pug
+++ b/pug/video.pug
@@ -23,6 +23,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 c in video.captions
                track(label=c.label kind="subtitles" srclang=c.languageCode src=c.url)
            .stream-notice The server provided no playback streams.
Message ID
<20210314064924.21503-1-sir@hacktivista.com> (view parent)
DKIM signature
Download raw message
Thanks so much for this! Tomorrow I can properly review it, but taking a 
peek at the code now, there's a couple of things that stand out to me:

- kind should be `captions` since it is a transcription of audio, not a 
translation; see 
- should put the result of `getSettingsOrDefaults` in a variable to make 
it easier to extract other settings in the future
- should validate the `lang` query parameter somehow

I can deal with these notes on my own tomorrow, as well as doing my full 
review, but if you want make these changes yourself, you're free to 
submit an updated patch.
Reply to thread Export thread (mbox)