Add podcast episode auto download new episodes cron

This commit is contained in:
advplyr 2022-03-26 19:58:59 -05:00
parent d5e96a3422
commit 0dd219f303
10 changed files with 155 additions and 15 deletions

View file

@ -82,6 +82,11 @@ class PodcastController {
Logger.info(`[PodcastController] Podcast created now starting ${payload.episodesToDownload.length} episode downloads`)
this.podcastManager.downloadPodcastEpisodes(libraryItem, payload.episodesToDownload)
}
// Turn on podcast auto download cron if not already on
if (libraryItem.media.autoDownloadEpisodes && !this.podcastManager.episodeScheduleTask) {
this.podcastManager.schedulePodcastEpisodeCron()
}
}
getPodcastFeed(req, res) {
@ -105,5 +110,21 @@ class PodcastController {
res.status(500).send(error)
})
}
async checkNewEpisodes(req, res) {
var libraryItem = this.db.getLibraryItem(req.params.id)
if (!libraryItem || libraryItem.mediaType !== 'podcast') {
return res.sendStatus(404)
}
if (!libraryItem.media.metadata.feedUrl) {
Logger.error(`[PodcastController] checkNewEpisodes no feed url for item ${libraryItem.id}`)
return res.status(500).send('Podcast has no rss feed url')
}
var newEpisodes = await this.podcastManager.checkPodcastForNewEpisodes(libraryItem)
res.json({
episodes: newEpisodes || []
})
}
}
module.exports = new PodcastController()