mirror of
https://codeberg.org/ashley/poke.git
synced 2024-11-25 23:58:59 +01:00
a
This commit is contained in:
parent
93898da514
commit
54b92b1e29
1 changed files with 164 additions and 175 deletions
|
@ -190,8 +190,8 @@ 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;
|
||||
app.get("/watch", async (req, res) => {
|
||||
const { dm, region, hl, v, e, r, f, m, quality: q, a, universe } = req.query;
|
||||
|
||||
if (!v) {
|
||||
return res.redirect("/");
|
||||
|
@ -207,6 +207,7 @@ module.exports = function (app, config, renderTemplate) {
|
|||
var contentlang = hl || "en-US";
|
||||
var contentregion = region || "US";
|
||||
|
||||
try {
|
||||
const isVideoValid = await INNERTUBE.isvalidvideo(v);
|
||||
if (!isVideoValid) {
|
||||
return res.redirect("/?fromerror=21_video_not_valid");
|
||||
|
@ -217,9 +218,10 @@ module.exports = function (app, config, renderTemplate) {
|
|||
const secure = ["poketube.fun"].includes(req.hostname);
|
||||
const verify = req.hostname === "poketube.sudovanilla.com";
|
||||
|
||||
INNERTUBE.getYouTubeApiVideo(f, v, contentlang, contentregion).then(
|
||||
(data) => {
|
||||
// Wrap the API call in a try/catch to handle any errors
|
||||
try {
|
||||
const data = await INNERTUBE.getYouTubeApiVideo(f, v, contentlang, contentregion);
|
||||
|
||||
const k = data?.video;
|
||||
const channel_uploads = data?.channel_uploads;
|
||||
const json = data?.json;
|
||||
|
@ -237,7 +239,7 @@ module.exports = function (app, config, renderTemplate) {
|
|||
d = desc.toString().replace(/\n/g, " <br> ");
|
||||
}
|
||||
|
||||
const descriptionString = String(inv_vid?.description).replace(/\bx.com\b/, "twitter.com")
|
||||
const descriptionString = String(inv_vid?.description).replace(/\bx.com\b/, "twitter.com");
|
||||
|
||||
function extractInfo(regex) {
|
||||
return descriptionString !== "[object Object]"
|
||||
|
@ -246,17 +248,17 @@ module.exports = function (app, config, renderTemplate) {
|
|||
}
|
||||
|
||||
const support = extractInfo(PATREON_REGEX);
|
||||
const STUPID_ELON_MUSK_WEBSITE_HE_IS_TRYING_TO_CALL_IT_X_FOR_SOME_REASON_WHICH_IS_A_STUPID_NAME_WE_WILL_FOREVER_CALL_IT_TWITTER_AND_HE_CAN_DO_NOTHING_ABOUT_IT_LOL_FUCK_YOU_ELON_TRANS_RIGHTS_BTW = extractInfo(TWITTER_REGEX);
|
||||
const twitter = extractInfo(TWITTER_REGEX);
|
||||
const linkto = extractInfo(LNKTO_REGEX);
|
||||
const discord = extractInfo(CORD_REGEX);
|
||||
const twitch = extractInfo(TWITCH_REGEX);
|
||||
const reddit = extractInfo(REDDIT_REGEX);
|
||||
|
||||
/* meta software */
|
||||
const instagram = extractInfo(INSTAGRAM_REGEX);
|
||||
const threads_by_instagram = extractInfo(THREADS_BY_INSTAGRAM_REGEX);
|
||||
|
||||
const videoObject = inv_vid?.adaptiveFormats;
|
||||
|
||||
function findItag(adaptiveFormats) {
|
||||
return;
|
||||
}
|
||||
|
@ -268,58 +270,44 @@ module.exports = function (app, config, renderTemplate) {
|
|||
var mediaproxy = config.media_proxy;
|
||||
|
||||
if (inv_vid?.genre === "Music") {
|
||||
var vidurl = u.losslessurl;
|
||||
vidurl = u.losslessurl;
|
||||
}
|
||||
|
||||
var vidurl = config.videourl;
|
||||
var isvidious = true;
|
||||
vidurl = config.videourl;
|
||||
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 = "";
|
||||
vidurl = "https://iv.ggtyler.dev";
|
||||
mediaproxy = "https://nyc1.pokejan.ggtyler.dev/";
|
||||
isvidious = true;
|
||||
}
|
||||
|
||||
// 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"
|
||||
);
|
||||
if (inv_vid?.error === "The uploader has not made this video available in your country" || inv_vid?.error === "This video is not available") {
|
||||
return res.status(403).send("error: " + inv_vid.error + " please refresh the page");
|
||||
}
|
||||
|
||||
if (inv_vid?.error) {
|
||||
renderTemplate(res, req, "404.ejs", {
|
||||
return 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";
|
||||
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.useragent.source.includes("Nintendo WiiU"))
|
||||
res.redirect("/lite?v=" + req.query.v);
|
||||
if (uaos === "Windows XP" || uaos === "Windows Vista") {
|
||||
return res.redirect("/lite?v=" + req.query.v);
|
||||
}
|
||||
|
||||
if (req.useragent.source.includes("Nintendo WiiU")) {
|
||||
return 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,
|
||||
|
@ -332,12 +320,12 @@ module.exports = function (app, config, renderTemplate) {
|
|||
support,
|
||||
shortsui,
|
||||
u: vidurl,
|
||||
isvidious: isvidious,
|
||||
isvidious,
|
||||
video: json,
|
||||
date: k.Video.uploadDate,
|
||||
e,
|
||||
a,
|
||||
twitter:STUPID_ELON_MUSK_WEBSITE_HE_IS_TRYING_TO_CALL_IT_X_FOR_SOME_REASON_WHICH_IS_A_STUPID_NAME_WE_WILL_FOREVER_CALL_IT_TWITTER_AND_HE_CAN_DO_NOTHING_ABOUT_IT_LOL_FUCK_YOU_ELON_TRANS_RIGHTS_BTW,
|
||||
twitter,
|
||||
k,
|
||||
dm,
|
||||
proxyurl,
|
||||
|
@ -359,7 +347,7 @@ module.exports = function (app, config, renderTemplate) {
|
|||
isMobile: req.useragent.isMobile,
|
||||
tj: data.channel,
|
||||
r,
|
||||
threads:threads_by_instagram,
|
||||
threads: threads_by_instagram,
|
||||
qua: q,
|
||||
inv: inv_comments,
|
||||
convert,
|
||||
|
@ -376,16 +364,17 @@ module.exports = function (app, config, renderTemplate) {
|
|||
inv_vid,
|
||||
lyrics: "",
|
||||
});
|
||||
} catch {
|
||||
return;
|
||||
} catch (fetchError) {
|
||||
// Handle fetch errors (like timeouts)
|
||||
console.error("Error fetching video data: ", fetchError);
|
||||
return res.status(500).send("Error fetching video data");
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return res.redirect(`/watch?v=${req.query.v}&fx=1&err=${error}`);
|
||||
console.error("Error during processing: ", error);
|
||||
return res.status(500).send("Internal Server Error");
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
app.get("/lite", async (req, res) => {
|
||||
const { dm, region, hl, v, e, r, f, m, quality: q, a, universe, } = req.query;
|
||||
|
|
Loading…
Reference in a new issue