mirror of
https://github.com/knightcrawler-stremio/knightcrawler.git
synced 2024-12-20 03:29:51 +00:00
stores files without found episode
This commit is contained in:
@@ -86,9 +86,6 @@ async function filesFromTorrentStream(torrent) {
|
||||
if (!torrent.infoHash && !torrent.magnetLink) {
|
||||
return Promise.reject(new Error("no infoHash or magnetLink"));
|
||||
}
|
||||
if (torrent.seeders === 0) {
|
||||
return Promise.reject(new Error("no seeders for the torrent"));
|
||||
}
|
||||
return new Promise((resolve, rejected) => {
|
||||
const engine = new torrentStream(torrent.magnetLink || torrent.infoHash, { connections: MAX_PEER_CONNECTIONS });
|
||||
|
||||
@@ -125,8 +122,8 @@ function filterSamples(files) {
|
||||
}
|
||||
|
||||
function filterExtras(files) {
|
||||
const isSample = file => file.path.match(/extras?\//i);
|
||||
return files.filter(file => !isSample(file));
|
||||
const isExtra = file => file.path.match(/extras?\//i);
|
||||
return files.filter(file => !isExtra(file));
|
||||
}
|
||||
|
||||
function dynamicTimeout(torrent) {
|
||||
|
||||
@@ -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()];
|
||||
|
||||
Reference in New Issue
Block a user