mirror of
https://codeberg.org/ashley/poke.git
synced 2024-11-10 16:08:25 +01:00
faster fetching :3
This commit is contained in:
parent
4d87c3621d
commit
14e770fe4c
1 changed files with 5 additions and 17 deletions
|
@ -27,7 +27,7 @@ module.exports = async function (video_id) {
|
||||||
const dislike = await fetch(`${dislike_api}${video_id}`).then((res) =>
|
const dislike = await fetch(`${dislike_api}${video_id}`).then((res) =>
|
||||||
res.json()
|
res.json()
|
||||||
);
|
);
|
||||||
|
|
||||||
const dislikes = dislike.dislikes || "none";
|
const dislikes = dislike.dislikes || "none";
|
||||||
|
|
||||||
const headers = {};
|
const headers = {};
|
||||||
|
@ -36,22 +36,10 @@ module.exports = async function (video_id) {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
async function parsexml(id) {
|
async function parsexml(id) {
|
||||||
for (let i = 0; i < 2; i++) {
|
const player = await fetch(`${new_api_url}?v=${id}`, headers);
|
||||||
try {
|
var h = await player.text();
|
||||||
const player = await fetch(`${new_api_url}?v=${id}`, headers);
|
var j = toJson(h);
|
||||||
var h = await player.text();
|
return JSON.parse(j);
|
||||||
var j = toJson(h);
|
|
||||||
return JSON.parse(j);
|
|
||||||
break;
|
|
||||||
} catch (err) {
|
|
||||||
if (err.status === 503) {
|
|
||||||
// retry after a bit
|
|
||||||
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
||||||
} else {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in a new issue