Skip to content

Commit

Permalink
feat: add 'episode-regex-exclude' option
Browse files Browse the repository at this point in the history
closes #91
  • Loading branch information
lightpohl committed Dec 5, 2024
1 parent 4a442fb commit 553c799
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Type values surrounded in square brackets (`[]`) can be used as used as boolean
| --after | String | false | Only download episodes after this date (i.e. MM/DD/YYY, inclusive). |
| --before | String | false | Only download episodes before this date (i.e. MM/DD/YYY, inclusive) |
| --episode-regex | String | false | Match episode title against provided regex before starting download. |
| --episode-regex-exclude | String | false | Matched episode titles against provided regex will be excluded. |
| --episode-digits | Number | false | Minimum number of digits to use for episode numbering (e.g. 3 would generate "001" instead of "1"). Default is 0. |
| --episode-num-offset | Number | false | Offset the acquired episode number. Default is 0. |
| --episode-source-order | String | false | Attempted order to extract episode audio URL from RSS feed. Default is "enclosure,link". |
Expand Down
3 changes: 3 additions & 0 deletions bin/bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const {
episodeDigits,
episodeNumOffset,
episodeRegex,
episodeRegexExclude,
episodeSourceOrder,
episodeTemplate,
episodeCustomTemplateOptions,
Expand Down Expand Up @@ -114,6 +115,7 @@ const main = async () => {
after,
before,
episodeRegex,
episodeRegexExclude,
});
} else {
logErrorAndExit("No episodes found to list");
Expand Down Expand Up @@ -219,6 +221,7 @@ const main = async () => {
episodeDigits,
episodeNumOffset,
episodeRegex,
episodeRegexExclude,
episodeSourceOrder,
episodeTemplate,
episodeCustomTemplateOptions,
Expand Down
4 changes: 4 additions & 0 deletions bin/commander.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ export const setupCommander = (program) => {
"--episode-regex <string>",
"match episode title against regex before downloading"
)
.option(
"--episode-regex-exclude <string>",
"matched episode titles against regex will be excluded"
)
.option(
"--after <string>",
"download episodes only after this date (inclusive)"
Expand Down
10 changes: 10 additions & 0 deletions bin/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ const getItemsToDownload = ({
episodeDigits,
episodeNumOffset,
episodeRegex,
episodeRegexExclude,
episodeSourceOrder,
episodeTemplate,
episodeCustomTemplateOptions,
Expand Down Expand Up @@ -196,6 +197,13 @@ const getItemsToDownload = ({
}
}

if (episodeRegexExclude) {
const generatedEpisodeRegexExclude = new RegExp(episodeRegexExclude);
if (title && generatedEpisodeRegexExclude.test(title)) {
isValid = false;
}
}

if (before) {
const beforeDateDay = dayjs(new Date(before));
if (
Expand Down Expand Up @@ -336,6 +344,7 @@ const logItemsList = ({
before,
after,
episodeRegex,
episodeRegexExclude,
}) => {
const items = getItemsToDownload({
feed,
Expand All @@ -345,6 +354,7 @@ const logItemsList = ({
before,
after,
episodeRegex,
episodeRegexExclude,
});

if (!items.length) {
Expand Down

0 comments on commit 553c799

Please sign in to comment.