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.
- package/bin/util.js +10 -11
- 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 = ({
|
|
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;
|
|
@@ -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) => {
|