mirror of
https://codeberg.org/ashley/poke.git
synced 2024-11-23 02:37:49 +01:00
check if formats exist
This commit is contained in:
parent
17c90e8c42
commit
8c644bd27e
1 changed files with 25 additions and 24 deletions
|
@ -112,33 +112,34 @@ module.exports = function (app, config, renderTemplate) {
|
||||||
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 (!v) res.redirect("/");
|
if (!v) res.redirect("/");
|
||||||
|
if ("Formats" in fetching.video.Player) {
|
||||||
|
//video
|
||||||
|
const j = fetching.video.Player.Formats.Format,
|
||||||
|
j_ = Array.isArray(j) ? j[j.length - 1] : j;
|
||||||
|
let url;
|
||||||
|
if (j_.URL != undefined) url = j_.URL;
|
||||||
|
|
||||||
//video
|
//checks if json exists
|
||||||
const j = fetching.video.Player.Formats.Format,
|
if (json) {
|
||||||
j_ = Array.isArray(j) ? j[j.length - 1] : j;
|
//checks if title exists in the json object
|
||||||
let url;
|
|
||||||
if (j_.URL != undefined) url = j_.URL;
|
|
||||||
|
|
||||||
//checks if json exists
|
if ("Title" in json) {
|
||||||
if (json) {
|
// json response
|
||||||
//checks if title exists in the json object
|
const re = {
|
||||||
|
main: {
|
||||||
|
video_id: sha384(json.id),
|
||||||
|
channel: sha384(json.Channel.Name),
|
||||||
|
title: sha384(json.Title),
|
||||||
|
date: sha384(btoa(Date.now()).toString()),
|
||||||
|
},
|
||||||
|
video: {
|
||||||
|
title: sha384(json.Title),
|
||||||
|
url: sha384(url),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
if ("Title" in json) {
|
res.json(re);
|
||||||
// json response
|
}
|
||||||
const re = {
|
|
||||||
main: {
|
|
||||||
video_id: sha384(json.id),
|
|
||||||
channel: sha384(json.Channel.Name),
|
|
||||||
title: sha384(json.Title),
|
|
||||||
date: sha384(btoa(Date.now()).toString()),
|
|
||||||
},
|
|
||||||
video: {
|
|
||||||
title: sha384(json.Title),
|
|
||||||
url: sha384(url),
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
res.json(re);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue