1
0
Fork 0
mirror of https://git.sr.ht/~cadence/cloudtube synced 2026-03-12 15:31:37 +00:00

Add setting to play on YouTube

This commit is contained in:
Cadence Ember 2024-07-25 20:21:15 +12:00
parent efcef9b540
commit 4823f8ec73
3 changed files with 22 additions and 7 deletions

View file

@ -108,6 +108,20 @@ module.exports = [
const settings = user.getSettingsOrDefaults()
const id = url.searchParams.get("v")
// Check if should watch on YouTube
if (settings.local === 2) {
const dest = `https://www.youtube.com${url.pathname}${url.search}#cloudtube`
user.addWatchedVideoMaybe(id)
return {
statusCode: 302,
contentType: "text/plain",
headers: {
"Location": dest
},
content: `Redirecting to ${dest}...`
}
}
// Check if playback is allowed
const videoTakedownInfo = db.prepare("SELECT id, org, url FROM TakedownVideos WHERE id = ?").get(id)
if (videoTakedownInfo) {
@ -128,7 +142,7 @@ module.exports = [
// Work out how to fetch the video
if (req.method === "GET") {
if (settings.local) { // skip to the local fetching page, which will then POST video data in a moment
if (settings.local === 1) { // skip to the local fetching page, which will then POST video data in a moment
return render(200, "pug/local-video.pug", {req, settings, id})
}
var instanceOrigin = settings.instance