diff --git a/README.md b/README.md index d47cd4e..bd33e7c 100644 --- a/README.md +++ b/README.md @@ -4,22 +4,24 @@ This is a node script extracting E-Books from Amazon Kindle Cloud Reader. Useful e.g. for being able to read on devices where the Cloud Reader doesn't work and for having a copy in an open format. Works with Chrome/Chromium. Other browsers use different formats for the WebSQL file where the E-Books are stored for offline use. -Code is from this gists: +Antecedents: - * 1: https://gist.github.com/yangchenyun/a1c123935d82f5e25d57 - * 2: https://gist.github.com/moodule/84140e557065ac3d73f669f120429ae1 +1. https://gist.github.com/yangchenyun/a1c123935d82f5e25d57 +2. https://gist.github.com/moodule/84140e557065ac3d73f669f120429ae1 +3. https://github.com/d10r/kindle-fetch -I have just added minor usability improvements (e.g. cmdline switch for input file selection) and a package.json file. +`d10r` added minor usability improvements (e.g. cmdline switch for input file selection) and a package.json file. + +I have just updated it to cope with newer versions of Node. ## Usage -This was successfully tested with nodejs v6 and v8 (will print ugly warnings with v8). -Doesn't work for me with nodejs v10 (and reportedly also not with v11). +This was successfully tested with Node v13. -
+``` npm install ./main.js --help -+``` This generates HTML files with the book content in the directory you're in. diff --git a/main.js b/main.js index b2699d4..ba904eb 100755 --- a/main.js +++ b/main.js @@ -289,8 +289,10 @@ db.all("select metadata from 'bookinfo'", function(err, rows) { //var HtmlFile = path.join(os.tmpdir(), title.replace(/\s+/g, '-') + '.html'); var HtmlFile = title.replace(/\s+/g, '-') + '.html'; - fs.writeFile(HtmlFile, HtmlHeader); - console.log("created the file with HTML headers."); + fs.writeFile(HtmlFile, HtmlHeader, (err) => { + if (err) throw err; + console.log("created the file with HTML headers."); + }); db.all("select id, piece, other from 'fragments' where asin='" + asin + "' order by id", function(err, rows) { rows.forEach(function (row) { @@ -309,11 +311,15 @@ db.all("select metadata from 'bookinfo'", function(err, rows) { 'dataUrl="' + image + '"', 'src="' + imageDataMap[image] + '"'); } - fs.appendFile(HtmlFile, uncompressedFragmentData); + fs.appendFile(HtmlFile, uncompressedFragmentData, (err) => { + if (err) throw err; + }); }); }); - fs.appendFile(HtmlFile, '