mirror of
https://codeberg.org/ashley/poke.git
synced 2024-11-22 20:57:48 +01:00
test b
This commit is contained in:
parent
aa3de021c7
commit
9f1cbd77d8
1 changed files with 177 additions and 167 deletions
|
@ -191,7 +191,7 @@ module.exports = function (app, config, renderTemplate) {
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get("/watch", async (req, res) => {
|
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) {
|
if (!v) {
|
||||||
return res.redirect("/");
|
return res.redirect("/");
|
||||||
|
@ -207,7 +207,6 @@ app.get("/watch", async (req, res) => {
|
||||||
var contentlang = hl || "en-US";
|
var contentlang = hl || "en-US";
|
||||||
var contentregion = region || "US";
|
var contentregion = region || "US";
|
||||||
|
|
||||||
try {
|
|
||||||
const isVideoValid = await INNERTUBE.isvalidvideo(v);
|
const isVideoValid = await INNERTUBE.isvalidvideo(v);
|
||||||
if (!isVideoValid) {
|
if (!isVideoValid) {
|
||||||
return res.redirect("/?fromerror=21_video_not_valid");
|
return res.redirect("/?fromerror=21_video_not_valid");
|
||||||
|
@ -218,10 +217,10 @@ app.get("/watch", async (req, res) => {
|
||||||
const secure = ["poketube.fun"].includes(req.hostname);
|
const secure = ["poketube.fun"].includes(req.hostname);
|
||||||
const verify = req.hostname === "poketube.sudovanilla.com";
|
const verify = req.hostname === "poketube.sudovanilla.com";
|
||||||
|
|
||||||
// Wrap the API call in a try/catch to handle any errors
|
|
||||||
try {
|
|
||||||
const data = await INNERTUBE.getYouTubeApiVideo(f, v, contentlang, contentregion);
|
|
||||||
|
|
||||||
|
INNERTUBE.getYouTubeApiVideo(f, v, contentlang, contentregion).then(
|
||||||
|
(data) => {
|
||||||
|
try {
|
||||||
const k = data?.video;
|
const k = data?.video;
|
||||||
const channel_uploads = data?.channel_uploads;
|
const channel_uploads = data?.channel_uploads;
|
||||||
const json = data?.json;
|
const json = data?.json;
|
||||||
|
@ -230,16 +229,14 @@ app.get("/watch", async (req, res) => {
|
||||||
const inv_vid = data?.vid;
|
const inv_vid = data?.vid;
|
||||||
const desc = data?.desc || "";
|
const desc = data?.desc || "";
|
||||||
|
|
||||||
if (k?.Error) {
|
if(k.Error) res.send("error")
|
||||||
return res.status(404).send("404: Not Found");
|
|
||||||
}
|
|
||||||
|
|
||||||
let d = false;
|
let d = false;
|
||||||
if (desc !== "[object Object]") {
|
if (desc !== "[object Object]") {
|
||||||
d = desc.toString().replace(/\n/g, " <br> ");
|
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) {
|
function extractInfo(regex) {
|
||||||
return descriptionString !== "[object Object]"
|
return descriptionString !== "[object Object]"
|
||||||
|
@ -248,17 +245,17 @@ app.get("/watch", async (req, res) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const support = extractInfo(PATREON_REGEX);
|
const support = extractInfo(PATREON_REGEX);
|
||||||
const twitter = extractInfo(TWITTER_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 linkto = extractInfo(LNKTO_REGEX);
|
const linkto = extractInfo(LNKTO_REGEX);
|
||||||
const discord = extractInfo(CORD_REGEX);
|
const discord = extractInfo(CORD_REGEX);
|
||||||
const twitch = extractInfo(TWITCH_REGEX);
|
const twitch = extractInfo(TWITCH_REGEX);
|
||||||
const reddit = extractInfo(REDDIT_REGEX);
|
const reddit = extractInfo(REDDIT_REGEX);
|
||||||
|
|
||||||
|
/* meta software */
|
||||||
const instagram = extractInfo(INSTAGRAM_REGEX);
|
const instagram = extractInfo(INSTAGRAM_REGEX);
|
||||||
const threads_by_instagram = extractInfo(THREADS_BY_INSTAGRAM_REGEX);
|
const threads_by_instagram = extractInfo(THREADS_BY_INSTAGRAM_REGEX);
|
||||||
|
|
||||||
const videoObject = inv_vid?.adaptiveFormats;
|
const videoObject = inv_vid?.adaptiveFormats;
|
||||||
|
|
||||||
function findItag(adaptiveFormats) {
|
function findItag(adaptiveFormats) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -270,44 +267,58 @@ app.get("/watch", async (req, res) => {
|
||||||
var mediaproxy = config.media_proxy;
|
var mediaproxy = config.media_proxy;
|
||||||
|
|
||||||
if (inv_vid?.genre === "Music") {
|
if (inv_vid?.genre === "Music") {
|
||||||
vidurl = u.losslessurl;
|
var vidurl = u.losslessurl;
|
||||||
}
|
}
|
||||||
|
|
||||||
vidurl = config.videourl;
|
var vidurl = config.videourl;
|
||||||
isvidious = true;
|
var isvidious = true;
|
||||||
|
|
||||||
if (req.useragent.source.includes("Pardus")) {
|
if (req.useragent.source.includes("Pardus")) {
|
||||||
vidurl = "https://iv.ggtyler.dev";
|
var vidurl = "https://iv.ggtyler.dev";
|
||||||
mediaproxy = "https://nyc1.pokejan.ggtyler.dev/";
|
var mediaproxy = "https://nyc1.pokejan.ggtyler.dev/";
|
||||||
isvidious = true;
|
var isvidious = true;
|
||||||
|
var isSchoolProxy = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// unused
|
||||||
|
let badges = "";
|
||||||
|
let comments = "";
|
||||||
|
let nnn = "";
|
||||||
|
|
||||||
const dnt_val = isDntEnabled(req);
|
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") {
|
if (
|
||||||
return res.status(403).send("error: " + inv_vid.error + " please refresh the page");
|
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) {
|
if (inv_vid?.error) {
|
||||||
return renderTemplate(res, req, "404.ejs", {
|
renderTemplate(res, req, "404.ejs", {
|
||||||
v,
|
v,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var uaos = req.useragent.os;
|
var uaos = req.useragent.os;
|
||||||
const browser = req.useragent.browser;
|
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") {
|
if (uaos === "Windows XP" || uaos === "Windows Vista")
|
||||||
return res.redirect("/lite?v=" + req.query.v);
|
res.redirect("/lite?v=" + req.query.v);
|
||||||
}
|
|
||||||
|
if (req.useragent.source.includes("Nintendo WiiU"))
|
||||||
|
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;
|
if (req.query.from === "short") var shortsui = true;
|
||||||
|
|
||||||
|
try {
|
||||||
renderTemplate(res, req, "poketube.ejs", {
|
renderTemplate(res, req, "poketube.ejs", {
|
||||||
color: data.color,
|
color: data.color,
|
||||||
color2: data.color2,
|
color2: data.color2,
|
||||||
|
@ -320,12 +331,12 @@ app.get("/watch", async (req, res) => {
|
||||||
support,
|
support,
|
||||||
shortsui,
|
shortsui,
|
||||||
u: vidurl,
|
u: vidurl,
|
||||||
isvidious,
|
isvidious: isvidious,
|
||||||
video: json,
|
video: json,
|
||||||
date: k.Video.uploadDate,
|
date: k.Video.uploadDate,
|
||||||
e,
|
e,
|
||||||
a,
|
a,
|
||||||
twitter,
|
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,
|
||||||
k,
|
k,
|
||||||
dm,
|
dm,
|
||||||
proxyurl,
|
proxyurl,
|
||||||
|
@ -341,7 +352,7 @@ app.get("/watch", async (req, res) => {
|
||||||
channel_uploads,
|
channel_uploads,
|
||||||
secure,
|
secure,
|
||||||
process,
|
process,
|
||||||
isSchoolProxy:"",
|
isSchoolProxy,
|
||||||
sha384,
|
sha384,
|
||||||
lightOrDark,
|
lightOrDark,
|
||||||
isMobile: req.useragent.isMobile,
|
isMobile: req.useragent.isMobile,
|
||||||
|
@ -364,18 +375,17 @@ app.get("/watch", async (req, res) => {
|
||||||
inv_vid,
|
inv_vid,
|
||||||
lyrics: "",
|
lyrics: "",
|
||||||
});
|
});
|
||||||
} catch (fetchError) {
|
} catch {
|
||||||
// Handle fetch errors (like timeouts)
|
return res.send("404");
|
||||||
console.error("Error fetching video data: ", fetchError);
|
|
||||||
return res.status(500).send("Error fetching video data");
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error during processing: ", error);
|
console.error(error);
|
||||||
return res.status(500).send("Internal Server Error");
|
return res.redirect(`/watch?v=${req.query.v}&fx=1&err=${error}`);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
app.get("/lite", async (req, res) => {
|
app.get("/lite", 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;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue