podcast-dl 7.2.0 → 7.3.2
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/bin/async.js +6 -8
- package/bin/bin.js +18 -0
- package/bin/util.js +44 -71
- package/package.json +1 -1
package/bin/async.js
CHANGED
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
writeItemMeta,
|
|
23
23
|
writeToArchive,
|
|
24
24
|
getUrlEmbed,
|
|
25
|
+
getIsInArchive,
|
|
25
26
|
} from "./util.js";
|
|
26
27
|
|
|
27
28
|
const pipeline = promisify(stream.pipeline);
|
|
@@ -44,6 +45,11 @@ const download = async ({
|
|
|
44
45
|
return;
|
|
45
46
|
}
|
|
46
47
|
|
|
48
|
+
if (key && archive && getIsInArchive({ key, archive })) {
|
|
49
|
+
logMessage("Download exists in archive. Skipping...");
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
47
53
|
let embeddedUrl = null;
|
|
48
54
|
if (filterUrlTracking) {
|
|
49
55
|
logMessage("Attempting to find embedded URL...");
|
|
@@ -125,14 +131,6 @@ const download = async ({
|
|
|
125
131
|
|
|
126
132
|
fs.renameSync(tempOutputPath, outputPath);
|
|
127
133
|
|
|
128
|
-
if (expectedSize && !isNaN(expectedSize) && expectedSize !== fileSize) {
|
|
129
|
-
logMessage(
|
|
130
|
-
"File size differs from expected content length. Suggestion: verify file works as expected",
|
|
131
|
-
LOG_LEVELS.important
|
|
132
|
-
);
|
|
133
|
-
logMessage(`${outputPath}`, LOG_LEVELS.important);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
134
|
logMessage("Download complete!");
|
|
137
135
|
|
|
138
136
|
if (onAfterDownload) {
|
package/bin/bin.js
CHANGED
|
@@ -293,6 +293,24 @@ const main = async () => {
|
|
|
293
293
|
filterUrlTracking,
|
|
294
294
|
});
|
|
295
295
|
|
|
296
|
+
if (hasErrors && numEpisodesDownloaded !== targetItems.length) {
|
|
297
|
+
logMessage(
|
|
298
|
+
`\n${numEpisodesDownloaded} of ${pluralize(
|
|
299
|
+
"episode",
|
|
300
|
+
targetItems.length,
|
|
301
|
+
true
|
|
302
|
+
)} downloaded\n`
|
|
303
|
+
);
|
|
304
|
+
} else if (numEpisodesDownloaded > 0) {
|
|
305
|
+
logMessage(
|
|
306
|
+
`\nSuccessfully downloaded ${pluralize(
|
|
307
|
+
"episode",
|
|
308
|
+
numEpisodesDownloaded,
|
|
309
|
+
true
|
|
310
|
+
)}\n`
|
|
311
|
+
);
|
|
312
|
+
}
|
|
313
|
+
|
|
296
314
|
if (numEpisodesDownloaded === 0) {
|
|
297
315
|
process.exit(ERROR_STATUSES.nothingDownloaded);
|
|
298
316
|
}
|
package/bin/util.js
CHANGED
|
@@ -97,28 +97,28 @@ const getUrlEmbed = async (url) => {
|
|
|
97
97
|
return null;
|
|
98
98
|
};
|
|
99
99
|
|
|
100
|
-
const getLoopControls = ({
|
|
100
|
+
const getLoopControls = ({ offset, length, reverse }) => {
|
|
101
101
|
if (reverse) {
|
|
102
102
|
const startIndex = length - 1 - offset;
|
|
103
|
-
const min =
|
|
104
|
-
const
|
|
103
|
+
const min = -1;
|
|
104
|
+
const shouldGo = (i) => i > min;
|
|
105
105
|
const decrement = (i) => i - 1;
|
|
106
106
|
|
|
107
107
|
return {
|
|
108
108
|
startIndex,
|
|
109
|
-
|
|
109
|
+
shouldGo,
|
|
110
110
|
next: decrement,
|
|
111
111
|
};
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
const startIndex = 0 + offset;
|
|
115
|
-
const max =
|
|
116
|
-
const
|
|
115
|
+
const max = length;
|
|
116
|
+
const shouldGo = (i) => i < max;
|
|
117
117
|
const increment = (i) => i + 1;
|
|
118
118
|
|
|
119
119
|
return {
|
|
120
120
|
startIndex,
|
|
121
|
-
|
|
121
|
+
shouldGo,
|
|
122
122
|
next: increment,
|
|
123
123
|
};
|
|
124
124
|
};
|
|
@@ -137,8 +137,7 @@ const getItemsToDownload = ({
|
|
|
137
137
|
episodeTemplate,
|
|
138
138
|
includeEpisodeImages,
|
|
139
139
|
}) => {
|
|
140
|
-
const { startIndex,
|
|
141
|
-
limit,
|
|
140
|
+
const { startIndex, shouldGo, next } = getLoopControls({
|
|
142
141
|
offset,
|
|
143
142
|
reverse,
|
|
144
143
|
length: feed.items.length,
|
|
@@ -149,7 +148,7 @@ const getItemsToDownload = ({
|
|
|
149
148
|
|
|
150
149
|
const savedArchive = archive ? getArchive(archive) : [];
|
|
151
150
|
|
|
152
|
-
while (
|
|
151
|
+
while (shouldGo(i)) {
|
|
153
152
|
const { title, pubDate } = feed.items[i];
|
|
154
153
|
const pubDateDay = dayjs(new Date(pubDate));
|
|
155
154
|
let isValid = true;
|
|
@@ -215,22 +214,20 @@ const getItemsToDownload = ({
|
|
|
215
214
|
}),
|
|
216
215
|
});
|
|
217
216
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
});
|
|
233
|
-
}
|
|
217
|
+
const episodeImageName = getFilename({
|
|
218
|
+
item,
|
|
219
|
+
feed,
|
|
220
|
+
url: episodeAudioUrl,
|
|
221
|
+
ext: episodeImageFileExt,
|
|
222
|
+
template: episodeTemplate,
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
const outputImagePath = path.resolve(basePath, episodeImageName);
|
|
226
|
+
item._extra_downloads.push({
|
|
227
|
+
url: episodeImageUrl,
|
|
228
|
+
outputPath: outputImagePath,
|
|
229
|
+
key: episodeImageArchiveKey,
|
|
230
|
+
});
|
|
234
231
|
}
|
|
235
232
|
}
|
|
236
233
|
|
|
@@ -240,7 +237,7 @@ const getItemsToDownload = ({
|
|
|
240
237
|
i = next(i);
|
|
241
238
|
}
|
|
242
239
|
|
|
243
|
-
return items;
|
|
240
|
+
return limit ? items.slice(0, limit) : items;
|
|
244
241
|
};
|
|
245
242
|
|
|
246
243
|
const logFeedInfo = (feed) => {
|
|
@@ -295,34 +292,24 @@ const logItemsList = ({
|
|
|
295
292
|
|
|
296
293
|
const writeFeedMeta = ({ outputPath, feed, key, archive, override }) => {
|
|
297
294
|
if (key && archive && getIsInArchive({ key, archive })) {
|
|
298
|
-
logMessage("Feed metadata exists in archive. Skipping
|
|
295
|
+
logMessage("Feed metadata exists in archive. Skipping...");
|
|
299
296
|
return;
|
|
300
297
|
}
|
|
301
298
|
|
|
302
|
-
const
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
299
|
+
const output = {};
|
|
300
|
+
["title", "description", "link", "feedUrl", "managingEditor"].forEach(
|
|
301
|
+
(key) => {
|
|
302
|
+
if (feed[key]) {
|
|
303
|
+
output[key] = feed[key];
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
);
|
|
307
307
|
|
|
308
308
|
try {
|
|
309
309
|
if (override || !fs.existsSync(outputPath)) {
|
|
310
|
-
fs.writeFileSync(
|
|
311
|
-
outputPath,
|
|
312
|
-
JSON.stringify(
|
|
313
|
-
{
|
|
314
|
-
title,
|
|
315
|
-
description,
|
|
316
|
-
link,
|
|
317
|
-
feedUrl,
|
|
318
|
-
managingEditor,
|
|
319
|
-
},
|
|
320
|
-
null,
|
|
321
|
-
4
|
|
322
|
-
)
|
|
323
|
-
);
|
|
310
|
+
fs.writeFileSync(outputPath, JSON.stringify(output, null, 4));
|
|
324
311
|
} else {
|
|
325
|
-
logMessage("Feed metadata exists locally. Skipping
|
|
312
|
+
logMessage("Feed metadata exists locally. Skipping...");
|
|
326
313
|
}
|
|
327
314
|
|
|
328
315
|
if (key && archive && !getIsInArchive({ key, archive })) {
|
|
@@ -348,36 +335,22 @@ const writeItemMeta = ({
|
|
|
348
335
|
override,
|
|
349
336
|
}) => {
|
|
350
337
|
if (key && archive && getIsInArchive({ key, archive })) {
|
|
351
|
-
logMessage(
|
|
352
|
-
`${marker} | Episode metadata exists in archive. Skipping write...`
|
|
353
|
-
);
|
|
338
|
+
logMessage(`${marker} | Episode metadata exists in archive. Skipping...`);
|
|
354
339
|
return;
|
|
355
340
|
}
|
|
356
341
|
|
|
357
|
-
const
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
342
|
+
const output = {};
|
|
343
|
+
["title", "contentSnippet", "pubDate", "creator"].forEach((key) => {
|
|
344
|
+
if (item[key]) {
|
|
345
|
+
output[key] = item[key];
|
|
346
|
+
}
|
|
347
|
+
});
|
|
361
348
|
|
|
362
349
|
try {
|
|
363
350
|
if (override || !fs.existsSync(outputPath)) {
|
|
364
|
-
fs.writeFileSync(
|
|
365
|
-
outputPath,
|
|
366
|
-
JSON.stringify(
|
|
367
|
-
{
|
|
368
|
-
title,
|
|
369
|
-
pubDate,
|
|
370
|
-
creator,
|
|
371
|
-
descriptionText,
|
|
372
|
-
},
|
|
373
|
-
null,
|
|
374
|
-
4
|
|
375
|
-
)
|
|
376
|
-
);
|
|
351
|
+
fs.writeFileSync(outputPath, JSON.stringify(output, null, 4));
|
|
377
352
|
} else {
|
|
378
|
-
logMessage(
|
|
379
|
-
`${marker} | Episode metadata exists locally. Skipping write...`
|
|
380
|
-
);
|
|
353
|
+
logMessage(`${marker} | Episode metadata exists locally. Skipping...`);
|
|
381
354
|
}
|
|
382
355
|
|
|
383
356
|
if (key && archive && !getIsInArchive({ key, archive })) {
|