| 361 | const asInfo = data.as?.split(" ")[0] || ""; |
| 362 | const ccFlag = data.countryCode |
| 363 | ? String.fromCodePoint( |
| 364 | ...data.countryCode |
| 365 | .toUpperCase() |
| 366 | .split("") |
| 367 | .map((c: string) => 127397 + c.charCodeAt(0)) |
| 368 | ) |
| 369 | : ""; |
| 370 | return { asInfo, ccFlag }; |
| 371 | } catch (error: any) { |
| 372 | return { asInfo: "", ccFlag: "" }; |
| 373 | } |
| 374 | } |
| 375 | |
| 376 | async function saveSpeedtestImage(url: string): Promise<string | null> { |
| 377 | try { |
| 378 | const imageUrl = url + ".png"; |
| 379 | const response = await axios.get(imageUrl, { responseType: "arraybuffer" }); |
| 380 | const imagePath = path.join(TEMP_DIR, "speedtest.png"); |
| 381 | const filledImagePath = path.join(TEMP_DIR, "speedtest_filled.png"); |
| 382 | fs.writeFileSync(imagePath, response.data); |
| 383 | |