RSS Manager code

This commit is contained in:
mfcar 2023-10-03 12:32:39 +01:00
parent 2ada293e8a
commit aefcc4490f
No known key found for this signature in database
7 changed files with 508 additions and 233 deletions

View file

@ -127,14 +127,32 @@ class PodcastController {
const podcast = await getPodcastFeed(libraryItem.media.metadata.feedUrl)
if (!podcast) {
this.podcastManager.setFeedHealthStatus(libraryItem, false)
this.podcastManager.setFeedHealthStatus(libraryItem.media.id, false)
return res.status(404).send('Podcast RSS feed request failed or invalid response data')
}
this.podcastManager.setFeedHealthStatus(libraryItem, true)
this.podcastManager.setFeedHealthStatus(libraryItem.media.id, true)
res.json({ podcast })
}
async checkPodcastFeedUrl(req, res) {
const podcastId = req.params.id;
try {
const podcast = await Database.podcastModel.findByPk(req.params.id)
const podcastResult = await getPodcastFeed(podcast.feedURL);
const podcastNewStatus = await this.podcastManager.setFeedHealthStatus(podcastId, !!podcastResult);
Logger.info(podcastNewStatus);
return res.json(podcastNewStatus);
} catch (error) {
Logger.error(`[PodcastController] checkPodcastFeed: Error checking podcast feed for podcast ${podcastId}`, error)
res.status(500).json({ error: 'An error occurred while checking the podcast feed.' });
}
}
async getFeedsFromOPMLText(req, res) {
if (!req.body.opmlText) {
return res.sendStatus(400)