mirror of
https://codeberg.org/ashley/poke.git
synced 2024-11-23 00:37:49 +01:00
refactor code
This commit is contained in:
parent
078266099d
commit
34d3f49bda
1 changed files with 48 additions and 29 deletions
|
@ -27,7 +27,8 @@ function linkify(text) {
|
|||
|
||||
return text.replace(urlRegex, (url) => {
|
||||
// wrap the URL in an <a> tag with the URL as the href attribute
|
||||
return `<a href="/api/redirect?u=${btoa(url
|
||||
return `<a href="/api/redirect?u=${btoa(
|
||||
url
|
||||
.replace(/twitter\.com/g, "nitter.net")
|
||||
.replace(/reddit\.com/g, "teddit.net")
|
||||
.replace("https://youtube.com", "")
|
||||
|
@ -44,7 +45,6 @@ const updatedDescription = text.replace(regex, '<a href="/channel?id=$1"');
|
|||
return updatedDescription;
|
||||
}
|
||||
|
||||
|
||||
function endsWithYouTubeAutoGenerated(text) {
|
||||
const target = " Auto-generated by YouTube. ";
|
||||
return text.endsWith(target);
|
||||
|
@ -178,7 +178,19 @@ module.exports = function (app, config, renderTemplate) {
|
|||
});
|
||||
|
||||
app.get("/watch", async (req, res) => {
|
||||
const { dm, region, hl, v, e, r, f, m, quality: q, a, universe } = req.query;
|
||||
const {
|
||||
dm,
|
||||
region,
|
||||
hl,
|
||||
v,
|
||||
e,
|
||||
r,
|
||||
f,
|
||||
m,
|
||||
quality: q,
|
||||
a,
|
||||
universe,
|
||||
} = req.query;
|
||||
|
||||
if (!v) {
|
||||
return res.redirect("/");
|
||||
|
@ -226,14 +238,21 @@ module.exports = function (app, config, renderTemplate) {
|
|||
const reddit = extractInfo(REDDIT_REGEX);
|
||||
const instagram = extractInfo(INSTAGRAM_REGEX);
|
||||
|
||||
var vidurl = u.url
|
||||
var vidurl = u.url;
|
||||
var isvidious = u.isInvidiousURL;
|
||||
|
||||
if (inv_vid?.genre === "Music") {
|
||||
var vidurl = u.losslessurl
|
||||
var vidurl = u.losslessurl;
|
||||
}
|
||||
|
||||
if (inv_vid.author.endsWith(" - Topic")) {
|
||||
var vidurl = u.losslessurl;
|
||||
var isvidious = true;
|
||||
}
|
||||
|
||||
if (req.useragent.source.includes("Pardus")) {
|
||||
var vidurl = "https://yt.sudovanilla.com"
|
||||
var vidurl = "https://yt.sudovanilla.com";
|
||||
var isvidious = true;
|
||||
}
|
||||
|
||||
let badges = "";
|
||||
|
@ -259,7 +278,7 @@ module.exports = function (app, config, renderTemplate) {
|
|||
if (uaos === "Windows XP" || uaos === "Windows Vista")
|
||||
res.redirect("/lite?v=" + req.query.v);
|
||||
|
||||
if (req.query.from === "short") var shortsui = true
|
||||
if (req.query.from === "short") var shortsui = true;
|
||||
|
||||
try {
|
||||
renderTemplate(res, req, "poketube.ejs", {
|
||||
|
@ -272,7 +291,7 @@ module.exports = function (app, config, renderTemplate) {
|
|||
support,
|
||||
shortsui,
|
||||
u: vidurl,
|
||||
isvidious: u.isInvidiousURL,
|
||||
isvidious: isvidious,
|
||||
video: json,
|
||||
date: k.Video.uploadDate,
|
||||
e,
|
||||
|
|
Loading…
Reference in a new issue