mirror of
https://git.sr.ht/~cadence/cloudtube
synced 2026-03-02 02:31:35 +00:00
Support t parameter using media fragments
This commit is contained in:
parent
36f33b9f7e
commit
bb4816c4b3
3 changed files with 56 additions and 4 deletions
|
|
@ -122,20 +122,23 @@ module.exports = [
|
|||
route: "/watch", methods: ["GET", "POST"], upload: true, code: async ({req, url, body}) => {
|
||||
const user = getUser(req)
|
||||
const settings = user.getSettingsOrDefaults()
|
||||
const id = url.searchParams.get("v")
|
||||
if (req.method === "GET") {
|
||||
const id = url.searchParams.get("v")
|
||||
const t = url.searchParams.get("t")
|
||||
let mediaFragment = converters.tToMediaFragment(t)
|
||||
if (!settings.local) {
|
||||
const instanceOrigin = settings.instance
|
||||
const outURL = `${instanceOrigin}/api/v1/videos/${id}`
|
||||
const videoPromise = request(outURL).then(res => res.json())
|
||||
return renderVideo(videoPromise, {user, id, instanceOrigin})
|
||||
return renderVideo(videoPromise, {user, id, instanceOrigin}, {mediaFragment})
|
||||
} else {
|
||||
return render(200, "pug/local-video.pug", {id})
|
||||
}
|
||||
} else { // req.method === "POST"
|
||||
const video = JSON.parse(new URLSearchParams(body.toString()).get("video"))
|
||||
const videoPromise = Promise.resolve(video)
|
||||
return renderVideo(videoPromise, {user})
|
||||
const instanceOrigin = "http://localhost:3000"
|
||||
return renderVideo(videoPromise, {user, id, instanceOrigin})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue