add try catch :p

This commit is contained in:
Ashley 2023-01-07 14:52:46 +00:00
parent 96a8eba7ec
commit 7b8c7dcb73

View file

@ -199,84 +199,88 @@ module.exports = function (app, config, renderTemplate) {
secure = false; secure = false;
} }
if (isvld) { try {
core.video(v).then((data) => { if (isvld) {
if (data) { core.video(v).then((data) => {
if ("video" in getJson(data)) { if (data) {
const k = data.video; if ("video" in data) {
const json = data.json; const k = data.video;
const engagement = data.engagement; const json = data.json;
var inv_comments = data.comments; const engagement = data.engagement;
const inv_vid = data.vid; var inv_comments = data.comments;
//checks if json exists const inv_vid = data.vid;
//checks if json exists
if (json) { if (json) {
//checks if title exists in the json object //checks if title exists in the json object
if ("Title" in json) { if ("Title" in json) {
if (!data.comments) inv_comments = "Disabled"; if (!data.comments) inv_comments = "Disabled";
if (!core.video(v).b) { if (!core.video(v).b) {
var nnn = ""; var nnn = "";
var badges = ""; var badges = "";
var comments = ""; var comments = "";
}
if (!v) res.redirect("/");
if (q === "medium") {
var url = `https://inv.vern.cc/latest_version?id=${v}&itag=18&local=true`;
}
const desc = data.desc;
if (d) {
var d = desc.toString().replace(/\n/g, " <br> ");
}
if (d === "[object Object]") {
var d = false;
}
renderTemplate(res, req, "poketube.ejs", {
color: data.color,
color2: data.color2,
engagement: engagement,
video: json,
date: k.Video.uploadDate,
e,
a,
k,
secure,
process,
sha384,
lightOrDark,
isMobile: req.useragent.isMobile,
tj: data.channel,
r: r,
qua: q,
inv: inv_comments,
ip: ip,
convert: convert,
wiki: data.wiki,
f: f,
t: config.t_url,
optout: t,
badges: badges,
desc: desc,
comments: comments,
n: nnn,
inv_vid,
lyrics: "",
});
} }
if (!v) res.redirect("/");
if (q === "medium") {
var url = `https://inv.vern.cc/latest_version?id=${v}&itag=18&local=true`;
}
const desc = data.desc;
if (d) {
var d = desc.toString().replace(/\n/g, " <br> ");
}
if (d === "[object Object]") {
var d = false;
}
renderTemplate(res, req, "poketube.ejs", {
color: data.color,
color2: data.color2,
engagement: engagement,
video: json,
date: k.Video.uploadDate,
e,
a,
k,
secure,
process,
sha384,
lightOrDark,
isMobile: req.useragent.isMobile,
tj: data.channel,
r: r,
qua: q,
inv: inv_comments,
ip: ip,
convert: convert,
wiki: data.wiki,
f: f,
t: config.t_url,
optout: t,
badges: badges,
desc: desc,
comments: comments,
n: nnn,
inv_vid,
lyrics: "",
});
} }
} }
} else {
res.redirect("/");
} }
} else { });
res.redirect("/"); } else {
} res.redirect("/");
}); }
} else { } catch {
res.redirect("/"); res.redirect("/");
} }
}); });
@ -401,84 +405,83 @@ module.exports = function (app, config, renderTemplate) {
if (!v) { if (!v) {
res.redirect("/discover?tab=music"); res.redirect("/discover?tab=music");
} else { } else {
var fetching = await fetcher(v); var fetching = await fetcher(v);
const json = fetching.video.Player; const json = fetching.video.Player;
const video = await modules.fetch(config.tubeApi + `video?v=${v}`); const video = await modules.fetch(config.tubeApi + `video?v=${v}`);
const h = await video.text(); const h = await video.text();
const k = JSON.parse(modules.toJson(h)); const k = JSON.parse(modules.toJson(h));
if (!json.Channel.Name.endsWith(" - Topic")) { if (!json.Channel.Name.endsWith(" - Topic")) {
res.redirect(`/watch?v=${v}`); res.redirect(`/watch?v=${v}`);
} }
//video //video
var url = `https://tube.kuylar.dev/proxy/media/${v}/22`; var url = `https://tube.kuylar.dev/proxy/media/${v}/22`;
// encryption // encryption
const url_e = const url_e =
url + url +
"?e=" + "?e=" +
sha384(k.Video.Channel.id) + sha384(k.Video.Channel.id) +
sha384(k.Video.Channel.id) + sha384(k.Video.Channel.id) +
"Piwik" + "Piwik" +
sha384(config.t_url); sha384(config.t_url);
// channel info // channel info
const engagement = fetching.engagement; const engagement = fetching.engagement;
const channel = await modules.fetch( const channel = await modules.fetch(
config.tubeApi + `channel?id=${k.Video.Channel.id}&tab=videos` config.tubeApi + `channel?id=${k.Video.Channel.id}&tab=videos`
); );
const c = await channel.text(); const c = await channel.text();
const tj = JSON.parse(modules.toJson(c)); const tj = JSON.parse(modules.toJson(c));
// info // info
const song = await musicInfo.searchSong( const song = await musicInfo.searchSong(
{ {
title: k.Video.Title, title: k.Video.Title,
artist: json.Channel.Name.replace("- Topic", ""), artist: json.Channel.Name.replace("- Topic", ""),
}, },
1000 1000
); );
if (!song) { if (!song) {
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) ly = "This Is Where I'd Put The songs lyrics. IF IT HAD ONE "; if (lyrics == undefined)
ly = "This Is Where I'd Put The songs lyrics. IF IT HAD ONE ";
var ly = "";
if (lyrics) {
ly = lyrics.replace(/\n/g, " <br> ");
}
var ly = ""; renderTemplate(res, req, "poketube-music.ejs", {
if (lyrics) { url: url_e,
ly = lyrics.replace(/\n/g, " <br> "); info: song,
} color: await modules
.getColors(`https://i.ytimg.com/vi/${v}/maxresdefault.jpg`)
renderTemplate(res, req, "poketube-music.ejs", { .then((colors) => colors[0].hex()),
url: url_e, engagement: engagement,
info: song, process: process,
color: await modules ip: ip,
.getColors(`https://i.ytimg.com/vi/${v}/maxresdefault.jpg`) video: json,
.then((colors) => colors[0].hex()), date: modules.moment(k.Video.uploadDate).format("LL"),
engagement: engagement, e: e,
process: process, k: k,
ip: ip, sha384: sha384,
video: json, isMobile: req.useragent.isMobile,
date: modules.moment(k.Video.uploadDate).format("LL"), tj: tj,
e: e, r: r,
k: k, f: f,
sha384: sha384, t: config.t_url,
isMobile: req.useragent.isMobile, optout: t,
tj: tj, lyrics: ly,
r: r, });
f: f,
t: config.t_url,
optout: t,
lyrics: ly,
});
} }
}); });
}; };