podcast-dl 9.3.3 → 9.4.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/README.md +1 -0
- package/bin/async.js +16 -8
- package/bin/bin.js +20 -17
- package/bin/commander.js +10 -0
- package/bin/naming.js +10 -2
- package/bin/util.js +3 -1
- package/bin/validate.js +0 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -42,6 +42,7 @@ Type values surrounded in square brackets (`[]`) can be used as used as boolean
|
|
|
42
42
|
| --before | String | false | Only download episodes before this date (i.e. MM/DD/YYY, inclusive) |
|
|
43
43
|
| --episode-regex | String | false | Match episode title against provided regex before starting download. |
|
|
44
44
|
| --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. |
|
|
45
|
+
| --episode-num-offset | Number | false | Offset the acquired episode number. Default is 0. |
|
|
45
46
|
| --episode-source-order | String | false | Attempted order to extract episode audio URL from RSS feed. Default is "enclosure,link". |
|
|
46
47
|
| --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**) |
|
|
47
48
|
| --adjust-bitrate | String (e.g. "48k") | false | Attempts to adjust bitrate of episodes. (**ffmpeg required**) |
|
package/bin/async.js
CHANGED
|
@@ -59,14 +59,19 @@ const download = async (options) => {
|
|
|
59
59
|
return;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
62
|
+
let headResponse = null;
|
|
63
|
+
try {
|
|
64
|
+
headResponse = await got(url, {
|
|
65
|
+
timeout: 30000,
|
|
66
|
+
method: "HEAD",
|
|
67
|
+
responseType: "json",
|
|
68
|
+
headers: {
|
|
69
|
+
accept: "*/*",
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
} catch (error) {
|
|
73
|
+
// unable to retrive head response
|
|
74
|
+
}
|
|
70
75
|
|
|
71
76
|
const tempOutputPath = getTempPath(outputPath);
|
|
72
77
|
const removeFile = () => {
|
|
@@ -160,6 +165,7 @@ const downloadItemsAsync = async ({
|
|
|
160
165
|
bitrate,
|
|
161
166
|
episodeTemplate,
|
|
162
167
|
episodeDigits,
|
|
168
|
+
episodeNumOffset,
|
|
163
169
|
episodeSourceOrder,
|
|
164
170
|
exec,
|
|
165
171
|
feed,
|
|
@@ -194,6 +200,7 @@ const downloadItemsAsync = async ({
|
|
|
194
200
|
ext: audioFileExt,
|
|
195
201
|
template: episodeTemplate,
|
|
196
202
|
width: episodeDigits,
|
|
203
|
+
offset: episodeNumOffset,
|
|
197
204
|
});
|
|
198
205
|
const outputPodcastPath = _path.resolve(basePath, episodeFilename);
|
|
199
206
|
|
|
@@ -277,6 +284,7 @@ const downloadItemsAsync = async ({
|
|
|
277
284
|
ext: episodeMetaExt,
|
|
278
285
|
template: episodeTemplate,
|
|
279
286
|
width: episodeDigits,
|
|
287
|
+
offset: episodeNumOffset,
|
|
280
288
|
});
|
|
281
289
|
const outputEpisodeMetaPath = _path.resolve(basePath, episodeMetaName);
|
|
282
290
|
|
package/bin/bin.js
CHANGED
|
@@ -32,31 +32,32 @@ import { downloadItemsAsync } from "./async.js";
|
|
|
32
32
|
setupCommander(commander, process.argv);
|
|
33
33
|
|
|
34
34
|
const {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
after,
|
|
36
|
+
alwaysPostprocess,
|
|
37
|
+
attempts,
|
|
38
|
+
before,
|
|
39
39
|
episodeDigits,
|
|
40
|
+
episodeNumOffset,
|
|
41
|
+
episodeRegex,
|
|
40
42
|
episodeSourceOrder,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
+
episodeTemplate,
|
|
44
|
+
exec,
|
|
45
|
+
file,
|
|
43
46
|
includeEpisodeImages,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
episodeRegex,
|
|
47
|
-
after,
|
|
48
|
-
before,
|
|
49
|
-
override,
|
|
50
|
-
alwaysPostprocess,
|
|
51
|
-
reverse,
|
|
47
|
+
includeEpisodeMeta,
|
|
48
|
+
includeMeta,
|
|
52
49
|
info,
|
|
50
|
+
limit,
|
|
53
51
|
list,
|
|
54
|
-
exec,
|
|
55
52
|
mono,
|
|
56
|
-
|
|
57
|
-
|
|
53
|
+
offset,
|
|
54
|
+
outDir,
|
|
55
|
+
override,
|
|
58
56
|
parserConfig,
|
|
59
57
|
proxy,
|
|
58
|
+
reverse,
|
|
59
|
+
threads,
|
|
60
|
+
url,
|
|
60
61
|
addMp3Metadata: addMp3MetadataFlag,
|
|
61
62
|
adjustBitrate: bitrate,
|
|
62
63
|
} = commander;
|
|
@@ -206,6 +207,7 @@ const main = async () => {
|
|
|
206
207
|
after,
|
|
207
208
|
before,
|
|
208
209
|
episodeDigits,
|
|
210
|
+
episodeNumOffset,
|
|
209
211
|
episodeRegex,
|
|
210
212
|
episodeSourceOrder,
|
|
211
213
|
episodeTemplate,
|
|
@@ -229,6 +231,7 @@ const main = async () => {
|
|
|
229
231
|
bitrate,
|
|
230
232
|
episodeTemplate,
|
|
231
233
|
episodeDigits,
|
|
234
|
+
episodeNumOffset,
|
|
232
235
|
episodeSourceOrder,
|
|
233
236
|
exec,
|
|
234
237
|
feed,
|
package/bin/commander.js
CHANGED
|
@@ -26,6 +26,16 @@ export const setupCommander = (commander, argv) => {
|
|
|
26
26
|
createParseNumber({ min: 0, name: "--episode-digits" }),
|
|
27
27
|
1
|
|
28
28
|
)
|
|
29
|
+
.option(
|
|
30
|
+
"--episode-num-offset <number>",
|
|
31
|
+
"offset the acquired episode number",
|
|
32
|
+
createParseNumber({
|
|
33
|
+
min: Number.MIN_SAFE_INTEGER,
|
|
34
|
+
max: Number.MAX_SAFE_INTEGER,
|
|
35
|
+
name: "--episode-num-offset",
|
|
36
|
+
}),
|
|
37
|
+
0
|
|
38
|
+
)
|
|
29
39
|
.option(
|
|
30
40
|
"--episode-source-order <string>",
|
|
31
41
|
"attempted order to extract episode audio URL from rss feed",
|
package/bin/naming.js
CHANGED
|
@@ -18,8 +18,16 @@ const getSimpleFilename = (name, ext = "") => {
|
|
|
18
18
|
return `${getSafeName(name, MAX_LENGTH_FILENAME - (ext?.length ?? 0))}${ext}`;
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
const getItemFilename = ({
|
|
22
|
-
|
|
21
|
+
const getItemFilename = ({
|
|
22
|
+
item,
|
|
23
|
+
ext,
|
|
24
|
+
url,
|
|
25
|
+
feed,
|
|
26
|
+
template,
|
|
27
|
+
width,
|
|
28
|
+
offset = 0,
|
|
29
|
+
}) => {
|
|
30
|
+
const episodeNum = feed.items.length - item._originalIndex + offset;
|
|
23
31
|
const formattedPubDate = item.pubDate
|
|
24
32
|
? dayjs(new Date(item.pubDate)).format("YYYYMMDD")
|
|
25
33
|
: null;
|
package/bin/util.js
CHANGED
|
@@ -15,7 +15,7 @@ const isWin = process.platform === "win32";
|
|
|
15
15
|
Escape arguments for a shell command used with exec.
|
|
16
16
|
Borrowed from shell-escape: https://github.com/xxorax/node-shell-escape/
|
|
17
17
|
Additionally, @see https://www.robvanderwoude.com/escapechars.php for why
|
|
18
|
-
we avoid trying
|
|
18
|
+
we avoid trying to escape complex sequences in Windows.
|
|
19
19
|
*/
|
|
20
20
|
const escapeArgForShell = (arg) => {
|
|
21
21
|
let result = arg;
|
|
@@ -154,6 +154,7 @@ const getItemsToDownload = ({
|
|
|
154
154
|
before,
|
|
155
155
|
after,
|
|
156
156
|
episodeDigits,
|
|
157
|
+
episodeNumOffset,
|
|
157
158
|
episodeRegex,
|
|
158
159
|
episodeSourceOrder,
|
|
159
160
|
episodeTemplate,
|
|
@@ -243,6 +244,7 @@ const getItemsToDownload = ({
|
|
|
243
244
|
ext: episodeImageFileExt,
|
|
244
245
|
template: episodeTemplate,
|
|
245
246
|
width: episodeDigits,
|
|
247
|
+
offset: episodeNumOffset,
|
|
246
248
|
});
|
|
247
249
|
|
|
248
250
|
const outputImagePath = path.resolve(basePath, episodeImageName);
|
package/bin/validate.js
CHANGED