This commit is contained in:
Nadim Kobeissi 2024-09-24 20:53:50 +02:00
parent 8652de12e3
commit 4df0457ab1

View file

@ -6,6 +6,9 @@ const path = require(`path`);
async function main() { async function main() {
const url = 'https://storage.googleapis.com/panels-api/data/20240916/media-1a-i-p~s'; const url = 'https://storage.googleapis.com/panels-api/data/20240916/media-1a-i-p~s';
const delay = (ms) => {
return new Promise(resolve => setTimeout(resolve, ms));
}
try { try {
const response = await fetch(url); const response = await fetch(url);
if (!response.ok) { if (!response.ok) {
@ -22,9 +25,6 @@ async function main() {
console.info(`📁 Created directory: ${downloadDir}`); console.info(`📁 Created directory: ${downloadDir}`);
} }
let fileIndex = 1; let fileIndex = 1;
function delay(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
for (const key in data) { for (const key in data) {
const subproperty = data[key]; const subproperty = data[key];
if (subproperty && subproperty.dhd) { if (subproperty && subproperty.dhd) {
@ -52,7 +52,6 @@ async function downloadImage(url, filePath) {
} }
const arrayBuffer = await response.arrayBuffer(); const arrayBuffer = await response.arrayBuffer();
const buffer = Buffer.from(arrayBuffer); const buffer = Buffer.from(arrayBuffer);
await fs.promises.writeFile(filePath, buffer); await fs.promises.writeFile(filePath, buffer);
} }