diff --git a/client/components/modals/item/tabs/Schedule.vue b/client/components/modals/item/tabs/Schedule.vue index b1aa2cdc..b21d40a2 100644 --- a/client/components/modals/item/tabs/Schedule.vue +++ b/client/components/modals/item/tabs/Schedule.vue @@ -19,6 +19,15 @@

+
+ + +

+ Max new episodes to download per check + info_outlined +

+
+
@@ -46,7 +55,8 @@ export default { return { enableAutoDownloadEpisodes: false, cronExpression: null, - newMaxEpisodesToKeep: 0 + newMaxEpisodesToKeep: 0, + newMaxNewEpisodesToDownload: 0 } }, computed: { @@ -82,8 +92,11 @@ export default { maxEpisodesToKeep() { return this.media.maxEpisodesToKeep }, + maxNewEpisodesToDownload() { + return this.media.maxNewEpisodesToDownload + }, isUpdated() { - return this.autoDownloadSchedule !== this.cronExpression || this.autoDownloadEpisodes !== this.enableAutoDownloadEpisodes || this.maxEpisodesToKeep !== Number(this.newMaxEpisodesToKeep) + return this.autoDownloadSchedule !== this.cronExpression || this.autoDownloadEpisodes !== this.enableAutoDownloadEpisodes || this.maxEpisodesToKeep !== Number(this.newMaxEpisodesToKeep) || this.maxNewEpisodesToDownload !== Number(this.newMaxNewEpisodesToDownload) } }, methods: { @@ -94,6 +107,13 @@ export default { this.newMaxEpisodesToKeep = Number(this.newMaxEpisodesToKeep) } }, + updateMaxNewEpisodesToDownload() { + if (isNaN(this.newMaxNewEpisodesToDownload) || this.newMaxNewEpisodesToDownload < 0) { + this.newMaxNewEpisodesToDownload = 0 + } else { + this.newMaxNewEpisodesToDownload = Number(this.newMaxNewEpisodesToDownload) + } + }, save() { // If custom expression input is focused then unfocus it instead of submitting if (this.$refs.cronExpressionBuilder && this.$refs.cronExpressionBuilder.checkBlurExpressionInput) { @@ -115,6 +135,9 @@ export default { if (this.newMaxEpisodesToKeep !== this.maxEpisodesToKeep) { updatePayload.maxEpisodesToKeep = this.newMaxEpisodesToKeep } + if (this.newMaxNewEpisodesToDownload !== this.maxNewEpisodesToDownload) { + updatePayload.maxNewEpisodesToDownload = this.newMaxNewEpisodesToDownload + } this.updateDetails(updatePayload) }, @@ -139,6 +162,7 @@ export default { this.enableAutoDownloadEpisodes = this.autoDownloadEpisodes this.cronExpression = this.autoDownloadSchedule this.newMaxEpisodesToKeep = this.maxEpisodesToKeep + this.newMaxNewEpisodesToDownload = this.maxNewEpisodesToDownload } }, mounted() { diff --git a/server/managers/PodcastManager.js b/server/managers/PodcastManager.js index cddf5b63..59bc7ea4 100644 --- a/server/managers/PodcastManager.js +++ b/server/managers/PodcastManager.js @@ -204,7 +204,7 @@ class PodcastManager { const dateToCheckForEpisodesAfter = latestEpisodePublishedAt || lastEpisodeCheckDate Logger.debug(`[PodcastManager] runEpisodeCheck: "${libraryItem.media.metadata.title}" checking for episodes after ${new Date(dateToCheckForEpisodesAfter)}`) - var newEpisodes = await this.checkPodcastForNewEpisodes(libraryItem, dateToCheckForEpisodesAfter) + var newEpisodes = await this.checkPodcastForNewEpisodes(libraryItem, dateToCheckForEpisodesAfter, libraryItem.media.maxNewEpisodesToDownload) Logger.debug(`[PodcastManager] runEpisodeCheck: ${newEpisodes ? newEpisodes.length : 'N/A'} episodes found`) if (!newEpisodes) { // Failed diff --git a/server/objects/mediaTypes/Podcast.js b/server/objects/mediaTypes/Podcast.js index 54a38299..d0f1da94 100644 --- a/server/objects/mediaTypes/Podcast.js +++ b/server/objects/mediaTypes/Podcast.js @@ -21,6 +21,7 @@ class Podcast { this.autoDownloadSchedule = null this.lastEpisodeCheck = 0 this.maxEpisodesToKeep = 0 + this.maxNewEpisodesToDownload = 3 this.lastCoverSearch = null this.lastCoverSearchQuery = null @@ -44,6 +45,7 @@ class Podcast { this.autoDownloadSchedule = podcast.autoDownloadSchedule || '0 * * * *' // Added in 2.1.3 so default to hourly this.lastEpisodeCheck = podcast.lastEpisodeCheck || 0 this.maxEpisodesToKeep = podcast.maxEpisodesToKeep || 0 + this.maxNewEpisodesToDownload = podcast.maxNewEpisodesToDownload || 3 } toJSON() { @@ -56,7 +58,8 @@ class Podcast { autoDownloadEpisodes: this.autoDownloadEpisodes, autoDownloadSchedule: this.autoDownloadSchedule, lastEpisodeCheck: this.lastEpisodeCheck, - maxEpisodesToKeep: this.maxEpisodesToKeep + maxEpisodesToKeep: this.maxEpisodesToKeep, + maxNewEpisodesToDownload: this.maxNewEpisodesToDownload } } @@ -70,6 +73,7 @@ class Podcast { autoDownloadSchedule: this.autoDownloadSchedule, lastEpisodeCheck: this.lastEpisodeCheck, maxEpisodesToKeep: this.maxEpisodesToKeep, + maxNewEpisodesToDownload: this.maxNewEpisodesToDownload, size: this.size } } @@ -85,6 +89,7 @@ class Podcast { autoDownloadSchedule: this.autoDownloadSchedule, lastEpisodeCheck: this.lastEpisodeCheck, maxEpisodesToKeep: this.maxEpisodesToKeep, + maxNewEpisodesToDownload: this.maxNewEpisodesToDownload, size: this.size } }