mirror of
https://github.com/knightcrawler-stremio/knightcrawler.git
synced 2024-12-20 03:29:51 +00:00
adds manual reapply step to decompose episodes again
This commit is contained in:
@@ -35,7 +35,8 @@ module.exports.updateCurrentSeeders = function (torrent) {
|
||||
};
|
||||
|
||||
module.exports.torrentFiles = function (torrent) {
|
||||
return filesFromTorrentFile(torrent)
|
||||
return getFilesFromObject(torrent)
|
||||
.catch(() => filesFromTorrentFile(torrent))
|
||||
.catch(() => filesFromTorrentStream(torrent))
|
||||
.catch(() => filesFromCache(torrent.infoHash))
|
||||
.then((files) => filterVideos(files))
|
||||
@@ -43,6 +44,13 @@ module.exports.torrentFiles = function (torrent) {
|
||||
.then((files) => filterExtras(files));
|
||||
};
|
||||
|
||||
function getFilesFromObject(torrent) {
|
||||
if (torrent.files && torrent.files.length) {
|
||||
return Promise.resolve(torrent.files);
|
||||
}
|
||||
return Promise.reject("No files in the object");
|
||||
}
|
||||
|
||||
function filesFromCache(infoHash) {
|
||||
return retrieveTorrentFiles(infoHash)
|
||||
.then((files) => files.map((file) => ({
|
||||
|
||||
@@ -138,8 +138,9 @@ async function decomposeEpisodes(torrent, files, metadata = { episodeCount: [] }
|
||||
&& sortedEpisodes.every(ep => metadata.episodeCount[div100(ep) - 1] >= mod100(ep))
|
||||
&& files.every(file => !file.season || file.episodes.every(ep => div100(ep) === file.season))) {
|
||||
decomposeConcatSeasonAndEpisodeFiles(torrent, files, metadata);
|
||||
} else if ((files.every(file => !file.season && file.episodes) || files.some(file => file.season && file.episodes
|
||||
&& file.episodes.every(ep => metadata.episodeCount[file.season - 1] < ep)))
|
||||
} else if ((files.filter(file => !file.isMovie && file.episodes).every(file => !file.season && file.episodes) ||
|
||||
files.some(file => file.season && file.episodes && file.episodes
|
||||
.every(ep => metadata.episodeCount[file.season - 1] < ep)))
|
||||
&& (sortedEpisodes.length <= 1 || sortedEpisodes.slice(1).every((ep, i) => ep - sortedEpisodes[i] <= 2))) {
|
||||
decomposeAbsoluteEpisodeFiles(torrent, files, metadata);
|
||||
} else if (files.every(file => (!file.season || !metadata.episodeCount[file.season - 1]) && file.date)) {
|
||||
|
||||
Reference in New Issue
Block a user