Slightly improve program output
Most notably reduce the number of output lines per chapter in the download step.
This commit is contained in:
parent
0be098ff16
commit
d5f3b58f0b
3 changed files with 4 additions and 7 deletions
|
|
@ -39,13 +39,11 @@ async function downloadAllChapters(manifest, startChapterURL, cachePath, manifes
|
|||
while (currentChapter !== null) {
|
||||
const filename = `${FILENAME_PREFIX}${chapterIndex.toString().padStart(3, "0")}.html`;
|
||||
|
||||
console.log(`Downloading ${currentChapter}`);
|
||||
process.stdout.write(`Downloading ${currentChapter}... `);
|
||||
|
||||
const response = await downloadChapter(currentChapter);
|
||||
const contents = await response.text();
|
||||
console.log("- Response body received");
|
||||
const rawChapterJSDOM = new JSDOM(contents, { url: currentChapter });
|
||||
console.log("- Response body parsed into DOM");
|
||||
|
||||
const chapterURLToSave = currentChapter;
|
||||
const chapterTitle = getChapterTitle(rawChapterJSDOM.window.document);
|
||||
|
|
@ -61,12 +59,11 @@ async function downloadAllChapters(manifest, startChapterURL, cachePath, manifes
|
|||
});
|
||||
|
||||
await fs.writeFile(path.resolve(cachePath, filename), contents);
|
||||
console.log("- Response text saved to cache file");
|
||||
|
||||
// Incrementally update the manifest after every successful download, instead of waiting until the end.
|
||||
const newManifestContents = JSON.stringify(manifest, undefined, 2);
|
||||
await fs.writeFile(manifestPath, newManifestContents);
|
||||
console.log("- Manifest updated");
|
||||
process.stdout.write("done\n");
|
||||
|
||||
++chapterIndex;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@ module.exports = async (scaffoldingPath, coverPath, bookPath, contentPath, chapt
|
|||
]);
|
||||
})
|
||||
]);
|
||||
|
||||
console.log(`EPUB contents assembled into ${scaffoldingPath}`);
|
||||
};
|
||||
|
||||
function noThumbs(filePath) {
|
||||
|
|
|
|||
|
|
@ -110,8 +110,6 @@ if (argv._.includes("zip")) {
|
|||
for (const command of commands) {
|
||||
await command();
|
||||
}
|
||||
|
||||
console.log("All done!");
|
||||
} catch (e) {
|
||||
console.error(e.stack);
|
||||
process.exit(1);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue