diff --git a/lib/metadata.js b/lib/metadata.js index 6f9f57d..921e119 100644 --- a/lib/metadata.js +++ b/lib/metadata.js @@ -9,6 +9,10 @@ const KITSU_URL = 'https://anime-kitsu.now.sh'; const TIMEOUT = 20000; function getMetadata(id, type = Type.SERIES) { + if (!id) { + return Promise.reject("no valid id provided"); + } + const key = id.match(/^\d+$/) ? `kitsu:${id}` : id; const metaType = type === Type.MOVIE ? Type.MOVIE : Type.SERIES; return cacheWrapMetadata(key, @@ -86,10 +90,11 @@ async function getImdbId(info) { } }); }).catch(() => bing.web(`${info.name} ${info.year || ''} ${info.type} imdb`) - .then((results) => results + .then(results => results .map((result) => result.link) - .find(result => result.includes('imdb.com/title/')) - .match(/imdb\.com\/title\/(tt\d+)/)[1]))); + .find(result => result.includes('imdb.com/title/'))) + .then(result => result && result.match(/imdb\.com\/title\/(tt\d+)/)) + .then(match => match && match[1]))); } async function getKitsuId(info) { diff --git a/package-lock.json b/package-lock.json index 108b348..d9f7a1a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1714,7 +1714,7 @@ } }, "parse-torrent-title": { - "version": "git://github.com/TheBeastLT/parse-torrent-title.git#91d711a5c3558baced7d20cb5a5458a859ddede6", + "version": "git://github.com/TheBeastLT/parse-torrent-title.git#d6b677ad5e576c9294de1de75c0fd1396bd1ab7b", "from": "git://github.com/TheBeastLT/parse-torrent-title.git#master" }, "parseurl": { diff --git a/scrapers/thepiratebay/thepiratebay_unofficial_dump_scraper.js b/scrapers/thepiratebay/thepiratebay_unofficial_dump_scraper.js index e74d3d8..3892a4c 100644 --- a/scrapers/thepiratebay/thepiratebay_unofficial_dump_scraper.js +++ b/scrapers/thepiratebay/thepiratebay_unofficial_dump_scraper.js @@ -63,7 +63,6 @@ async function scrape() { console.log(err); }); lr.on('end', () => { - fs.unlink(CSV_FILE_PATH); console.log(`finished to scrape tpb dump!`); }); }