diff --git a/.gitignore b/.gitignore index 4579be9..c89f8f8 100644 --- a/.gitignore +++ b/.gitignore @@ -108,6 +108,7 @@ dist # ignore for now test.js -# local development folders +# local development folders & files ODD Scans/ +out.txt diff --git a/README.md b/README.md index de6fba7..afed71f 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ indexer.scanUrl(url) | Wrapper Version | Supported ODD Versions (up to) | Included Version | | --- | --- | --- | -| **6.0.0** | **2.1.0.0** | **2.1.0.0** | +| **6.1.0** | **2.1.0.0** | **2.1.0.0** | | 5.1.0 | 2.0.0.6 | 2.0.0.3 | | 5.0.0 | 2.0.0.2 | 2.0.0.0 | | 4.0.3 | 1.9.6.1 | 1.9.6.1 | diff --git a/open-directory-downloader.js b/open-directory-downloader.js index 0eb9f0f..87e4f1a 100644 --- a/open-directory-downloader.js +++ b/open-directory-downloader.js @@ -198,11 +198,17 @@ module.exports.OpenDirectoryDownloader = class OpenDirectoryDownloader { // console.log(`finalResults:`, finalResults); - const redditOutputRegExp = /Saved URL list.*\r\nHttp status codes\r\n(?:.|\r\n)*?(^\|\*\*(?:.|\r\n)*?)\r\n\^\(Created by.*?\)\r\n\r\n/m + const redditOutputRegExp = options.performSpeedtest ? + /Finished speedtest.*\r\nHttp status codes\r\n(?:.|\r\n)*?(^\|\*\*(?:.|\r\n)*?)\r\n\^\(Created by.*?\)\r\n\r\n/m : + /Saved URL list.*\r\nHttp status codes\r\n(?:.|\r\n)*?(^\|\*\*(?:.|\r\n)*?)\r\n\^\(Created by.*?\)\r\n\r\n/m const redditOutputEndRegExp = /\^\(Created by \[KoalaBear84\'s OpenDirectory Indexer v.*?\]\(https:\/\/github\.com\/KoalaBear84\/OpenDirectoryDownloader\/\)\)/; const credits = transcriber.output.match(redditOutputEndRegExp)[0] - let redditOutput = finalResults.match(redditOutputRegExp)[1] + if (!redditOutputRegExp.test(finalResults)) { + return reject([new ODDWrapperError(`Failed to parse ODD output!`)]) + } + let redditOutput = `|**Url` + finalResults.match(redditOutputRegExp)[1] + .split('|**Url').filter(Boolean).slice(-1)[0] // make sure there's only a single table let missingFileSizes = redditOutput.includes(`**Total:** n/a`) @@ -321,6 +327,7 @@ class OutputTranscriber extends EventEmitter { this.stdinStream = stdin this.stdinStream.setEncoding(`utf8`) + this.stdinStream.on('error', (err) => {}) // handle errors to prevent crashing this.stdinStreamIntervalId = setInterval(() => { this.stdinStream.write(`s`); // input `S` to trigger ODD stats output }, this.options.statsInterval * 1000); diff --git a/package-lock.json b/package-lock.json index 782a3dd..b9f63d7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "open-directory-downloader", - "version": "6.0.0", + "version": "6.1.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 799f93e..825c220 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "open-directory-downloader", - "version": "6.0.0", + "version": "6.1.0", "description": "A NodeJS wrapper around KoalaBear84/OpenDirectoryDownloader", "main": "open-directory-downloader.js", "scripts": {