podcast-dl 11.1.1 → 11.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +121 -120
- package/bin/archive.js +39 -39
- package/bin/async.js +370 -370
- package/bin/bin.js +292 -289
- package/bin/commander.js +198 -193
- package/bin/exec.js +30 -30
- package/bin/ffmpeg.js +105 -105
- package/bin/items.js +247 -237
- package/bin/logger.js +84 -84
- package/bin/meta.js +66 -66
- package/bin/naming.js +112 -112
- package/bin/util.js +299 -299
- package/bin/validate.js +39 -39
- package/package.json +62 -62
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2020 Joshua Pohl
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 Joshua Pohl
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,120 +1,121 @@
|
|
|
1
|
-
# podcast-dl
|
|
2
|
-
|
|
3
|
-
A humble CLI for downloading and archiving podcasts.
|
|
4
|
-
|
|
5
|
-
## How to Use
|
|
6
|
-
|
|
7
|
-
### npx
|
|
8
|
-
|
|
9
|
-
**[Node Required](https://nodejs.org/en/)**
|
|
10
|
-
|
|
11
|
-
`npx podcast-dl --url <PODCAST_RSS_URL>`
|
|
12
|
-
|
|
13
|
-
### Binaries
|
|
14
|
-
|
|
15
|
-
[Visit the releases page](https://github.com/lightpohl/podcast-dl/releases) and download the latest binary for your system.
|
|
16
|
-
|
|
17
|
-
`podcast-dl --url <PODCAST_RSS_URL>`
|
|
18
|
-
|
|
19
|
-
### [More Examples](./docs/examples.md)
|
|
20
|
-
|
|
21
|
-
## Options
|
|
22
|
-
|
|
23
|
-
Either `--url` or `--file` must be provided.
|
|
24
|
-
|
|
25
|
-
Type values surrounded in square brackets (`[]`) can be used as used as boolean options (no argument required).
|
|
26
|
-
|
|
27
|
-
| Option | Type | Required | Description |
|
|
28
|
-
| --------------------------------- | ------------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
29
|
-
| --url | String | true\* | URL to podcast RSS feed. |
|
|
30
|
-
| --file | String | true\* | Path to local RSS file. |
|
|
31
|
-
| --out-dir | String | false | Specify output directory for episodes and metadata. Defaults to "./{{podcast_title}}". See "Template Options" for more details. |
|
|
32
|
-
| --threads | Number | false | Determines the number of downloads that will happen concurrently. Default is 1. |
|
|
33
|
-
| --attempts | Number | false | Sets the number of download attempts per individual file. Default is 3. |
|
|
34
|
-
| --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 "Template Options" for more details. |
|
|
35
|
-
| --episode-template | String | false | Template for generating episode related filenames. See "Template Options" for details. |
|
|
36
|
-
| --episode-custom-template-options | <String...> | false | Provide custom options for the episode template. See "Template Options" for details. |
|
|
37
|
-
| --include-meta | | false | Write out podcast metadata to JSON. |
|
|
38
|
-
| --include-episode-meta | | false | Write out individual episode metadata **to** JSON. |
|
|
39
|
-
| --include-episode-images | | false | Download found episode images. |
|
|
40
|
-
| --include-episode-transcripts | | false | Download found episode transcripts. |
|
|
41
|
-
| --offset | Number | false | Offset starting download position. Default is 0. |
|
|
42
|
-
| --limit | Number | false | Max number of episodes to download. Downloads all by default. |
|
|
43
|
-
| --after | String | false | Only download episodes after this date (i.e. MM/DD/YYY, inclusive). |
|
|
44
|
-
| --before | String | false | Only download episodes before this date (i.e. MM/DD/YYY, inclusive) |
|
|
45
|
-
| --episode-regex | String | false | Match episode title against provided regex before starting download. |
|
|
46
|
-
| --episode-regex-exclude | String | false | Matched episode titles against provided regex will be excluded. |
|
|
47
|
-
| --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. |
|
|
48
|
-
| --episode-num-offset | Number | false | Offset the acquired episode number. Default is 0. |
|
|
49
|
-
| --episode-source-order | String | false | Attempted order to extract episode audio URL from RSS feed. Default is "enclosure,link". |
|
|
50
|
-
| --episode-transcript-types | String | false | List of allowed transcript types in preferred order. Default is "application/json,application/x-subrip,application/srr,application/srt,text/vtt,text/html,text/plain". |
|
|
51
|
-
| --
|
|
52
|
-
| --
|
|
53
|
-
| --
|
|
54
|
-
| --
|
|
55
|
-
| --
|
|
56
|
-
| --
|
|
57
|
-
| --
|
|
58
|
-
| --
|
|
59
|
-
| --
|
|
60
|
-
| --
|
|
61
|
-
| --
|
|
62
|
-
| --
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
- `
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
- `
|
|
86
|
-
- `
|
|
87
|
-
- `
|
|
88
|
-
- `
|
|
89
|
-
- `
|
|
90
|
-
- `
|
|
91
|
-
- `
|
|
92
|
-
- `
|
|
93
|
-
- `
|
|
94
|
-
- `
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
- `
|
|
106
|
-
- `
|
|
107
|
-
- `
|
|
108
|
-
- `
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
- `
|
|
116
|
-
- `
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
1
|
+
# podcast-dl
|
|
2
|
+
|
|
3
|
+
A humble CLI for downloading and archiving podcasts.
|
|
4
|
+
|
|
5
|
+
## How to Use
|
|
6
|
+
|
|
7
|
+
### npx
|
|
8
|
+
|
|
9
|
+
**[Node Required](https://nodejs.org/en/)**
|
|
10
|
+
|
|
11
|
+
`npx podcast-dl --url <PODCAST_RSS_URL>`
|
|
12
|
+
|
|
13
|
+
### Binaries
|
|
14
|
+
|
|
15
|
+
[Visit the releases page](https://github.com/lightpohl/podcast-dl/releases) and download the latest binary for your system.
|
|
16
|
+
|
|
17
|
+
`podcast-dl --url <PODCAST_RSS_URL>`
|
|
18
|
+
|
|
19
|
+
### [More Examples](./docs/examples.md)
|
|
20
|
+
|
|
21
|
+
## Options
|
|
22
|
+
|
|
23
|
+
Either `--url` or `--file` must be provided.
|
|
24
|
+
|
|
25
|
+
Type values surrounded in square brackets (`[]`) can be used as used as boolean options (no argument required).
|
|
26
|
+
|
|
27
|
+
| Option | Type | Required | Description |
|
|
28
|
+
| --------------------------------- | ------------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
29
|
+
| --url | String | true\* | URL to podcast RSS feed. |
|
|
30
|
+
| --file | String | true\* | Path to local RSS file. |
|
|
31
|
+
| --out-dir | String | false | Specify output directory for episodes and metadata. Defaults to "./{{podcast_title}}". See "Template Options" for more details. |
|
|
32
|
+
| --threads | Number | false | Determines the number of downloads that will happen concurrently. Default is 1. |
|
|
33
|
+
| --attempts | Number | false | Sets the number of download attempts per individual file. Default is 3. |
|
|
34
|
+
| --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 "Template Options" for more details. |
|
|
35
|
+
| --episode-template | String | false | Template for generating episode related filenames. See "Template Options" for details. |
|
|
36
|
+
| --episode-custom-template-options | <String...> | false | Provide custom options for the episode template. See "Template Options" for details. |
|
|
37
|
+
| --include-meta | | false | Write out podcast metadata to JSON. |
|
|
38
|
+
| --include-episode-meta | | false | Write out individual episode metadata **to** JSON. |
|
|
39
|
+
| --include-episode-images | | false | Download found episode images. |
|
|
40
|
+
| --include-episode-transcripts | | false | Download found episode transcripts. |
|
|
41
|
+
| --offset | Number | false | Offset starting download position. Default is 0. |
|
|
42
|
+
| --limit | Number | false | Max number of episodes to download. Downloads all by default. |
|
|
43
|
+
| --after | String | false | Only download episodes after this date (i.e. MM/DD/YYY, inclusive). |
|
|
44
|
+
| --before | String | false | Only download episodes before this date (i.e. MM/DD/YYY, inclusive) |
|
|
45
|
+
| --episode-regex | String | false | Match episode title against provided regex before starting download. |
|
|
46
|
+
| --episode-regex-exclude | String | false | Matched episode titles against provided regex will be excluded. |
|
|
47
|
+
| --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. |
|
|
48
|
+
| --episode-num-offset | Number | false | Offset the acquired episode number. Default is 0. |
|
|
49
|
+
| --episode-source-order | String | false | Attempted order to extract episode audio URL from RSS feed. Default is "enclosure,link". |
|
|
50
|
+
| --episode-transcript-types | String | false | List of allowed transcript types in preferred order. Default is "application/json,application/x-subrip,application/srr,application/srt,text/vtt,text/html,text/plain". |
|
|
51
|
+
| --season | Number | false | Only download episodes from this season. Note: this will only work if the RSS feed includes the itunes:season tag on episodes. |
|
|
52
|
+
| --add-mp3-metadata | | false | Attempts to add a base level of episode metadata to each episode. Recommended only in cases where the original metadata is of poor quality. (**ffmpeg required**) |
|
|
53
|
+
| --adjust-bitrate | String (e.g. "48k") | false | Attempts to adjust bitrate of episodes. (**ffmpeg required**) |
|
|
54
|
+
| --mono | | false | Attempts to force episodes into mono. (**ffmpeg required**) |
|
|
55
|
+
| --override | | false | Override local files on collision. |
|
|
56
|
+
| --always-postprocess | | false | Always run additional tasks on the file regardless if the file already exists. This includes --add-mp3-metadata, --adjust-bitrate, --mono, and --exec. |
|
|
57
|
+
| --reverse | | false | Reverse download direction and start at last RSS item. |
|
|
58
|
+
| --info | | false | Print retrieved podcast info instead of downloading. |
|
|
59
|
+
| --list | [String] | false | Print episode list instead of downloading. Defaults to "table" when used as a boolean option. "json" is also supported. |
|
|
60
|
+
| --exec | String | false | Execute a command after each episode is downloaded. See "Template Options" for more details. |
|
|
61
|
+
| --parser-config | String | false | Path to JSON file that will be parsed and used to override the default config passed to [rss-parser](https://github.com/rbren/rss-parser#xml-options). |
|
|
62
|
+
| --proxy | | false | Enable proxy support. Specify environment variables listed by [global-agent](https://github.com/gajus/global-agent#environment-variables). |
|
|
63
|
+
| --help | | false | Output usage information. |
|
|
64
|
+
|
|
65
|
+
## Archive
|
|
66
|
+
|
|
67
|
+
- If passed the `--archive [path]` option, `podcast-dl` will generate/use a JSON archive at the provided path.
|
|
68
|
+
- Before downloading an episode or writing out metadata, it'll check if the item was saved previously and abort the save if found.
|
|
69
|
+
|
|
70
|
+
## Template Options
|
|
71
|
+
|
|
72
|
+
Options that support templates allow users to specify a template for the generated filename(s) or option. The provided template will replace all matched keywords with the related data described below. Each keyword must be wrapped in two braces like so:
|
|
73
|
+
|
|
74
|
+
`--out-dir "./{{podcast_title}}"`
|
|
75
|
+
|
|
76
|
+
`--episode-template "{{release_date}}-{{title}}"`
|
|
77
|
+
|
|
78
|
+
### `--out-dir` & `--archive`
|
|
79
|
+
|
|
80
|
+
- `podcast_title`: Title of the podcast feed.
|
|
81
|
+
- `podcast_link`: `link` value provided for the podcast feed. Typically the homepage URL.
|
|
82
|
+
|
|
83
|
+
### `--episode-template`
|
|
84
|
+
|
|
85
|
+
- `title`: The title of the episode.
|
|
86
|
+
- `release_date`: The release date of the episode in `YYYYMMDD` format.
|
|
87
|
+
- `release_year`: The release year (`YYYY`) of the episode.
|
|
88
|
+
- `release_month`: The release month (`MM`) of the episode.
|
|
89
|
+
- `release_day`: The release day (`DD`) of the episode.
|
|
90
|
+
- `episode_num`: The location number of where the episodes appears in the feed.
|
|
91
|
+
- `url`: URL of episode audio file.
|
|
92
|
+
- `duration`: Provided `mm:ss` duration (if found).
|
|
93
|
+
- `podcast_title`: Title of the podcast feed.
|
|
94
|
+
- `podcast_link`: `link` value provided for the podcast feed. Typically the homepage URL.
|
|
95
|
+
- `guid`: The GUID of the episode.
|
|
96
|
+
|
|
97
|
+
#### `--episode-custom-template-options`
|
|
98
|
+
|
|
99
|
+
Each matcher provided will be used to extract a value from the episode `title`. Access these values in the template using the `custom_<n>` keyword where `<n>` is the index of the matcher provided (starting from `0`).
|
|
100
|
+
|
|
101
|
+
If no match is found, the `custom_<n>` keyword will be replaced with an empty string.
|
|
102
|
+
|
|
103
|
+
### `--exec`
|
|
104
|
+
|
|
105
|
+
- `episode_path`: The path to the downloaded episode.
|
|
106
|
+
- `episode_path_base`: The path to the folder of the downloaded episode.
|
|
107
|
+
- `episode_filename`: The filename of the episode.
|
|
108
|
+
- `episode_filename_base`: The filename of the episode without its extension.
|
|
109
|
+
- `url`: URL of episode audio file.
|
|
110
|
+
|
|
111
|
+
## Log Levels
|
|
112
|
+
|
|
113
|
+
By default, all logs and errors are outputted to the console. The amount of logs can be controlled using the environment variable `LOG_LEVEL` with the following options:
|
|
114
|
+
|
|
115
|
+
- `static`: All logs and errors are outputted to the console, but disables any animations.
|
|
116
|
+
- `quiet`: Only important info and non-critical errors will be logged (e.g. episode download started).
|
|
117
|
+
- `silent`: Only critical error messages will be be logged.
|
|
118
|
+
|
|
119
|
+
## OS Filename Limits
|
|
120
|
+
|
|
121
|
+
By default, the max length of a generated filename is `255`. If your OS has different limitations, or if you're running into issues with non-standard feeds, you can adjust the limit via the environment variable `MAX_LENGTH_FILENAME`.
|
package/bin/archive.js
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import dayjs from "dayjs";
|
|
2
|
-
import fs from "fs";
|
|
3
|
-
import path from "path";
|
|
4
|
-
import { getJsonFile } from "./util.js";
|
|
5
|
-
|
|
6
|
-
export const getArchiveKey = ({ prefix, name }) => {
|
|
7
|
-
return `${prefix}-${name}`;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export const getArchive = (archive) => {
|
|
11
|
-
const archiveContent = getJsonFile(archive);
|
|
12
|
-
return archiveContent === null ? [] : archiveContent;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export const writeToArchive = ({ key, archive }) => {
|
|
16
|
-
const archivePath = path.resolve(process.cwd(), archive);
|
|
17
|
-
const archiveResult = getArchive(archive);
|
|
18
|
-
|
|
19
|
-
if (!archiveResult.includes(key)) {
|
|
20
|
-
archiveResult.push(key);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
fs.writeFileSync(archivePath, JSON.stringify(archiveResult, null, 4));
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export const getIsInArchive = ({ key, archive }) => {
|
|
27
|
-
const archiveResult = getArchive(archive);
|
|
28
|
-
return archiveResult.includes(key);
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export const getArchiveFilename = ({ pubDate, name, ext }) => {
|
|
32
|
-
const formattedPubDate = pubDate
|
|
33
|
-
? dayjs(new Date(pubDate)).format("YYYYMMDD")
|
|
34
|
-
: null;
|
|
35
|
-
|
|
36
|
-
const baseName = formattedPubDate ? `${formattedPubDate}-${name}` : name;
|
|
37
|
-
|
|
38
|
-
return `${baseName}${ext}`;
|
|
39
|
-
};
|
|
1
|
+
import dayjs from "dayjs";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import { getJsonFile } from "./util.js";
|
|
5
|
+
|
|
6
|
+
export const getArchiveKey = ({ prefix, name }) => {
|
|
7
|
+
return `${prefix}-${name}`;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const getArchive = (archive) => {
|
|
11
|
+
const archiveContent = getJsonFile(archive);
|
|
12
|
+
return archiveContent === null ? [] : archiveContent;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const writeToArchive = ({ key, archive }) => {
|
|
16
|
+
const archivePath = path.resolve(process.cwd(), archive);
|
|
17
|
+
const archiveResult = getArchive(archive);
|
|
18
|
+
|
|
19
|
+
if (!archiveResult.includes(key)) {
|
|
20
|
+
archiveResult.push(key);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
fs.writeFileSync(archivePath, JSON.stringify(archiveResult, null, 4));
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const getIsInArchive = ({ key, archive }) => {
|
|
27
|
+
const archiveResult = getArchive(archive);
|
|
28
|
+
return archiveResult.includes(key);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const getArchiveFilename = ({ pubDate, name, ext }) => {
|
|
32
|
+
const formattedPubDate = pubDate
|
|
33
|
+
? dayjs(new Date(pubDate)).format("YYYYMMDD")
|
|
34
|
+
: null;
|
|
35
|
+
|
|
36
|
+
const baseName = formattedPubDate ? `${formattedPubDate}-${name}` : name;
|
|
37
|
+
|
|
38
|
+
return `${baseName}${ext}`;
|
|
39
|
+
};
|