Skip to content

Commit

Permalink
feat!: consolidate '--list' and '--list-format'
Browse files Browse the repository at this point in the history
  • Loading branch information
lightpohl committed Aug 13, 2021
1 parent 551c0a8 commit ce47051
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 37 deletions.
53 changes: 27 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,35 +22,36 @@

## Options

| Option | Type | Required | Description |
| ----------------------- | -------------------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| --url | String | true | URL to podcast RSS feed. |
| --out-dir | String | false | Specify output directory for episodes and metadata. Defaults to "./{{podcast_title}}". See "Templating" for more details. |
| --archive | String | false | Download or write out items not listed in archive file. Generates archive file at path if not found. Defaults to "./{{podcast_title}}/archive.json". See "Templating" for more details. |
| --episode-template | String | false | Template for generating episode related filenames. See "Templating" for details. |
| --include-meta | | false | Write out podcast metadata to JSON. |
| --include-episode-meta | | false | Write out individual episode metadata to JSON. |
| --ignore-episode-images | | false | Ignore downloading found images from --include-episode-meta. |
| --offset | Number | false | Offset starting download position. Default is 0. |
| --limit | Number | false | Max number of episodes to download. Downloads all by default. |
| --list-format | String ("table" \| "json") | false | How to structure list data when logged. Default is "table". |
| --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. |
| --add-mp3-metadata | | false | Attempts to add a base level of MP3 metadata to each episode. Recommended only in cases where the original metadata is of poor quality. (**ffmpeg required**) |
| --adjust-bitrate | String (e.g. "48k") | false | Attempts to adjust bitrate of MP3s. (**ffmpeg required**) |
| --mono | | false | Attempts to force MP3s into mono. (**ffmpeg required**) |
| --override | | false | Override local files on collision. |
| --reverse | | false | Reverse download direction and start at last RSS item. |
| --info | | false | Print retrieved podcast info instead of downloading. |
| --list | | false | Print episode list instead of downloading. |
| --exec | String | false | Execute a command after each episode is downloaded. |
| --version | | false | Output the version number. |
| --help | | false | Output usage information. |
**Type values surrounded in square brackets `[]` can be used as used as boolean options (no argument required).**

| Option | Type | Required | Description |
| ----------------------- | ------------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| --url | String | true | URL to podcast RSS feed. |
| --out-dir | String | false | Specify output directory for episodes and metadata. Defaults to "./{{podcast_title}}". See "Templating" for more details. |
| --archive | [String] | false | Download or write out items not listed in archive file. Generates archive file at path if not found. Defaults to "./{{podcast_title}}/archive.json" when used as a boolean option. See "Templating" for more details. |
| --episode-template | String | false | Template for generating episode related filenames. See "Templating" for details. |
| --include-meta | | false | Write out podcast metadata to JSON. |
| --include-episode-meta | | false | Write out individual episode metadata to JSON. |
| --ignore-episode-images | | false | Ignore downloading found images from --include-episode-meta. |
| --offset | Number | false | Offset starting download position. Default is 0. |
| --limit | Number | false | Max number of episodes to download. Downloads all by default. |
| --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. |
| --add-mp3-metadata | | false | Attempts to add a base level of MP3 metadata to each episode. Recommended only in cases where the original metadata is of poor quality. (**ffmpeg required**) |
| --adjust-bitrate | String (e.g. "48k") | false | Attempts to adjust bitrate of MP3s. (**ffmpeg required**) |
| --mono | | false | Attempts to force MP3s into mono. (**ffmpeg required**) |
| --override | | false | Override local files on collision. |
| --reverse | | false | Reverse download direction and start at last RSS item. |
| --info | | false | Print retrieved podcast info instead of downloading. |
| --list | [String] | false | Print episode list instead of downloading. May optionally be passed "table" or "json" to specify output type. |
| --exec | String | false | Execute a command after each episode is downloaded. |
| --version | | false | Output the version number. |
| --help | | false | Output usage information. |

## Archive

- If passed the `--archive <path>` option, `podcast-dl` will generate/use a JSON archive at the provided path.
- If passed the `--archive [path]` option, `podcast-dl` will generate/use a JSON archive at the provided path.
- Before downloading an episode or writing out metadata, it'll check if the item was saved previously and abort the save if found.

## Templating
Expand Down
18 changes: 7 additions & 11 deletions bin/bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,25 +95,21 @@ commander
.option("--override", "override local files on collision")
.option("--reverse", "download episodes in reverse order")
.option("--info", "print retrieved podcast info instead of downloading")
.option("--list", "print episode info instead of downloading")
.option(
"--list-format <table|json>",
"how to structure list data when logged",
"--list [table|json]",
"print episode info instead of downloading",
(value) => {
if (!value) {
return undefined;
}

if (
value !== ITEM_LIST_FORMATS.table &&
value !== ITEM_LIST_FORMATS.json
) {
logErrorAndExit(`${value} is an invalid format for --list`);
logErrorAndExit(
`${value} is an invalid format for --list\nUse "table" or "json"`
);
}

return value;
},
"table"
}
)
.option(
"--exec <string>",
Expand All @@ -137,7 +133,6 @@ const {
reverse,
info,
list,
listFormat,
exec,
mono,
addMp3Metadata: addMp3MetadataFlag,
Expand Down Expand Up @@ -165,6 +160,7 @@ const main = async () => {

if (list) {
if (feed.items && feed.items.length) {
const listFormat = typeof list === "boolean" ? "table" : list;
logItemsList({
type: listFormat,
feed,
Expand Down

0 comments on commit ce47051

Please sign in to comment.