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
4bf687b4a3
commit
310ffb643c
@ -94,15 +94,15 @@ module.exports = function (app, config, renderTemplate) {
|
|||||||
|
|
||||||
var media_proxy = config.media_proxy;
|
var media_proxy = config.media_proxy;
|
||||||
|
|
||||||
if (config.useragent.source.includes("Pardus")) {
|
if (req.useragent.source.includes("Pardus")) {
|
||||||
var media_proxy = "https://media-proxy.ashley0143.xyz";
|
var media_proxy = "https://media-proxy.ashley0143.xyz";
|
||||||
}
|
}
|
||||||
var uaos = config.useragent.os;
|
var uaos = req.useragent.os;
|
||||||
let IsOldWindows;
|
var IsOldWindows;
|
||||||
|
|
||||||
if (uaos == "Windows 7" && config.useragent.browser == "Firefox") {
|
if (uaos == "Windows 7" && req.useragent.browser == "Firefox") {
|
||||||
IsOldWindows = true;
|
IsOldWindows = true;
|
||||||
} else if (uaos == "Windows 8" && config.useragent.browser == "Firefox") {
|
} else if (uaos == "Windows 8" && req.useragent.browser == "Firefox") {
|
||||||
IsOldWindows = true;
|
IsOldWindows = true;
|
||||||
} else {
|
} else {
|
||||||
IsOldWindows = false;
|
IsOldWindows = false;
|
||||||
@ -159,7 +159,11 @@ module.exports = function (app, config, renderTemplate) {
|
|||||||
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)
|
const xmlData = await fetch(searchUrl, {
|
||||||
|
headers: {
|
||||||
|
'User-Agent': config.useragent,
|
||||||
|
},
|
||||||
|
})
|
||||||
.then((res) => res.text())
|
.then((res) => res.text())
|
||||||
.then((txt) => getJson(txt));
|
.then((txt) => getJson(txt));
|
||||||
|
|
||||||
@ -197,7 +201,7 @@ module.exports = function (app, config, renderTemplate) {
|
|||||||
try {
|
try {
|
||||||
var media_proxy = config.media_proxy;
|
var media_proxy = config.media_proxy;
|
||||||
|
|
||||||
if (config.useragent.source.includes("Pardus")) {
|
if (req.useragent.source.includes("Pardus")) {
|
||||||
var media_proxy = "https://media-proxy.ashley0143.xyz";
|
var media_proxy = "https://media-proxy.ashley0143.xyz";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -216,7 +220,11 @@ module.exports = function (app, config, renderTemplate) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
// about
|
// about
|
||||||
const bout = await fetch(config.tubeApi + `channel?id=${ID}&tab=about`);
|
const bout = await fetch(config.tubeApi + `channel?id=${ID}&tab=about`, {
|
||||||
|
headers: {
|
||||||
|
'User-Agent': config.useragent,
|
||||||
|
},
|
||||||
|
});
|
||||||
const h = await bout.text();
|
const h = await bout.text();
|
||||||
var boutJson = JSON.parse(modules.toJson(h));
|
var boutJson = JSON.parse(modules.toJson(h));
|
||||||
} catch {
|
} catch {
|
||||||
@ -236,7 +244,11 @@ module.exports = function (app, config, renderTemplate) {
|
|||||||
|
|
||||||
const getChannelData = async (url) => {
|
const getChannelData = async (url) => {
|
||||||
try {
|
try {
|
||||||
return await fetch(url)
|
return await fetch(url, {
|
||||||
|
headers: {
|
||||||
|
'User-Agent': config.useragent,
|
||||||
|
},
|
||||||
|
})
|
||||||
.then((res) => res.text())
|
.then((res) => res.text())
|
||||||
.then((txt) => getJson(txt));
|
.then((txt) => getJson(txt));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -287,7 +299,7 @@ module.exports = function (app, config, renderTemplate) {
|
|||||||
|
|
||||||
if (bannedchannels.some(channel => channel === ID) && !bypassExists && !tabExists && !continuationExists) {
|
if (bannedchannels.some(channel => channel === ID) && !bypassExists && !tabExists && !continuationExists) {
|
||||||
var cinv = {
|
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.`,
|
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.`
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -340,17 +352,28 @@ module.exports = function (app, config, renderTemplate) {
|
|||||||
j: boutJson,
|
j: boutJson,
|
||||||
sort: sort_by,
|
sort: sort_by,
|
||||||
stream,
|
stream,
|
||||||
description,
|
tj,
|
||||||
subscribers,
|
c,
|
||||||
banner: c.banner,
|
|
||||||
logo: c.logo,
|
|
||||||
ctv: c.ctv,
|
|
||||||
cinv,
|
cinv,
|
||||||
dnoreplace,
|
convert,
|
||||||
|
turntomins,
|
||||||
|
pronoun,
|
||||||
media_proxy_url: media_proxy,
|
media_proxy_url: media_proxy,
|
||||||
|
dnoreplace,
|
||||||
|
getThumbnailUrl,
|
||||||
|
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.log(error);
|
console.error("Failed to render channel page:", error);
|
||||||
res.redirect("/");
|
res.redirect("/");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user