mirror of
https://github.com/nadimkobeissi/mkbsd.git
synced 2025-04-21 06:06:34 -04:00
using image names instead of index
This commit is contained in:
parent
6c6add0f1e
commit
64c99e8e6f
1 changed files with 3 additions and 4 deletions
7
mkbsd.js
7
mkbsd.js
|
@ -24,19 +24,18 @@ async function main() {
|
||||||
fs.mkdirSync(downloadDir);
|
fs.mkdirSync(downloadDir);
|
||||||
console.info(`📁 Created directory: ${downloadDir}`);
|
console.info(`📁 Created directory: ${downloadDir}`);
|
||||||
}
|
}
|
||||||
let fileIndex = 1;
|
|
||||||
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) {
|
||||||
const imageUrl = subproperty.dhd;
|
const imageUrl = subproperty.dhd;
|
||||||
console.info(`🔍 Found image URL!`);
|
console.info(`🔍 Found image URL!`);
|
||||||
await delay(100);
|
await delay(100);
|
||||||
const ext = path.extname(new URL(imageUrl).pathname) || '.jpg';
|
// Extract the actual filename from the URL
|
||||||
const filename = `${fileIndex}${ext}`;
|
const filename = path.basename(new URL(imageUrl).pathname);
|
||||||
const filePath = path.join(downloadDir, filename);
|
const filePath = path.join(downloadDir, filename);
|
||||||
await downloadImage(imageUrl, filePath);
|
await downloadImage(imageUrl, filePath);
|
||||||
console.info(`🖼️ Saved image to ${filePath}`);
|
console.info(`🖼️ Saved image to ${filePath}`);
|
||||||
fileIndex++;
|
|
||||||
await delay(250);
|
await delay(250);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue