mirror of
https://codeberg.org/ashley/poke.git
synced 2024-11-26 15:58:13 +01:00
fix somethin lel
This commit is contained in:
parent
90e25c74c3
commit
075627c520
1 changed files with 151 additions and 168 deletions
|
@ -68,50 +68,39 @@ async function lyricsFinder(e = "", d = "") {
|
||||||
}
|
}
|
||||||
|
|
||||||
function lightOrDark(color) {
|
function lightOrDark(color) {
|
||||||
|
|
||||||
// Variables for red, green, blue values
|
// Variables for red, green, blue values
|
||||||
var r, g, b, hsp;
|
var r, g, b, hsp;
|
||||||
|
|
||||||
// Check the format of the color, HEX or RGB?
|
// Check the format of the color, HEX or RGB?
|
||||||
if (color.match(/^rgb/)) {
|
if (color.match(/^rgb/)) {
|
||||||
|
|
||||||
// If RGB --> store the red, green, blue values in separate variables
|
// If RGB --> store the red, green, blue values in separate variables
|
||||||
color = color.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)$/);
|
color = color.match(
|
||||||
|
/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)$/
|
||||||
|
);
|
||||||
|
|
||||||
r = color[1];
|
r = color[1];
|
||||||
g = color[2];
|
g = color[2];
|
||||||
b = color[3];
|
b = color[3];
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
|
|
||||||
// If hex --> Convert it to RGB: http://gist.github.com/983661
|
// If hex --> Convert it to RGB: http://gist.github.com/983661
|
||||||
color = +("0x" + color.slice(1).replace(
|
color = +("0x" + color.slice(1).replace(color.length < 5 && /./g, "$&$&"));
|
||||||
color.length < 5 && /./g, '$&$&'));
|
|
||||||
|
|
||||||
r = color >> 16;
|
r = color >> 16;
|
||||||
g = color >> 8 & 255;
|
g = (color >> 8) & 255;
|
||||||
b = color & 255;
|
b = color & 255;
|
||||||
}
|
}
|
||||||
|
|
||||||
// HSP (Highly Sensitive Poo) equation from http://alienryderflex.com/hsp.html
|
// HSP (Highly Sensitive Poo) equation from http://alienryderflex.com/hsp.html
|
||||||
hsp = Math.sqrt(
|
hsp = Math.sqrt(0.299 * (r * r) + 0.587 * (g * g) + 0.114 * (b * b));
|
||||||
0.299 * (r * r) +
|
|
||||||
0.587 * (g * g) +
|
|
||||||
0.114 * (b * b)
|
|
||||||
);
|
|
||||||
|
|
||||||
// Using the HSP value, determine whether the color is light or dark
|
// Using the HSP value, determine whether the color is light or dark
|
||||||
if (hsp>127.5) {
|
if (hsp > 127.5) {
|
||||||
|
return "light";
|
||||||
return 'light';
|
} else {
|
||||||
}
|
return "dark";
|
||||||
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,19 +161,17 @@ 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(json.Title) {
|
|
||||||
if (!data.comments) inv_comments = "Disabled";
|
if (!data.comments) inv_comments = "Disabled";
|
||||||
|
|
||||||
if (!core.video(v).b) {
|
if (!core.video(v).b) {
|
||||||
|
@ -210,7 +197,7 @@ module.exports = function (app, config, renderTemplate) {
|
||||||
|
|
||||||
renderTemplate(res, req, "poketube.ejs", {
|
renderTemplate(res, req, "poketube.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,
|
||||||
|
@ -237,17 +224,17 @@ module.exports = function (app, config, renderTemplate) {
|
||||||
inv_vid,
|
inv_vid,
|
||||||
lyrics: "",
|
lyrics: "",
|
||||||
});
|
});
|
||||||
} }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
res.redirect("/");
|
||||||
|
}
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
res.redirect("/");
|
res.redirect("/");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
app.get("/lite", async function (req, res) {
|
app.get("/lite", async function (req, res) {
|
||||||
/*
|
/*
|
||||||
|
@ -271,16 +258,14 @@ 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) {
|
||||||
|
@ -306,7 +291,7 @@ module.exports = function (app, config, renderTemplate) {
|
||||||
|
|
||||||
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,
|
||||||
|
@ -335,8 +320,6 @@ module.exports = function (app, config, renderTemplate) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
res.redirect("/");
|
res.redirect("/");
|
||||||
}
|
}
|
||||||
|
@ -410,7 +393,7 @@ module.exports = function (app, config, renderTemplate) {
|
||||||
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 = "";
|
||||||
|
|
Loading…
Reference in a new issue