mirror of https://git.sr.ht/~cadence/cloudtube
Add setting to play on YouTube
This commit is contained in:
parent
efcef9b540
commit
4823f8ec73
16
api/video.js
16
api/video.js
|
@ -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
|
||||
|
|
|
@ -57,11 +57,12 @@ block content
|
|||
|
||||
+select({
|
||||
id: "local",
|
||||
label: "Fetch videos from",
|
||||
description: 'If remote, the instance above will be used.\nIf local, CloudTube will try to connect to an instance running on your own computer. This can bypass blocks, but requires you to run the instance software.\nIf you wish to use local mode, <a href="https://git.sr.ht/~cadence/tube-docs/tree/main/item/docs/newleaf/Installing%20NewLeaf.md">read how to install NewLeaf.</a>',
|
||||
label: "Play videos on",
|
||||
description: 'If CloudTube, the instance above will be used.\nIf YouTube, you will be redirected there.\nIf local, CloudTube will try to connect to a NewLeaf/Invidious instance running on your own computer. This can bypass blocks, but requires you to run the instance software.\nIf you wish to use local mode, <a href="https://git.sr.ht/~cadence/tube-docs/tree/main/item/docs/newleaf/Installing%20NewLeaf.md">read how to install NewLeaf.</a>',
|
||||
options: [
|
||||
{value: "0", text: "Remote instance"},
|
||||
{value: "1", text: "Locally"}
|
||||
{value: "0", text: "CloudTube"},
|
||||
{value: "2", text: "YouTube"},
|
||||
{value: "1", text: "Local"},
|
||||
]
|
||||
})
|
||||
|
||||
|
|
|
@ -18,8 +18,8 @@ let constants = {
|
|||
default: false
|
||||
},
|
||||
local: {
|
||||
type: "boolean",
|
||||
default: false
|
||||
type: "integer",
|
||||
default: 0
|
||||
},
|
||||
quality: {
|
||||
type: "integer",
|
||||
|
|
Loading…
Reference in New Issue