faster fetching :3

This commit is contained in:
Ashley 2022-11-16 17:43:53 +01:00
parent 8e1d3c1ba3
commit cde39cf98b

View file

@ -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++) {
try {
const player = await fetch(`${new_api_url}?v=${id}`, headers); const player = await fetch(`${new_api_url}?v=${id}`, headers);
var h = await player.text(); var h = await player.text();
var j = toJson(h); var j = toJson(h);
return JSON.parse(j); return JSON.parse(j);
break;
} catch (err) {
if (err.status === 503) {
// retry after a bit
await new Promise((resolve) => setTimeout(resolve, 1000));
} else {
return "";
}
}
}
} }
/* /*