podcast-dl 7.3.1 → 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.
Files changed (2) hide show
  1. package/bin/util.js +10 -11
  2. package/package.json +1 -1
package/bin/util.js CHANGED
@@ -97,28 +97,28 @@ const getUrlEmbed = async (url) => {
97
97
  return null;
98
98
  };
99
99
 
100
- const getLoopControls = ({ limit, offset, length, reverse }) => {
100
+ const getLoopControls = ({ offset, length, reverse }) => {
101
101
  if (reverse) {
102
102
  const startIndex = length - 1 - offset;
103
- const min = limit ? Math.max(startIndex - limit, -1) : -1;
104
- const limitCheck = (i) => i > min;
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
- limitCheck,
109
+ shouldGo,
110
110
  next: decrement,
111
111
  };
112
112
  }
113
113
 
114
114
  const startIndex = 0 + offset;
115
- const max = limit ? Math.min(startIndex + limit, length) : length;
116
- const limitCheck = (i) => i < max;
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
- limitCheck,
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, limitCheck, next } = getLoopControls({
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 (limitCheck(i)) {
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;
@@ -238,7 +237,7 @@ const getItemsToDownload = ({
238
237
  i = next(i);
239
238
  }
240
239
 
241
- return items;
240
+ return limit ? items.slice(0, limit) : items;
242
241
  };
243
242
 
244
243
  const logFeedInfo = (feed) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "podcast-dl",
3
- "version": "7.3.1",
3
+ "version": "7.3.2",
4
4
  "description": "A CLI for downloading podcasts.",
5
5
  "type": "module",
6
6
  "bin": "./bin/bin.js",