Skip to content

Commit

Permalink
feat(option): fixes for includeSeasonPackEpisodes
Browse files Browse the repository at this point in the history
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
  • Loading branch information
zakkarry authored and mmgoodnow committed Sep 25, 2023
1 parent c03e331 commit 7663460
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/cmd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 4 additions & 4 deletions src/preFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 7663460

Please sign in to comment.