lint code :3

This commit is contained in:
ashley 2024-05-04 05:28:05 +00:00
parent d451a834a2
commit d4521153b1

View file

@ -141,8 +141,8 @@ function lightOrDark(color) {
} }
function isDntEnabled(req) { function isDntEnabled(req) {
const dntHeader = req.header('DNT'); const dntHeader = req.header("DNT");
return dntHeader && (dntHeader === '1' || dntHeader === 'true'); return dntHeader && (dntHeader === "1" || dntHeader === "true");
} }
function IsInArray(array, id) { function IsInArray(array, id) {
@ -203,148 +203,153 @@ module.exports = function (app, config, renderTemplate) {
const secure = ["poketube.fun"].includes(req.hostname); const secure = ["poketube.fun"].includes(req.hostname);
const verify = req.hostname === "poketube.sudovanilla.com"; const verify = req.hostname === "poketube.sudovanilla.com";
INNERTUBE.getYouTubeApiVideo(f, v, contentlang, contentregion).then((data) => { INNERTUBE.getYouTubeApiVideo(f, v, contentlang, contentregion).then(
try { (data) => {
const k = data?.video;
const channel_uploads = data?.channel_uploads
const json = data?.json;
const engagement = data?.engagement;
const inv_comments = data?.comments || "Disabled";
const inv_vid = data?.vid;
const desc = data?.desc || "";
let d = false;
if (desc !== "[object Object]") {
d = desc.toString().replace(/\n/g, " <br> ");
}
const descriptionString = String(inv_vid?.description);
function extractInfo(regex) {
return descriptionString !== "[object Object]"
? (regex.exec(descriptionString) ?? {}).groups
: undefined;
}
const support = extractInfo(PATREON_REGEX);
const twitter = extractInfo(X_REGEX);
const discord = extractInfo(CORD_REGEX);
const twitch = extractInfo(TWITCH_REGEX);
const reddit = extractInfo(REDDIT_REGEX);
const instagram = extractInfo(INSTAGRAM_REGEX);
var proxyurl = config.p_url;
var vidurl = u.url;
var isvidious = u.isInvidiousURL;
var mediaproxy = config.media_proxy
if (inv_vid?.genre === "Music") {
var vidurl = u.losslessurl;
}
var vidurl = config.videourl;
var isvidious = true;
if (req.useragent.source.includes("Pardus")) {
var vidurl = "https://iv.ggtyler.dev";
var mediaproxy = "https://nyc1.pokejan.ggtyler.dev/"
var isvidious = true;
var isSchoolProxy = "";
}
// unused
let badges = "";
let comments = "";
let nnn = "";
const dnt_val = isDntEnabled(req)
if (
inv_vid?.error ===
"The uploader has not made this video available in your country" ||
inv_vid?.error === "This video is not available"
) {
res.send(
"error: " + inv_vid.error + " please refresh the page please qt"
);
}
var uaos = req.useragent.os;
const browser = req.useragent.browser;
const IsOldWindows =
(uaos === "Windows 7" || uaos === "Windows 8") &&
browser === "Firefox";
if (uaos === "Windows XP" || uaos === "Windows Vista")
res.redirect("/lite?v=" + req.query.v);
if (req.query.from === "short") var shortsui = true;
try { try {
renderTemplate(res, req, "poketube.ejs", { const k = data?.video;
color: data.color, const channel_uploads = data?.channel_uploads;
color2: data.color2, const json = data?.json;
linkify, const engagement = data?.engagement;
engagement, const inv_comments = data?.comments || "Disabled";
IsOldWindows, const inv_vid = data?.vid;
channelurlfixer, const desc = data?.desc || "";
support,
shortsui, let d = false;
u: vidurl, if (desc !== "[object Object]") {
isvidious: isvidious, d = desc.toString().replace(/\n/g, " <br> ");
video: json, }
date: k.Video.uploadDate,
e, const descriptionString = String(inv_vid?.description);
a,
twitter, function extractInfo(regex) {
k, return descriptionString !== "[object Object]"
dm, ? (regex.exec(descriptionString) ?? {}).groups
proxyurl, : undefined;
media_proxy_url: mediaproxy, }
instagram,
useragent: req.useragent, const support = extractInfo(PATREON_REGEX);
verify, const twitter = extractInfo(X_REGEX);
discord, const discord = extractInfo(CORD_REGEX);
turntomins, const twitch = extractInfo(TWITCH_REGEX);
twitch, const reddit = extractInfo(REDDIT_REGEX);
dnt_val, const instagram = extractInfo(INSTAGRAM_REGEX);
reddit,
channel_uploads, var proxyurl = config.p_url;
secure, var vidurl = u.url;
process, var isvidious = u.isInvidiousURL;
isSchoolProxy, var mediaproxy = config.media_proxy;
sha384,
lightOrDark, if (inv_vid?.genre === "Music") {
isMobile: req.useragent.isMobile, var vidurl = u.losslessurl;
tj: data.channel, }
r,
qua: q, var vidurl = config.videourl;
inv: inv_comments, var isvidious = true;
convert,
universe, if (req.useragent.source.includes("Pardus")) {
wiki: data.wiki, var vidurl = "https://iv.ggtyler.dev";
escapeHtml, var mediaproxy = "https://nyc1.pokejan.ggtyler.dev/";
f, var isvidious = true;
t: config.t_url, var isSchoolProxy = "";
optout: m, }
badges,
desc, // unused
comments, let badges = "";
n: nnn, let comments = "";
inv_vid, let nnn = "";
lyrics: "",
}); const dnt_val = isDntEnabled(req);
} catch {
return; if (
inv_vid?.error ===
"The uploader has not made this video available in your country" ||
inv_vid?.error === "This video is not available"
) {
res.send(
"error: " + inv_vid.error + " please refresh the page please qt"
);
}
if (inv_vid.error) {
renderTemplate(res, req, "404.ejs", {
v,
});
}
var uaos = req.useragent.os;
const browser = req.useragent.browser;
const IsOldWindows =
(uaos === "Windows 7" || uaos === "Windows 8") &&
browser === "Firefox";
if (uaos === "Windows XP" || uaos === "Windows Vista")
res.redirect("/lite?v=" + req.query.v);
if (req.query.from === "short") var shortsui = true;
try {
renderTemplate(res, req, "poketube.ejs", {
color: data.color,
color2: data.color2,
linkify,
engagement,
IsOldWindows,
channelurlfixer,
support,
shortsui,
u: vidurl,
isvidious: isvidious,
video: json,
date: k.Video.uploadDate,
e,
a,
twitter,
k,
dm,
proxyurl,
media_proxy_url: mediaproxy,
instagram,
useragent: req.useragent,
verify,
discord,
turntomins,
twitch,
dnt_val,
reddit,
channel_uploads,
secure,
process,
isSchoolProxy,
sha384,
lightOrDark,
isMobile: req.useragent.isMobile,
tj: data.channel,
r,
qua: q,
inv: inv_comments,
convert,
universe,
wiki: data.wiki,
escapeHtml,
f,
t: config.t_url,
optout: m,
badges,
desc,
comments,
n: nnn,
inv_vid,
lyrics: "",
});
} catch {
return;
}
} catch (error) {
console.error(error);
return res.redirect(`/watch?v=${req.query.v}&fx=1&err=${error}`);
} }
} catch (error) {
console.error(error);
return res.redirect(`/watch?v=${req.query.v}&fx=1&err=${error}`);
} }
}); );
}); });
app.get("/lite", async (req, res) => { app.get("/lite", async (req, res) => {
@ -367,144 +372,143 @@ module.exports = function (app, config, renderTemplate) {
const secure = ["poketube.fun"].includes(req.hostname); const secure = ["poketube.fun"].includes(req.hostname);
const verify = req.hostname === "poketube.sudovanilla.com"; const verify = req.hostname === "poketube.sudovanilla.com";
INNERTUBE.getYouTubeApiVideo(f, v, contentlang, contentregion).then((data) => { INNERTUBE.getYouTubeApiVideo(f, v, contentlang, contentregion).then(
try { (data) => {
const k = data?.video;
const channel_uploads = data?.channel_uploads
const json = data?.json;
const engagement = data?.engagement;
const inv_comments = data?.comments || "Disabled";
const inv_vid = data?.vid;
const desc = data?.desc || "";
let d = false;
if (desc !== "[object Object]") {
d = desc.toString().replace(/\n/g, " <br> ");
}
const descriptionString = String(inv_vid?.description);
function extractInfo(regex) {
return descriptionString !== "[object Object]"
? (regex.exec(descriptionString) ?? {}).groups
: undefined;
}
const support = extractInfo(PATREON_REGEX);
const twitter = extractInfo(X_REGEX);
const discord = extractInfo(CORD_REGEX);
const twitch = extractInfo(TWITCH_REGEX);
const reddit = extractInfo(REDDIT_REGEX);
const instagram = extractInfo(INSTAGRAM_REGEX);
var proxyurl = config.p_url;
var vidurl = u.url;
var isvidious = u.isInvidiousURL;
var mediaproxy = config.media_proxy
if (inv_vid?.genre === "Music") {
var vidurl = u.losslessurl;
}
var vidurl = "https://eu-proxy.poketube.fun";
var isvidious = true;
if (req.useragent.source.includes("Pardus")) {
var vidurl = "https://iv.ggtyler.dev";
var mediaproxy = "https://media-proxy.ashley0143.xyz"
var isvidious = true;
var isSchoolProxy = "";
}
// unused
let badges = "";
let comments = "";
let nnn = "";
const dnt_val = isDntEnabled(req)
if (
inv_vid?.error ===
"The uploader has not made this video available in your country" ||
inv_vid?.error === "This video is not available"
) {
res.send(
"error: " + inv_vid.error + " please refresh the page please qt"
);
}
var uaos = req.useragent.os;
const browser = req.useragent.browser;
const IsOldWindows =
(uaos === "Windows 7" || uaos === "Windows 8") &&
browser === "Firefox";
if (req.query.from === "short") var shortsui = true;
try { try {
renderTemplate(res, req, "lite.ejs", { const k = data?.video;
color: data.color, const channel_uploads = data?.channel_uploads;
color2: data.color2, const json = data?.json;
linkify, const engagement = data?.engagement;
engagement, const inv_comments = data?.comments || "Disabled";
IsOldWindows, const inv_vid = data?.vid;
channelurlfixer, const desc = data?.desc || "";
support,
shortsui, let d = false;
u: vidurl, if (desc !== "[object Object]") {
isvidious: isvidious, d = desc.toString().replace(/\n/g, " <br> ");
video: json, }
date: k.Video.uploadDate,
e, const descriptionString = String(inv_vid?.description);
a,
twitter, function extractInfo(regex) {
k, return descriptionString !== "[object Object]"
dm, ? (regex.exec(descriptionString) ?? {}).groups
proxyurl, : undefined;
media_proxy_url: mediaproxy, }
instagram,
useragent: req.useragent, const support = extractInfo(PATREON_REGEX);
verify, const twitter = extractInfo(X_REGEX);
discord, const discord = extractInfo(CORD_REGEX);
turntomins, const twitch = extractInfo(TWITCH_REGEX);
twitch, const reddit = extractInfo(REDDIT_REGEX);
dnt_val, const instagram = extractInfo(INSTAGRAM_REGEX);
reddit,
channel_uploads, var proxyurl = config.p_url;
secure, var vidurl = u.url;
process, var isvidious = u.isInvidiousURL;
isSchoolProxy, var mediaproxy = config.media_proxy;
sha384,
lightOrDark, if (inv_vid?.genre === "Music") {
isMobile: req.useragent.isMobile, var vidurl = u.losslessurl;
tj: data.channel, }
r,
qua: q, var vidurl = "https://eu-proxy.poketube.fun";
inv: inv_comments, var isvidious = true;
convert,
universe, if (req.useragent.source.includes("Pardus")) {
wiki: data.wiki, var vidurl = "https://iv.ggtyler.dev";
f, var mediaproxy = "https://media-proxy.ashley0143.xyz";
t: config.t_url, var isvidious = true;
optout: m, var isSchoolProxy = "";
badges, }
desc,
comments, // unused
n: nnn, let badges = "";
inv_vid, let comments = "";
lyrics: "", let nnn = "";
});
} catch { const dnt_val = isDntEnabled(req);
return;
if (
inv_vid?.error ===
"The uploader has not made this video available in your country" ||
inv_vid?.error === "This video is not available"
) {
res.send(
"error: " + inv_vid.error + " please refresh the page please qt"
);
}
var uaos = req.useragent.os;
const browser = req.useragent.browser;
const IsOldWindows =
(uaos === "Windows 7" || uaos === "Windows 8") &&
browser === "Firefox";
if (req.query.from === "short") var shortsui = true;
try {
renderTemplate(res, req, "lite.ejs", {
color: data.color,
color2: data.color2,
linkify,
engagement,
IsOldWindows,
channelurlfixer,
support,
shortsui,
u: vidurl,
isvidious: isvidious,
video: json,
date: k.Video.uploadDate,
e,
a,
twitter,
k,
dm,
proxyurl,
media_proxy_url: mediaproxy,
instagram,
useragent: req.useragent,
verify,
discord,
turntomins,
twitch,
dnt_val,
reddit,
channel_uploads,
secure,
process,
isSchoolProxy,
sha384,
lightOrDark,
isMobile: req.useragent.isMobile,
tj: data.channel,
r,
qua: q,
inv: inv_comments,
convert,
universe,
wiki: data.wiki,
f,
t: config.t_url,
optout: m,
badges,
desc,
comments,
n: nnn,
inv_vid,
lyrics: "",
});
} catch {
return;
}
} catch (error) {
console.error(error);
return res.redirect(`/watch?v=${req.query.v}&fx=1&err=${error}`);
} }
} catch (error) {
console.error(error);
return res.redirect(`/watch?v=${req.query.v}&fx=1&err=${error}`);
} }
}); );
}); });
app.get("/music", async function (req, res) { app.get("/music", async function (req, res) {