mirror of
https://codeberg.org/ashley/poke
synced 2025-06-03 04:59:41 +00:00
Update src/libpoketube/init/pages-channel-and-download.js
This commit is contained in:
parent
4acf840d80
commit
4bf687b4a3
@ -58,21 +58,21 @@ const ChannelTabs = {
|
|||||||
|
|
||||||
module.exports = function (app, config, renderTemplate) {
|
module.exports = function (app, config, renderTemplate) {
|
||||||
app.get("/download", async (req, res) => {
|
app.get("/download", async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const v = req.query.v;
|
const v = req.query.v;
|
||||||
|
|
||||||
const thumbnailUrl = `https://i.ytimg.com/vi/${v}/maxresdefault.jpg`;
|
const thumbnailUrl = `https://i.ytimg.com/vi/${v}/maxresdefault.jpg`;
|
||||||
const colors = await modules.getColors(thumbnailUrl);
|
const colors = await modules.getColors(thumbnailUrl);
|
||||||
const color = colors[0].hex();
|
const color = colors[0].hex();
|
||||||
|
|
||||||
renderTemplate(res, req, "download.ejs", {
|
renderTemplate(res, req, "download.ejs", {
|
||||||
v,
|
v,
|
||||||
color,
|
color,
|
||||||
isMobile: req.useragent.isMobile,
|
isMobile: req.useragent.isMobile,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
res.redirect("/");
|
res.redirect("/");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get("/old/watch", async function (req, res) {
|
app.get("/old/watch", async function (req, res) {
|
||||||
@ -94,15 +94,15 @@ module.exports = function (app, config, renderTemplate) {
|
|||||||
|
|
||||||
var media_proxy = config.media_proxy;
|
var media_proxy = config.media_proxy;
|
||||||
|
|
||||||
if (req.useragent.source.includes("Pardus")) {
|
if (config.useragent.source.includes("Pardus")) {
|
||||||
var media_proxy = "https://media-proxy.ashley0143.xyz";
|
var media_proxy = "https://media-proxy.ashley0143.xyz";
|
||||||
}
|
}
|
||||||
var uaos = req.useragent.os;
|
var uaos = config.useragent.os;
|
||||||
var IsOldWindows;
|
let IsOldWindows;
|
||||||
|
|
||||||
if (uaos == "Windows 7" && req.useragent.browser == "Firefox") {
|
if (uaos == "Windows 7" && config.useragent.browser == "Firefox") {
|
||||||
IsOldWindows = true;
|
IsOldWindows = true;
|
||||||
} else if (uaos == "Windows 8" && req.useragent.browser == "Firefox") {
|
} else if (uaos == "Windows 8" && config.useragent.browser == "Firefox") {
|
||||||
IsOldWindows = true;
|
IsOldWindows = true;
|
||||||
} else {
|
} else {
|
||||||
IsOldWindows = false;
|
IsOldWindows = false;
|
||||||
@ -135,7 +135,6 @@ module.exports = function (app, config, renderTemplate) {
|
|||||||
res.redirect("https://lite.duckduckgo.com/lite/?q=" + query);
|
res.redirect("https://lite.duckduckgo.com/lite/?q=" + query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (query && query.startsWith("Hey ChatGPT,") && query.length > 2) {
|
if (query && query.startsWith("Hey ChatGPT,") && query.length > 2) {
|
||||||
res.redirect("https://chatgpt.com/?q=" + query + "- sent using pokeAI features");
|
res.redirect("https://chatgpt.com/?q=" + query + "- sent using pokeAI features");
|
||||||
}
|
}
|
||||||
@ -153,17 +152,16 @@ module.exports = function (app, config, renderTemplate) {
|
|||||||
try {
|
try {
|
||||||
const headers = {};
|
const headers = {};
|
||||||
|
|
||||||
let searchUrl;
|
let searchUrl;
|
||||||
if (req.query.from === 'hashtag') {
|
if (req.query.from === 'hashtag') {
|
||||||
searchUrl = `${config.invapi}/hashtag/${query}?hl=en-gb`;
|
searchUrl = `${config.invapi}/hashtag/${query}?hl=en-gb`;
|
||||||
} else {
|
} else {
|
||||||
searchUrl = `${config.invapi}/search?q=${encodeURIComponent(query)}&page=${encodeURIComponent(continuation)}&date=${date}&type=${type}&duration=${duration}&sort=${sort}&hl=en+gb`;
|
searchUrl = `${config.invapi}/search?q=${encodeURIComponent(query)}&page=${encodeURIComponent(continuation)}&date=${date}&type=${type}&duration=${duration}&sort=${sort}&hl=en+gb`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const xmlData = await fetch(searchUrl)
|
|
||||||
.then((res) => res.text())
|
|
||||||
.then((txt) => getJson(txt));
|
|
||||||
|
|
||||||
|
const xmlData = await fetch(searchUrl)
|
||||||
|
.then((res) => res.text())
|
||||||
|
.then((txt) => getJson(txt));
|
||||||
|
|
||||||
renderTemplate(res, req, "search.ejs", {
|
renderTemplate(res, req, "search.ejs", {
|
||||||
invresults: xmlData,
|
invresults: xmlData,
|
||||||
@ -199,7 +197,7 @@ const xmlData = await fetch(searchUrl)
|
|||||||
try {
|
try {
|
||||||
var media_proxy = config.media_proxy;
|
var media_proxy = config.media_proxy;
|
||||||
|
|
||||||
if (req.useragent.source.includes("Pardus")) {
|
if (config.useragent.source.includes("Pardus")) {
|
||||||
var media_proxy = "https://media-proxy.ashley0143.xyz";
|
var media_proxy = "https://media-proxy.ashley0143.xyz";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -247,25 +245,25 @@ const xmlData = await fetch(searchUrl)
|
|||||||
};
|
};
|
||||||
|
|
||||||
const apiUrl = config.invapi + "/channels/";
|
const apiUrl = config.invapi + "/channels/";
|
||||||
const channelUrl = `${apiUrl}${ID}/${atob(
|
const channelUrl = `${apiUrl}${ID}/${atob(
|
||||||
ChannelTabs.videos
|
ChannelTabs.videos
|
||||||
)}?sort_by=${sort_by}${continuation}`;
|
)}?sort_by=${sort_by}${continuation}`;
|
||||||
|
|
||||||
const shortsUrl = `${apiUrl}${ID}/${atob(
|
const shortsUrl = `${apiUrl}${ID}/${atob(
|
||||||
ChannelTabs.shorts
|
ChannelTabs.shorts
|
||||||
)}?sort_by=${sort_by}${continuation}`;
|
)}?sort_by=${sort_by}${continuation}`;
|
||||||
|
|
||||||
const streamUrl = `${apiUrl}${ID}/${atob(
|
const streamUrl = `${apiUrl}${ID}/${atob(
|
||||||
ChannelTabs.streams
|
ChannelTabs.streams
|
||||||
)}?sort_by=${sort_by}${continuation}`;
|
)}?sort_by=${sort_by}${continuation}`;
|
||||||
|
|
||||||
const communityUrl = `${apiUrl}${ID}/${atob(
|
const communityUrl = `${apiUrl}${ID}/${atob(
|
||||||
ChannelTabs.community
|
ChannelTabs.community
|
||||||
)}?hl=en-US`;
|
)}?hl=en-US`;
|
||||||
|
|
||||||
const PlaylistUrl = `${apiUrl}${ID}/${atob(
|
const PlaylistUrl = `${apiUrl}${ID}/${atob(
|
||||||
ChannelTabs.playlist
|
ChannelTabs.playlist
|
||||||
)}?hl=en-US`;
|
)}?hl=en-US`;
|
||||||
|
|
||||||
const channelINVUrl = `${apiUrl}${ID}/`;
|
const channelINVUrl = `${apiUrl}${ID}/`;
|
||||||
|
|
||||||
@ -280,22 +278,18 @@ const PlaylistUrl = `${apiUrl}${ID}/${atob(
|
|||||||
getChannelData(channelINVUrl),
|
getChannelData(channelINVUrl),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
var bannedchannels = ["UC1okSIA8UEY8OqvtjGHFvzA", "UClsVg5LkK2COQRo1mVS4taA", "UCIr4vkCsn0tdTW2xZ1jRG1g"];
|
||||||
var bannedchannels = ["UC1okSIA8UEY8OqvtjGHFvzA", "UClsVg5LkK2COQRo1mVS4taA", "UCIr4vkCsn0tdTW2xZ1jRG1g"];
|
var bypassQuery = "cG9rZXR1YmVjaGFubmVsYnlwYXNzbG9scGVvcGxldGhpbmt0aGlzaXNjZW5zb3JzaGlwLTQ1OTBh";
|
||||||
var bypassQuery = "cG9rZXR1YmVjaGFubmVsYnlwYXNzbG9scGVvcGxldGhpbmt0aGlzaXNjZW5zb3JzaGlwLTQ1OTBh";
|
|
||||||
|
|
||||||
var bypassExists = req.query.bypass === bypassQuery;
|
|
||||||
var tabExists = 'tab' in req.query;
|
|
||||||
var continuationExists = 'continuation' in req.query;
|
|
||||||
|
|
||||||
|
|
||||||
if (bannedchannels.some(channel => channel === ID) && !bypassExists && !tabExists && !continuationExists) {
|
|
||||||
var cinv = {
|
|
||||||
error:`this channel may include disinformation. If you still wanna view content <a href="/channel?id=${ID}&bypass=${bypassQuery}">click here</a> to bypass this restriction.`
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
var bypassExists = req.query.bypass === bypassQuery;
|
||||||
|
var tabExists = 'tab' in req.query;
|
||||||
|
var continuationExists = 'continuation' in req.query;
|
||||||
|
|
||||||
|
if (bannedchannels.some(channel => channel === ID) && !bypassExists && !tabExists && !continuationExists) {
|
||||||
|
var cinv = {
|
||||||
|
error: `this channel may include disinformation. If you still wanna view content <a href="/channel?id=${ID}&bypass=${bypassQuery}">click here</a> to bypass this restriction.`,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
function getThumbnailUrl(video) {
|
function getThumbnailUrl(video) {
|
||||||
const maxresDefaultThumbnail = video.videoThumbnails.find(
|
const maxresDefaultThumbnail = video.videoThumbnails.find(
|
||||||
@ -333,12 +327,10 @@ if (bannedchannels.some(channel => channel === ID) && !bypassExists && !tabExist
|
|||||||
);
|
);
|
||||||
const dnoreplace = about?.Description.toString();
|
const dnoreplace = about?.Description.toString();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
let ChannelFirstVideoObject = {
|
let ChannelFirstVideoObject = {
|
||||||
subCountText: "0",
|
subCountText: "0",
|
||||||
authorVerified: false,
|
authorVerified: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
renderTemplate(res, req, "channel.ejs", {
|
renderTemplate(res, req, "channel.ejs", {
|
||||||
ID,
|
ID,
|
||||||
@ -348,29 +340,17 @@ if (bannedchannels.some(channel => channel === ID) && !bypassExists && !tabExist
|
|||||||
j: boutJson,
|
j: boutJson,
|
||||||
sort: sort_by,
|
sort: sort_by,
|
||||||
stream,
|
stream,
|
||||||
tj,
|
description,
|
||||||
c,
|
subscribers,
|
||||||
|
banner: c.banner,
|
||||||
|
logo: c.logo,
|
||||||
|
ctv: c.ctv,
|
||||||
cinv,
|
cinv,
|
||||||
convert,
|
|
||||||
turntomins,
|
|
||||||
pronoun,
|
|
||||||
media_proxy_url: media_proxy,
|
|
||||||
dnoreplace,
|
dnoreplace,
|
||||||
getThumbnailUrl,
|
media_proxy_url: media_proxy,
|
||||||
continuation,
|
|
||||||
wiki: "",
|
|
||||||
getFirstLine,
|
|
||||||
isMobile: req.useragent.isMobile,
|
|
||||||
about,
|
|
||||||
playlist,
|
|
||||||
subs:
|
|
||||||
typeof subscribers === "string"
|
|
||||||
? subscribers.replace("subscribers", "")
|
|
||||||
: "None",
|
|
||||||
desc: dnoreplace === "[object Object]" ? "" : description,
|
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Failed to render channel page:", error);
|
console.log(error);
|
||||||
res.redirect("/");
|
res.redirect("/");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user