mirror of
https://github.com/nadimkobeissi/mkbsd.git
synced 2025-04-20 16:16: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);
|
||||
console.info(`📁 Created directory: ${downloadDir}`);
|
||||
}
|
||||
let fileIndex = 1;
|
||||
|
||||
for (const key in data) {
|
||||
const subproperty = data[key];
|
||||
if (subproperty && subproperty.dhd) {
|
||||
const imageUrl = subproperty.dhd;
|
||||
console.info(`🔍 Found image URL!`);
|
||||
await delay(100);
|
||||
const ext = path.extname(new URL(imageUrl).pathname) || '.jpg';
|
||||
const filename = `${fileIndex}${ext}`;
|
||||
// Extract the actual filename from the URL
|
||||
const filename = path.basename(new URL(imageUrl).pathname);
|
||||
const filePath = path.join(downloadDir, filename);
|
||||
await downloadImage(imageUrl, filePath);
|
||||
console.info(`🖼️ Saved image to ${filePath}`);
|
||||
fileIndex++;
|
||||
await delay(250);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue