Skip to content

Commit

Permalink
Make the dir through Bun.write, and await the ffmpeg requests
Browse files Browse the repository at this point in the history
  • Loading branch information
NightScript370 committed Apr 4, 2024
1 parent 056c44d commit 298a036
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions bun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,6 @@ for (const folder of await readdir("pages", { withFileTypes: true })) {
}))
}), accessURL);

const imagePath = `nitrofiles/pages/${rootPath}.gif`
if (await needsUpdate(imagePath, `pages/${dir}/${page}`)) {
await tab.screenshot({ path: tempFileNames.screenshot, clip: { x: 0, y: 0, width: 256, height: pageEval.height } });

$`ffmpeg -i ${tempFileNames.screenshot} -vf palettegen=max_colors=246 ${tempFileNames.palette} -y -loglevel error`;
$`ffmpeg -i ${tempFileNames.screenshot} -i ${tempFileNames.palette} -filter_complex paletteuse ${imagePath} -y -loglevel error`;
}

if (await needsUpdate(`nitrofiles/pages/${rootPath}.ini`, `pages/${dir}/${page}`)) {
let iniContent = dedent(`
[INFO]
Expand All @@ -99,6 +91,14 @@ for (const folder of await readdir("pages", { withFileTypes: true })) {
iniContent += iniLinks.join('\n\n')
await Bun.write(`nitrofiles/pages/${rootPath}.ini`, iniContent.trim());
}

const imagePath = `nitrofiles/pages/${rootPath}.gif`
if (await needsUpdate(imagePath, `pages/${dir}/${page}`)) {
await tab.screenshot({ path: tempFileNames.screenshot, clip: { x: 0, y: 0, width: 256, height: pageEval.height } });

await $`ffmpeg -i ${tempFileNames.screenshot} -vf palettegen=max_colors=246 ${tempFileNames.palette} -y -loglevel error`;
await $`ffmpeg -i ${tempFileNames.screenshot} -i ${tempFileNames.palette} -filter_complex paletteuse ${imagePath} -y -loglevel error`;
}
}
}

Expand Down

0 comments on commit 298a036

Please sign in to comment.