podcast-dl 10.3.0 → 10.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 CHANGED
@@ -28,6 +28,8 @@ import {
28
28
  const pipeline = promisify(stream.pipeline);
29
29
 
30
30
  const BYTES_IN_MB = 1000000;
31
+ const USER_AGENT =
32
+ "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36";
31
33
 
32
34
  const download = async (options) => {
33
35
  const {
@@ -67,6 +69,7 @@ const download = async (options) => {
67
69
  responseType: "json",
68
70
  headers: {
69
71
  accept: "*/*",
72
+ "user-agent": USER_AGENT,
70
73
  },
71
74
  });
72
75
  } catch (error) {
@@ -108,7 +111,9 @@ const download = async (options) => {
108
111
  });
109
112
 
110
113
  await pipeline(
111
- got.stream(url).on("downloadProgress", onDownloadProgress),
114
+ got
115
+ .stream(url, { headers: { "user-agent": USER_AGENT } })
116
+ .on("downloadProgress", onDownloadProgress),
112
117
  fs.createWriteStream(tempOutputPath)
113
118
  );
114
119
  } catch (error) {
@@ -159,7 +164,7 @@ const download = async (options) => {
159
164
  const downloadItemsAsync = async ({
160
165
  addMp3MetadataFlag,
161
166
  archive,
162
- archiveUrl,
167
+ archivePrefix,
163
168
  attempts,
164
169
  basePath,
165
170
  bitrate,
@@ -215,7 +220,7 @@ const downloadItemsAsync = async ({
215
220
  alwaysPostprocess,
216
221
  marker,
217
222
  key: getArchiveKey({
218
- prefix: archiveUrl,
223
+ prefix: archivePrefix,
219
224
  name: getArchiveFilename({
220
225
  name: item.title,
221
226
  pubDate: item.pubDate,
@@ -300,7 +305,7 @@ const downloadItemsAsync = async ({
300
305
  override,
301
306
  item,
302
307
  key: getArchiveKey({
303
- prefix: archiveUrl,
308
+ prefix: archivePrefix,
304
309
  name: getArchiveFilename({
305
310
  pubDate: item.pubDate,
306
311
  name: item.title,
package/bin/bin.js CHANGED
@@ -84,8 +84,15 @@ const main = async () => {
84
84
  ? await getUrlFeed(url, parserConfig)
85
85
  : await getFileFeed(file, parserConfig);
86
86
 
87
- const { hostname, pathname } = new URL(feed.feedUrl || url);
88
- const archiveUrl = `${hostname}${pathname}`;
87
+ const archivePrefix = (() => {
88
+ if (feed.feedUrl || url) {
89
+ const { hostname, pathname } = new URL(feed.feedUrl || url);
90
+ return `${hostname}${pathname}`;
91
+ }
92
+
93
+ return feed.title || file;
94
+ })();
95
+
89
96
  const basePath = _path.resolve(
90
97
  process.cwd(),
91
98
  getFolderName({ feed, template: outDir })
@@ -152,7 +159,7 @@ const main = async () => {
152
159
  override,
153
160
  marker: podcastImageUrl,
154
161
  key: getArchiveKey({
155
- prefix: archiveUrl,
162
+ prefix: archivePrefix,
156
163
  name: `${
157
164
  feed.title ? `${feed.title}.image` : "image"
158
165
  }${podcastImageFileExt}`,
@@ -181,7 +188,7 @@ const main = async () => {
181
188
  override,
182
189
  feed,
183
190
  key: getArchiveKey({
184
- prefix: archiveUrl,
191
+ prefix: archivePrefix,
185
192
  name: `${feed.title ? `${feed.title}.meta` : "meta"}.json`,
186
193
  }),
187
194
  outputPath: outputMetaPath,
@@ -201,7 +208,7 @@ const main = async () => {
201
208
 
202
209
  const targetItems = getItemsToDownload({
203
210
  archive,
204
- archiveUrl,
211
+ archivePrefix,
205
212
  basePath,
206
213
  feed,
207
214
  limit,
@@ -231,7 +238,7 @@ const main = async () => {
231
238
  const { numEpisodesDownloaded, hasErrors } = await downloadItemsAsync({
232
239
  addMp3MetadataFlag,
233
240
  archive,
234
- archiveUrl,
241
+ archivePrefix,
235
242
  attempts,
236
243
  basePath,
237
244
  bitrate,
package/bin/util.js CHANGED
@@ -152,7 +152,7 @@ const getLoopControls = ({ offset, length, reverse }) => {
152
152
 
153
153
  const getItemsToDownload = ({
154
154
  archive,
155
- archiveUrl,
155
+ archivePrefix,
156
156
  basePath,
157
157
  feed,
158
158
  limit,
@@ -216,7 +216,7 @@ const getItemsToDownload = ({
216
216
  const { url: episodeAudioUrl, ext: audioFileExt } =
217
217
  getEpisodeAudioUrlAndExt(feed.items[i], episodeSourceOrder);
218
218
  const key = getArchiveKey({
219
- prefix: archiveUrl,
219
+ prefix: archivePrefix,
220
220
  name: getArchiveFilename({
221
221
  pubDate,
222
222
  name: title,
@@ -239,7 +239,7 @@ const getItemsToDownload = ({
239
239
  if (episodeImageUrl) {
240
240
  const episodeImageFileExt = getUrlExt(episodeImageUrl);
241
241
  const episodeImageArchiveKey = getArchiveKey({
242
- prefix: archiveUrl,
242
+ prefix: archivePrefix,
243
243
  name: getArchiveFilename({
244
244
  pubDate,
245
245
  name: title,
@@ -276,7 +276,7 @@ const getItemsToDownload = ({
276
276
  if (episodeTranscriptUrl) {
277
277
  const episodeTranscriptFileExt = getUrlExt(episodeTranscriptUrl);
278
278
  const episodeTranscriptArchiveKey = getArchiveKey({
279
- prefix: archiveUrl,
279
+ prefix: archivePrefix,
280
280
  name: getArchiveFilename({
281
281
  pubDate,
282
282
  name: title,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "podcast-dl",
3
- "version": "10.3.0",
3
+ "version": "10.3.2",
4
4
  "description": "A CLI for downloading podcasts.",
5
5
  "type": "module",
6
6
  "bin": "./bin/bin.js",