do not treat new non indexed episodes as absolute

This commit is contained in:
TheBeastLT
2022-06-02 09:11:00 +03:00
parent b38b635f0b
commit 845c6251f9
2 changed files with 13 additions and 7 deletions

View File

@@ -176,6 +176,10 @@ function getTorrentsBasedOnQuery(where) {
return Torrent.findAll({ where: where }); return Torrent.findAll({ where: where });
} }
function getFilesBasedOnQuery(where) {
return File.findAll({ where: where });
}
function getTorrentsWithoutSize() { function getTorrentsWithoutSize() {
return Torrent.findAll({ return Torrent.findAll({
where: literal( where: literal(
@@ -325,6 +329,7 @@ module.exports = {
getTorrent, getTorrent,
getTorrentsBasedOnTitle, getTorrentsBasedOnTitle,
getTorrentsBasedOnQuery, getTorrentsBasedOnQuery,
getFilesBasedOnQuery,
deleteTorrent, deleteTorrent,
getUpdateSeedersTorrents, getUpdateSeedersTorrents,
getUpdateSeedersNewTorrents, getUpdateSeedersNewTorrents,

View File

@@ -247,18 +247,18 @@ function isAbsoluteEpisodeFiles(torrent, files, metadata) {
.filter(file => file.episodes.every(ep => metadata.episodeCount[file.season - 1] < ep)) .filter(file => file.episodes.every(ep => metadata.episodeCount[file.season - 1] < ep))
return nonMovieEpisodes.every(file => !file.season) return nonMovieEpisodes.every(file => !file.season)
|| (isAnime && nonMovieEpisodes.every(file => file.season > metadata.episodeCount.length)) || (isAnime && nonMovieEpisodes.every(file => file.season > metadata.episodeCount.length))
|| absoluteEpisodes.length >= threshold || absoluteEpisodes.length >= threshold;
// && !isNewEpisodesNotInMetadata(files, metadata);
} }
function isNewEpisodesNotInMetadata(files, metadata) { function isNewEpisodeNotInMetadata(torrent, file, metadata) {
// new episode might not yet been indexed by cinemeta. // new episode might not yet been indexed by cinemeta.
// detect this if episode number is larger than the last episode or season is larger than the last one // detect this if episode number is larger than the last episode or season is larger than the last one
return files.length === 1 // only for non anime metas
const isAnime = torrent.type === Type.ANIME && torrent.kitsuId;
return !isAnime && !file.isMovie && file.episodes && file.season !== 1
&& /continuing|current/i.test(metadata.status) && /continuing|current/i.test(metadata.status)
&& files.filter(file => !file.isMovie && file.episodes) && file.season >= metadata.episodeCount.length
.every(file => file.season >= metadata.episodeCount.length && file.episodes.every(ep => ep > (metadata.episodeCount[file.season - 1] || 0));
&& file.episodes.every(ep => ep > metadata.episodeCount[file.season - 1]))
} }
function decomposeConcatSeasonAndEpisodeFiles(torrent, files, metadata) { function decomposeConcatSeasonAndEpisodeFiles(torrent, files, metadata) {
@@ -284,6 +284,7 @@ function decomposeAbsoluteEpisodeFiles(torrent, files, metadata) {
} }
files files
.filter(file => file.episodes && !file.isMovie && file.season !== 0) .filter(file => file.episodes && !file.isMovie && file.season !== 0)
.filter(file => !isNewEpisodeNotInMetadata(torrent, file, metadata))
.filter(file => !file.season || (metadata.episodeCount[file.season - 1] || 0) < file.episodes[0]) .filter(file => !file.season || (metadata.episodeCount[file.season - 1] || 0) < file.episodes[0])
.forEach(file => { .forEach(file => {
const seasonIdx = ([...metadata.episodeCount.keys()] const seasonIdx = ([...metadata.episodeCount.keys()]