Skip to content

Commit

Permalink
Add infra to handle with feed healthy
Browse files Browse the repository at this point in the history
  • Loading branch information
mfcar committed Sep 23, 2023
1 parent 102c90c commit 2b3c3cd
Show file tree
Hide file tree
Showing 6 changed files with 379 additions and 332 deletions.
8 changes: 4 additions & 4 deletions client/pages/item/_id/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -485,16 +485,16 @@ export default {
return this.$toast.error('Podcast does not have an RSS Feed')
}
this.fetchingRSSFeed = true
var payload = await this.$axios.$post(`/api/podcasts/feed`, { rssFeed: this.mediaMetadata.feedUrl }).catch((error) => {
var payload = await this.$axios.get(`/api/podcasts/${this.libraryItemId}/feed`).catch((error) => {
console.error('Failed to get feed', error)
this.$toast.error('Failed to get podcast feed')
return null
})
this.fetchingRSSFeed = false
if (!payload) return
if (!payload || !payload.data) return
console.log('Podcast feed', payload)
const podcastfeed = payload.podcast
console.log('Podcast feed', payload.data)
const podcastfeed = payload.data.podcast
if (!podcastfeed.episodes || !podcastfeed.episodes.length) {
this.$toast.info('No episodes found in RSS feed')
return
Expand Down
13 changes: 13 additions & 0 deletions server/controllers/PodcastController.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,19 @@ class PodcastController {
res.json({ podcast })
}

async checkPodcastFeed(req, res) {
const libraryItem = req.libraryItem
const podcast = await getPodcastFeed(libraryItem.media.metadata.feedUrl)

if (!podcast) {
this.podcastManager.setFeedHealthStatus(libraryItem, false)
return res.status(404).send('Podcast RSS feed request failed or invalid response data')
}

this.podcastManager.setFeedHealthStatus(libraryItem, true)
res.json({ podcast })
}

async getFeedsFromOPMLText(req, res) {
if (!req.body.opmlText) {
return res.sendStatus(400)
Expand Down
Loading

0 comments on commit 2b3c3cd

Please sign in to comment.