mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-07-10 19:31:39 +00:00
Creating a controller to return only the podcasts with feedURL
This commit is contained in:
parent
2b3c3cd088
commit
9872937a99
4 changed files with 19 additions and 0 deletions
|
|
@ -115,6 +115,13 @@ class PodcastController {
|
|||
res.json({ podcast })
|
||||
}
|
||||
|
||||
async getPodcastsWithInboundFeed(req, res) {
|
||||
const podcasts = await Database.podcastModel.getAllInboundFeeds()
|
||||
res.json({
|
||||
podcasts
|
||||
})
|
||||
}
|
||||
|
||||
async checkPodcastFeed(req, res) {
|
||||
const libraryItem = req.libraryItem
|
||||
const podcast = await getPodcastFeed(libraryItem.media.metadata.feedUrl)
|
||||
|
|
|
|||
|
|
@ -408,6 +408,12 @@ class PodcastManager {
|
|||
queue: this.downloadQueue.filter(item => !libraryId || item.libraryId === libraryId).map(item => item.toJSONForClient())
|
||||
}
|
||||
}
|
||||
|
||||
async getPodcastsWithInboundFeed() {
|
||||
const podcasts = await Database.models.podcast.getAllInboundFeeds()
|
||||
Logger.info(`[PodcastManager] Fetched all podcasts with feed`)
|
||||
return podcasts
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = PodcastManager
|
||||
|
|
|
|||
|
|
@ -120,6 +120,11 @@ class Podcast extends Model {
|
|||
}
|
||||
}
|
||||
|
||||
static async getAllInboundFeeds(){
|
||||
const podcasts = await this.findAll()
|
||||
return podcasts.map(p => this.getFromOld(p))
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize model
|
||||
* @param {import('../Database').sequelize} sequelize
|
||||
|
|
|
|||
|
|
@ -226,6 +226,7 @@ class ApiRouter {
|
|||
//
|
||||
this.router.post('/podcasts', PodcastController.create.bind(this))
|
||||
this.router.post('/podcasts/feed', PodcastController.getPodcastFeed.bind(this))
|
||||
this.router.get('/podcasts/inboundFeeds', PodcastController.getPodcastsWithInboundFeed.bind(this))
|
||||
this.router.get('/podcasts/:id/feed', PodcastController.middleware.bind(this), PodcastController.checkPodcastFeed.bind(this))
|
||||
this.router.post('/podcasts/opml', PodcastController.getFeedsFromOPMLText.bind(this))
|
||||
this.router.get('/podcasts/:id/checknew', PodcastController.middleware.bind(this), PodcastController.checkNewEpisodes.bind(this))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue