diff --git a/api/video.js b/api/video.js index b5ce8d5..1389c99 100644 --- a/api/video.js +++ b/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 diff --git a/pug/settings.pug b/pug/settings.pug index 16f5741..f504dba 100644 --- a/pug/settings.pug +++ b/pug/settings.pug @@ -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, read how to install NewLeaf.', + 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, read how to install NewLeaf.', options: [ - {value: "0", text: "Remote instance"}, - {value: "1", text: "Locally"} + {value: "0", text: "CloudTube"}, + {value: "2", text: "YouTube"}, + {value: "1", text: "Local"}, ] }) diff --git a/utils/constants.js b/utils/constants.js index 55e916c..fe06882 100644 --- a/utils/constants.js +++ b/utils/constants.js @@ -18,8 +18,8 @@ let constants = { default: false }, local: { - type: "boolean", - default: false + type: "integer", + default: 0 }, quality: { type: "integer",