stores files without found episode

This commit is contained in:
TheBeastLT
2020-03-01 15:31:30 +01:00
parent 149b24fbf0
commit 1170159f59
4 changed files with 23 additions and 15 deletions

View File

@@ -52,7 +52,7 @@ async function parseTorrentFiles(torrent) {
.then((files) => assignKitsuOrImdbEpisodes(files, metadata))
.then((files) => Promise.all(files.map(file => file.isMovie
? mapSeriesMovie(file, torrent)
: mapSeriesEpisode(file, torrent))))
: mapSeriesEpisode(file, torrent, files))))
.then((files) => files.reduce((a, b) => a.concat(b), []))
.catch((error) => {
console.log(`Failed getting files for ${torrent.title}`, error.message);
@@ -72,8 +72,17 @@ async function getSeriesFiles(torrent, parsedTorrentName) {
return torrentFiles(torrent);
}
async function mapSeriesEpisode(file, torrent) {
async function mapSeriesEpisode(file, torrent, files) {
if (!file.episodes && !file.kitsuEpisodes) {
if (files.some(otherFile => otherFile.episodes || otherFile.kitsuEpisodes) || parse(torrent.title).seasons) {
return Promise.resolve({
infoHash: torrent.infoHash,
fileIndex: file.fileIndex,
title: file.path || file.name,
size: file.size,
imdbId: torrent.imdbId || file.imdbId,
});
}
return Promise.resolve([]);
}
const episodeIndexes = [...(file.episodes || file.kitsuEpisodes).keys()];