mirror of
https://codeberg.org/ashley/poke.git
synced 2024-12-01 07:57:24 +01:00
Improvements owowowowowo
This commit is contained in:
parent
11da1178d4
commit
5634a5cb87
1 changed files with 53 additions and 58 deletions
|
@ -57,76 +57,56 @@ async function channel(id, cnt) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function video(v) {
|
async function video(v) {
|
||||||
if (v == null) return "Gib ID";
|
try {
|
||||||
|
if (v == null) return "Gib ID";
|
||||||
|
|
||||||
let nightlyRes;
|
let nightlyRes;
|
||||||
|
|
||||||
for (let i = 0; i < 2; i++) {
|
const video = await fetch(`${config.tubeApi}video?v=${v}`)
|
||||||
try {
|
.then((res) => res.text())
|
||||||
const nightly = await fetch(
|
.then((xml) => JSON.parse(toJson(xml)));
|
||||||
`https://lighttube-nightly.kuylar.dev/api/video?v=${v}`
|
|
||||||
).then((res) => res.text());
|
|
||||||
|
|
||||||
nightlyRes = nightly;
|
var inv_comments = await fetch(`${config.invapi}/comments/${v}`).then(
|
||||||
break;
|
(res) => res.text()
|
||||||
} catch (err) {
|
);
|
||||||
if (err.status === 500)
|
|
||||||
// Retry after a second.
|
|
||||||
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
||||||
else return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const video = await fetch(`${config.tubeApi}video?v=${v}`)
|
var comments = await JSON.parse(inv_comments);
|
||||||
.then((res) => res.text())
|
|
||||||
.then((xml) => JSON.parse(toJson(xml)));
|
|
||||||
|
|
||||||
var inv_comments = await fetch(`${config.invapi}/comments/${v}`).then((res) =>
|
var video_new_info = await fetch(`${config.invapi}/videos/${v}`).then(
|
||||||
res.text()
|
(res) => res.text()
|
||||||
);
|
);
|
||||||
|
|
||||||
var comments = await JSON.parse(inv_comments);
|
var vid = await JSON.parse(video_new_info);
|
||||||
|
|
||||||
|
|
||||||
var video_new_info = await fetch(`${config.invapi}/videos/${v}`).then((res) =>
|
|
||||||
res.text()
|
|
||||||
);
|
|
||||||
|
|
||||||
var vid = await JSON.parse(video_new_info);
|
const a = await fetch(
|
||||||
|
`${config.tubeApi}channel?id=${video.Video.Channel.id}&tab=about`
|
||||||
|
)
|
||||||
|
.then((res) => res.text())
|
||||||
|
.then((xml) => JSON.parse(toJson(xml)));
|
||||||
|
|
||||||
const c = await fetch(
|
const summary = await wiki
|
||||||
`${config.tubeApi}channel?id=${video.Video.Channel.id}&tab=videos`
|
.summary(video.Video.Channel.Name + " ")
|
||||||
)
|
.then((summary_) =>
|
||||||
.then((res) => res.text())
|
summary_.title !== "Not found." ? summary_ : "none"
|
||||||
.then((xml) => JSON.parse(toJson(xml)));
|
);
|
||||||
|
|
||||||
const a = await fetch(
|
const data = await fetcher(v);
|
||||||
`${config.tubeApi}channel?id=${video.Video.Channel.id}&tab=about`
|
|
||||||
)
|
|
||||||
.then((res) => res.text())
|
|
||||||
.then((xml) => JSON.parse(toJson(xml)));
|
|
||||||
|
|
||||||
const summary = await wiki
|
const nightlyJsonData = getJson(nightlyRes);
|
||||||
.summary(video.Video.Channel.Name + " ")
|
|
||||||
.then((summary_) => (summary_.title !== "Not found." ? summary_ : "none"));
|
|
||||||
|
|
||||||
const data = await fetcher(v);
|
return {
|
||||||
|
json: data.video.Player,
|
||||||
const nightlyJsonData = getJson(nightlyRes);
|
video,
|
||||||
|
vid,
|
||||||
return {
|
comments,
|
||||||
json: data.video.Player,
|
engagement: data.engagement,
|
||||||
video,
|
wiki: summary,
|
||||||
vid,
|
desc: a.Channel.Contents.ItemSection.About.Description,
|
||||||
channel: c,
|
color: await getColors(
|
||||||
comments,
|
`https://i.ytimg.com/vi/${v}/maxresdefault.jpg`
|
||||||
engagement: data.engagement,
|
).then((colors) => colors[0].hex()),
|
||||||
wiki: summary,
|
|
||||||
desc: a.Channel.Contents.ItemSection.About.Description,
|
|
||||||
color: await getColors(
|
|
||||||
`https://i.ytimg.com/vi/${v}/maxresdefault.jpg`
|
|
||||||
).then((colors) => colors[0].hex()),
|
|
||||||
};
|
};
|
||||||
|
} catch (err) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function search(query, cnt) {
|
async function search(query, cnt) {
|
||||||
|
@ -141,8 +121,23 @@ async function search(query, cnt) {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function isvalidvideo(v) {
|
||||||
|
var status;
|
||||||
|
const vld = await fetch(`${config.dislikes}${v}`).then((res) => {
|
||||||
|
status = res.status;
|
||||||
|
return res.json();
|
||||||
|
});
|
||||||
|
|
||||||
|
if (status == 400) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
search,
|
search,
|
||||||
video,
|
video,
|
||||||
|
isvalidvideo,
|
||||||
channel,
|
channel,
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue