From 76634605ebb6e9448ee9fd179cc5afc693574b50 Mon Sep 17 00:00:00 2001 From: zakary <123845855+zakkarry@users.noreply.github.com> Date: Sun, 24 Sep 2023 20:02:16 -0500 Subject: [PATCH] feat(option): fixes for `includeSeasonPackEpisodes` following changes for includeSeasonPackEpisodes - defaults includeSeasonPackEpisodes to includeEpisodes value to maintain current behavior when undefined - update isSeasonPack naming to isSeasonPackEpisodes - change ternary for isSeasonPackEpisode to use truthy - move searchee.files.length === 1 check from season pack episode "if" to initialization of isSeasonPackEpisode --- src/cmd.ts | 2 +- src/preFilter.ts | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cmd.ts b/src/cmd.ts index b6cf8c3ae..c93b290b7 100755 --- a/src/cmd.ts +++ b/src/cmd.ts @@ -140,7 +140,7 @@ function createCommandWithSharedOptions(name, description) { .option( "--include-season-pack-episodes", "Include episodes from a season pack in the search", - fallback(fileConfig.includeSeasonPackEpisodes, false) + fallback(fileConfig.includeSeasonPackEpisodes, fileConfig.includeEpisodes) ) .option( "--no-include-non-videos", diff --git a/src/preFilter.ts b/src/preFilter.ts index de8419974..84248fc34 100644 --- a/src/preFilter.ts +++ b/src/preFilter.ts @@ -20,14 +20,14 @@ export function filterByContent(searchee: Searchee): boolean { } const isSingleEpisodeTorrent = searchee.files.length === 1 && EP_REGEX.test(searchee.name); - const isSeasonPack = typeof searchee.path !== 'undefined' ? SEASON_REGEX.test(path.dirname(searchee.path).split(path.sep).reverse()[0]): false; - - if (!includeEpisodes && isSingleEpisodeTorrent && !isSeasonPack) { + const isSeasonPackEpisode = searchee.path && searchee.files.length === 1 && SEASON_REGEX.test(path.basename(path.dirname(searchee.path))); + + if (!includeEpisodes && isSingleEpisodeTorrent && !isSeasonPackEpisode) { logReason("it is a single episode"); return false; } - if (!includeSeasonPackEpisodes && (searchee.files.length === 1 && isSeasonPack)) { + if (!includeSeasonPackEpisodes && isSeasonPackEpisode) { logReason("it is a season pack episode"); return false; }