mirror of
https://git.sr.ht/~cadence/cloudtube
synced 2024-11-24 08:27:30 +00:00
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 settings = user.getSettingsOrDefaults()
|
||||||
const id = url.searchParams.get("v")
|
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
|
// Check if playback is allowed
|
||||||
const videoTakedownInfo = db.prepare("SELECT id, org, url FROM TakedownVideos WHERE id = ?").get(id)
|
const videoTakedownInfo = db.prepare("SELECT id, org, url FROM TakedownVideos WHERE id = ?").get(id)
|
||||||
if (videoTakedownInfo) {
|
if (videoTakedownInfo) {
|
||||||
@ -128,7 +142,7 @@ module.exports = [
|
|||||||
|
|
||||||
// Work out how to fetch the video
|
// Work out how to fetch the video
|
||||||
if (req.method === "GET") {
|
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})
|
return render(200, "pug/local-video.pug", {req, settings, id})
|
||||||
}
|
}
|
||||||
var instanceOrigin = settings.instance
|
var instanceOrigin = settings.instance
|
||||||
|
@ -57,11 +57,12 @@ block content
|
|||||||
|
|
||||||
+select({
|
+select({
|
||||||
id: "local",
|
id: "local",
|
||||||
label: "Fetch videos from",
|
label: "Play videos on",
|
||||||
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>',
|
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: [
|
options: [
|
||||||
{value: "0", text: "Remote instance"},
|
{value: "0", text: "CloudTube"},
|
||||||
{value: "1", text: "Locally"}
|
{value: "2", text: "YouTube"},
|
||||||
|
{value: "1", text: "Local"},
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -18,8 +18,8 @@ let constants = {
|
|||||||
default: false
|
default: false
|
||||||
},
|
},
|
||||||
local: {
|
local: {
|
||||||
type: "boolean",
|
type: "integer",
|
||||||
default: false
|
default: 0
|
||||||
},
|
},
|
||||||
quality: {
|
quality: {
|
||||||
type: "integer",
|
type: "integer",
|
||||||
|
Loading…
Reference in New Issue
Block a user