fix somethin lel

This commit is contained in:
Ashley 2022-12-16 22:18:03 +00:00
parent 90e25c74c3
commit 075627c520

View file

@ -66,52 +66,41 @@ async function lyricsFinder(e = "", d = "") {
} }
return String(encoding.convert(final)).trim(); return String(encoding.convert(final)).trim();
} }
function lightOrDark(color) { function lightOrDark(color) {
// Variables for red, green, blue values
var r, g, b, hsp;
// Variables for red, green, blue values // Check the format of the color, HEX or RGB?
var r, g, b, hsp; if (color.match(/^rgb/)) {
// If RGB --> store the red, green, blue values in separate variables
// Check the format of the color, HEX or RGB? color = color.match(
if (color.match(/^rgb/)) { /^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)$/
// If RGB --> store the red, green, blue values in separate variables
color = color.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)$/);
r = color[1];
g = color[2];
b = color[3];
}
else {
// If hex --> Convert it to RGB: http://gist.github.com/983661
color = +("0x" + color.slice(1).replace(
color.length < 5 && /./g, '$&$&'));
r = color >> 16;
g = color >> 8 & 255;
b = color & 255;
}
// HSP (Highly Sensitive Poo) equation from http://alienryderflex.com/hsp.html
hsp = Math.sqrt(
0.299 * (r * r) +
0.587 * (g * g) +
0.114 * (b * b)
); );
// Using the HSP value, determine whether the color is light or dark r = color[1];
if (hsp>127.5) { g = color[2];
b = color[3];
} else {
// If hex --> Convert it to RGB: http://gist.github.com/983661
color = +("0x" + color.slice(1).replace(color.length < 5 && /./g, "$&$&"));
return 'light'; r = color >> 16;
} g = (color >> 8) & 255;
else { b = color & 255;
}
return 'dark'; // HSP (Highly Sensitive Poo) equation from http://alienryderflex.com/hsp.html
} hsp = Math.sqrt(0.299 * (r * r) + 0.587 * (g * g) + 0.114 * (b * b));
// Using the HSP value, determine whether the color is light or dark
if (hsp > 127.5) {
return "light";
} else {
return "dark";
}
} }
module.exports = function (app, config, renderTemplate) { module.exports = function (app, config, renderTemplate) {
app.get("/encryption", async function (req, res) { app.get("/encryption", async function (req, res) {
var v = req.query.v; var v = req.query.v;
@ -172,83 +161,81 @@ module.exports = function (app, config, renderTemplate) {
const ip = JSON.parse(jj); const ip = JSON.parse(jj);
const isvld = await core.isvalidvideo(v); const isvld = await core.isvalidvideo(v);
if (isvld) { if (isvld) {
core.video(v).then((data) => {
core.video(v).then((data) => { if (data) {
const k = data.video; const k = data.video;
const json = data.json; const json = data.json;
const engagement = data.engagement; const engagement = data.engagement;
var inv_comments = data.comments; var inv_comments = data.comments;
const inv_vid = data.vid; const inv_vid = data.vid;
if(data.video) { if (data.video) {
if(json) { if (json) {
if (json.Title) {
if (!data.comments) inv_comments = "Disabled";
if(json.Title) { if (!core.video(v).b) {
if (!data.comments) inv_comments = "Disabled"; var nnn = "";
var badges = "";
var comments = "";
}
if (!core.video(v).b) { if (!v) res.redirect("/");
var nnn = "";
var badges = ""; if (q === "medium") {
var comments = ""; var url = `https://inv.vern.cc/latest_version?id=${v}&itag=18&local=true`;
}
const desc = data.desc;
if (d) {
var d = desc.toString().replace(/\n/g, " <br> ");
}
if (d === "[object Object]") {
var d = false;
}
renderTemplate(res, req, "poketube.ejs", {
color: data.color,
color2: data.color2,
engagement: engagement,
video: json,
date: k.Video.uploadDate,
e: e,
k: k,
process: process,
sha384: sha384,
lightOrDark,
isMobile: req.useragent.isMobile,
tj: data.channel,
r: r,
qua: q,
inv: inv_comments,
ip: ip,
convert: convert,
wiki: data.wiki,
f: f,
t: config.t_url,
optout: t,
badges: badges,
desc: desc,
comments: comments,
n: nnn,
inv_vid,
lyrics: "",
});
}
} }
}
if (!v) res.redirect("/"); } else {
res.redirect("/");
if (q === "medium") { }
var url = `https://inv.vern.cc/latest_version?id=${v}&itag=18&local=true`; });
}
const desc = data.desc;
if (d) {
var d = desc.toString().replace(/\n/g, " <br> ");
}
if (d === "[object Object]") {
var d = false;
}
renderTemplate(res, req, "poketube.ejs", {
color: data.color,
color2:data.color2,
engagement: engagement,
video: json,
date: k.Video.uploadDate,
e: e,
k: k,
process: process,
sha384: sha384,
lightOrDark,
isMobile: req.useragent.isMobile,
tj: data.channel,
r: r,
qua: q,
inv: inv_comments,
ip: ip,
convert: convert,
wiki: data.wiki,
f: f,
t: config.t_url,
optout: t,
badges: badges,
desc: desc,
comments: comments,
n: nnn,
inv_vid,
lyrics: "",
});
} }
}
});
} else { } else {
res.redirect("/"); res.redirect("/");
} }
}); });
app.get("/lite", async function (req, res) { app.get("/lite", async function (req, res) {
/* /*
* QUERYS * QUERYS
@ -271,72 +258,68 @@ module.exports = function (app, config, renderTemplate) {
const ip = JSON.parse(jj); const ip = JSON.parse(jj);
const isvld = await core.isvalidvideo(v); const isvld = await core.isvalidvideo(v);
if (isvld) { if (isvld) {
core.video(v).then((data) => {
core.video(v).then((data) => { const k = data.video;
const k = data.video; const json = data.json;
const json = data.json; const engagement = data.engagement;
const engagement = data.engagement; var inv_comments = data.comments;
var inv_comments = data.comments; const inv_vid = data.vid;
const inv_vid = data.vid; if (json.Title) {
if(json.Title) { if (!data.comments) inv_comments = "Disabled";
if (!data.comments) inv_comments = "Disabled";
if (!core.video(v).b) { if (!core.video(v).b) {
var nnn = ""; var nnn = "";
var badges = ""; var badges = "";
var comments = ""; var comments = "";
} }
if (!v) res.redirect("/"); if (!v) res.redirect("/");
if (q === "medium") { if (q === "medium") {
var url = `https://inv.vern.cc/latest_version?id=${v}&itag=18&local=true`; var url = `https://inv.vern.cc/latest_version?id=${v}&itag=18&local=true`;
} }
const desc = data.desc; const desc = data.desc;
if (d) { if (d) {
var d = desc.toString().replace(/\n/g, " <br> "); var d = desc.toString().replace(/\n/g, " <br> ");
} }
if (d === "[object Object]") { if (d === "[object Object]") {
var d = false; var d = false;
} }
renderTemplate(res, req, "lite.ejs", { renderTemplate(res, req, "lite.ejs", {
color: data.color, color: data.color,
color2:data.color2, color2: data.color2,
engagement: engagement, engagement: engagement,
video: json, video: json,
date: k.Video.uploadDate, date: k.Video.uploadDate,
e: e, e: e,
k: k, k: k,
process: process, process: process,
sha384: sha384, sha384: sha384,
lightOrDark, lightOrDark,
isMobile: req.useragent.isMobile, isMobile: req.useragent.isMobile,
tj: data.channel, tj: data.channel,
r: r, r: r,
qua: q, qua: q,
inv: inv_comments, inv: inv_comments,
ip: ip, ip: ip,
convert: convert, convert: convert,
wiki: data.wiki, wiki: data.wiki,
f: f, f: f,
t: config.t_url, t: config.t_url,
optout: t, optout: t,
badges: badges, badges: badges,
desc: desc, desc: desc,
comments: comments, comments: comments,
n: nnn, n: nnn,
inv_vid, inv_vid,
lyrics: "", lyrics: "",
});
}
}); });
}
});
} else { } else {
res.redirect("/"); res.redirect("/");
} }
@ -409,10 +392,10 @@ module.exports = function (app, config, renderTemplate) {
if (!song) { if (!song) {
res.redirect(`/watch?v=${v}`); res.redirect(`/watch?v=${v}`);
} }
const lyrics = await lyricsFinder(song.artist + song.title ); const lyrics = await lyricsFinder(song.artist + song.title);
if (lyrics == undefined) lyrics = "Lyrics not found"; if (lyrics == undefined) lyrics = "Lyrics not found";
var ly = ""; var ly = "";
if (lyrics === null) { if (lyrics === null) {