This commit is contained in:
Ashley //// 2024-03-29 15:36:17 +00:00
parent 681beb1bdb
commit 4f27a24a9b

View file

@ -345,73 +345,168 @@ module.exports = function (app, config, renderTemplate) {
}); });
}); });
app.get("/lite", async function (req, res) { app.get("/lite", async (req, res) => {
const { v, e, r, f, t, quality: q } = req.query; const { dm, region, hl, v, e, r, f, m, quality: q, a, universe, } = req.query;
if (!v) {
return res.redirect("/");
}
var contentlang = hl || "en-US";
var contentregion = region || "US";
const isVideoValid = await INNERTUBE.isvalidvideo(v);
if (!isVideoValid) {
return res.redirect("/?fromerror=21_video_not_valid");
}
const u = await media_proxy(v);
const secure = ["poketube.fun"].includes(req.hostname);
const verify = req.hostname === "poketube.sudovanilla.com";
INNERTUBE.getYouTubeApiVideo(f, v, contentlang, contentregion).then((data) => {
try { try {
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 var mediaproxy = config.media_proxy
var contentlang = "en-US";
var contentregion = "US";
if (inv_vid?.genre === "Music") {
var vidurl = u.losslessurl;
}
const data = await INNERTUBE?.getYouTubeApiVideo(f, v, contentlang, contentregion); var vidurl = "https://eu-proxy.poketube.fun";
const color = data.color; var isvidious = true;
const color2 = data.color2;
const desc = data?.desc;
const isMobile = req.useragent.isMobile;
const wiki = data?.wiki;
const json = data?.json;
const inv_vid = data?.vid;
const engagement = data?.engagement
const k = data?.video;
const { channel: tj } = data;
const u = await media_proxy(v);
const d = desc.toString().replace(/\n/g, " <br> ");
const comments = inv_comments || "Disabled";
const channel_uploads = data?.channel_uploads
const templateData = { if (req.useragent.source.includes("Pardus")) {
color, var vidurl = "https://iv.ggtyler.dev";
color2, 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 (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, engagement,
channel_uploads, IsOldWindows,
u: u.url, channelurlfixer,
support,
shortsui,
u: vidurl,
isvidious: isvidious,
video: json, video: json,
date: k.Video.uploadDate, date: k.Video.uploadDate,
e, e,
a,
twitter,
k, k,
dm,
proxyurl,
media_proxy_url: mediaproxy,
instagram,
useragent: req.useragent,
verify,
discord,
turntomins,
twitch,
dnt_val,
reddit,
channel_uploads,
secure,
process, process,
isSchoolProxy,
sha384, sha384,
lightOrDark, lightOrDark,
isMobile, isMobile: req.useragent.isMobile,
tj, tj: data.channel,
media_proxy_url: mediaproxy,
r, r,
qua: q, qua: q,
isvidious: u.isInvidiousURL, inv: inv_comments,
inv: comments,
turntomins,
convert, convert,
linkify, universe,
wiki, wiki: data.wiki,
f, f,
t: config.t_url, t: config.t_url,
optout: t, optout: m,
badges: "", badges,
desc, desc,
comments, comments,
n: "", n: nnn,
inv_vid, inv_vid,
lyrics: "", lyrics: "",
}; });
} catch {
renderTemplate(res, req, "lite.ejs", templateData); return;
}
} catch (error) { } catch (error) {
console.error(error); console.error(error);
res.redirect("/?err=" + 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) {
/* /*