-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_loader.js
More file actions
26 lines (25 loc) · 1.02 KB
/
test_loader.js
File metadata and controls
26 lines (25 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
async function testLoader() {
console.log("Testing loader.to 1080p download progression");
const res = await fetch(`https://loader.to/ajax/download.php?start=1&end=1&format=1080&url=https://www.youtube.com/watch?v=fJ9rUzIMcZQ`);
const data = await res.json();
console.log("Response:", data);
if (data.id) {
console.log("Got task ID. Polling...");
let done = false;
while (!done) {
const pRes = await fetch(`https://loader.to/ajax/progress.php?id=${data.id}`);
const pData = await pRes.json();
console.log("Progress:", pData);
if (pData.success === 1 || pData.download_url) {
console.log("DOWNLOAD URL:", pData.download_url);
done = true;
} else if (pData.text && pData.text.includes("Error")) {
console.log("Error:", pData.text);
done = true;
} else {
await new Promise(r => setTimeout(r, 2000));
}
}
}
}
testLoader();