Spaces:
Paused
Paused
Update index.js
Browse files
index.js
CHANGED
|
@@ -428,6 +428,41 @@ async function processImage(image, denoise, scale, format, type) {
|
|
| 428 |
},
|
| 429 |
});
|
| 430 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 431 |
const images = await axios.request({
|
| 432 |
method: "GET",
|
| 433 |
url:
|
|
|
|
| 428 |
},
|
| 429 |
});
|
| 430 |
|
| 431 |
+
|
| 432 |
+
const check_finish = async (id_hash) => {
|
| 433 |
+
let finished = false;
|
| 434 |
+
|
| 435 |
+
while (!finished) {
|
| 436 |
+
try {
|
| 437 |
+
const response = await axios.request({
|
| 438 |
+
method: "GET",
|
| 439 |
+
url: "https://api.alcaamado.es/api/v2/waifu2x/check?hash=" + id_hash
|
| 440 |
+
headers: {
|
| 441 |
+
Accept: "image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8",
|
| 442 |
+
"Content-Type": "image/jpg",
|
| 443 |
+
Referer: "https://waifu2x.pro/",
|
| 444 |
+
"User-Agent":
|
| 445 |
+
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
|
| 446 |
+
}
|
| 447 |
+
});
|
| 448 |
+
|
| 449 |
+
if (response.data.finished) {
|
| 450 |
+
finished = true;
|
| 451 |
+
return response.data
|
| 452 |
+
} else {
|
| 453 |
+
console.log("Polling in progress. Waiting for the next check...");
|
| 454 |
+
// Tambahkan delay jika diperlukan untuk mencegah polling terlalu sering
|
| 455 |
+
await new Promise(resolve => setTimeout(resolve, 3000)); // Delay 1 detik
|
| 456 |
+
}
|
| 457 |
+
} catch (error) {
|
| 458 |
+
console.error("Error during polling:", error.message);
|
| 459 |
+
// Tambahkan penanganan kesalahan jika diperlukan
|
| 460 |
+
}
|
| 461 |
+
}}
|
| 462 |
+
|
| 463 |
+
const fiss = await check_finish(response.data.hash)
|
| 464 |
+
if(fiss) throw "Error: Try Another Photo"
|
| 465 |
+
|
| 466 |
const images = await axios.request({
|
| 467 |
method: "GET",
|
| 468 |
url:
|