[scraper] handles torrent files from object without index

This commit is contained in:
TheBeastLT
2020-12-27 20:04:56 +01:00
parent 0004fbcd9f
commit 21072dc4d7
2 changed files with 10 additions and 1 deletions

View File

@@ -130,6 +130,9 @@ function filesAndSizeFromTorrentStream(torrent, timeout = 30000) {
}
function filterVideos(files) {
if (files.length === 1 && !Number.isInteger(files[0].fileIndex)) {
return files;
}
const videos = files.filter(file => isVideo(file.path));
const maxSize = Math.max(...videos.map(video => video.size));
const minSampleRatio = videos.length <= 3 ? 5 : 10;

View File

@@ -71,7 +71,13 @@ async function reapplyEpisodeDecomposing(infoHash, includeSourceFiles = true) {
const kitsuId = undefined;
const imdbId = kitsuId
? undefined
: mostCommonValue(storedFiles.map(file => file.imdbId)) || await getImdbId(parse(torrent.title));
: mostCommonValue(storedFiles.map(file => file.imdbId))
|| await getImdbId(parse(torrent.title)).catch(() => undefined);
if (!imdbId && !kitsuId) {
console.log(`imdbId or kitsuId not found: ${torrent.provider} ${torrent.title}`);
return Promise.resolve();
}
return parseTorrentFiles({ ...torrent.get(), imdbId, kitsuId, files })
.then(torrentContents => torrentContents.videos)