mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-11-10 01:19:37 +01:00
Merge providers API into a single endpoint
This commit is contained in:
parent
0a82d6a41b
commit
0a8662d198
@ -251,107 +251,27 @@ class SearchController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GET: /api/search/providers/podcasts/covers
|
* GET: /api/search/providers
|
||||||
* Get available podcast cover metadata providers
|
* Get all available metadata providers
|
||||||
*
|
*
|
||||||
* @param {RequestWithUser} req
|
* @param {RequestWithUser} req
|
||||||
* @param {Response} res
|
* @param {Response} res
|
||||||
*/
|
*/
|
||||||
async getPodcastCoverProviders(req, res) {
|
async getAllProviders(req, res) {
|
||||||
// Podcast covers only use iTunes
|
const customProviders = await Database.customMetadataProviderModel.findAll()
|
||||||
const customProviders = await Database.customMetadataProviderModel.findAll({
|
|
||||||
where: {
|
|
||||||
mediaType: 'podcast'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
const providers = [SearchController.formatProvider('itunes'), ...SearchController.mapCustomProviders(customProviders)]
|
const customBookProviders = customProviders.filter((p) => p.mediaType === 'book')
|
||||||
|
const customPodcastProviders = customProviders.filter((p) => p.mediaType === 'podcast')
|
||||||
|
|
||||||
res.json({ providers })
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GET: /api/search/providers/books/covers
|
|
||||||
* Get available book cover metadata providers
|
|
||||||
*
|
|
||||||
* @param {RequestWithUser} req
|
|
||||||
* @param {Response} res
|
|
||||||
*/
|
|
||||||
async getBookCoverProviders(req, res) {
|
|
||||||
// Book covers use all book providers
|
|
||||||
const customProviders = await Database.customMetadataProviderModel.findAll({
|
|
||||||
where: {
|
|
||||||
mediaType: 'book'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
const providers = [SearchController.formatProvider('best'), ...BookFinder.providers.map((p) => SearchController.formatProvider(p)), ...SearchController.mapCustomProviders(customProviders), SearchController.formatProvider('all')]
|
|
||||||
|
|
||||||
res.json({ providers })
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GET: /api/search/providers/books
|
|
||||||
* Get available book metadata providers
|
|
||||||
*
|
|
||||||
* @param {RequestWithUser} req
|
|
||||||
* @param {Response} res
|
|
||||||
*/
|
|
||||||
async getBookProviders(req, res) {
|
|
||||||
const customProviders = await Database.customMetadataProviderModel.findAll({
|
|
||||||
where: {
|
|
||||||
mediaType: 'book'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
// Filter out cover-only providers
|
|
||||||
const bookProviders = BookFinder.providers.filter((p) => p !== 'audiobookcovers')
|
const bookProviders = BookFinder.providers.filter((p) => p !== 'audiobookcovers')
|
||||||
|
|
||||||
const providers = [...bookProviders.map((p) => SearchController.formatProvider(p)), ...SearchController.mapCustomProviders(customProviders)]
|
// Build minimized payload with custom providers merged in
|
||||||
|
const providers = {
|
||||||
res.json({ providers })
|
books: [...bookProviders.map((p) => SearchController.formatProvider(p)), ...SearchController.mapCustomProviders(customBookProviders)],
|
||||||
|
booksCovers: [SearchController.formatProvider('best'), ...BookFinder.providers.map((p) => SearchController.formatProvider(p)), ...SearchController.mapCustomProviders(customBookProviders), SearchController.formatProvider('all')],
|
||||||
|
podcasts: [SearchController.formatProvider('itunes'), ...SearchController.mapCustomProviders(customPodcastProviders)]
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* GET: /api/search/providers/podcasts
|
|
||||||
* Get available podcast metadata providers
|
|
||||||
*
|
|
||||||
* @param {RequestWithUser} req
|
|
||||||
* @param {Response} res
|
|
||||||
*/
|
|
||||||
async getPodcastProviders(req, res) {
|
|
||||||
const customProviders = await Database.customMetadataProviderModel.findAll({
|
|
||||||
where: {
|
|
||||||
mediaType: 'podcast'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
const providers = [SearchController.formatProvider('itunes'), ...SearchController.mapCustomProviders(customProviders)]
|
|
||||||
|
|
||||||
res.json({ providers })
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GET: /api/search/providers/authors
|
|
||||||
* Get available author metadata providers
|
|
||||||
*
|
|
||||||
* @param {RequestWithUser} req
|
|
||||||
* @param {Response} res
|
|
||||||
*/
|
|
||||||
async getAuthorProviders(req, res) {
|
|
||||||
const providers = [SearchController.formatProvider('audnexus')]
|
|
||||||
res.json({ providers })
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GET: /api/search/providers/chapters
|
|
||||||
* Get available chapter metadata providers
|
|
||||||
*
|
|
||||||
* @param {RequestWithUser} req
|
|
||||||
* @param {Response} res
|
|
||||||
*/
|
|
||||||
async getChapterProviders(req, res) {
|
|
||||||
const providers = [SearchController.formatProvider('audnexus')]
|
|
||||||
res.json({ providers })
|
res.json({ providers })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -283,12 +283,7 @@ class ApiRouter {
|
|||||||
this.router.get('/search/podcast', SearchController.findPodcasts.bind(this))
|
this.router.get('/search/podcast', SearchController.findPodcasts.bind(this))
|
||||||
this.router.get('/search/authors', SearchController.findAuthor.bind(this))
|
this.router.get('/search/authors', SearchController.findAuthor.bind(this))
|
||||||
this.router.get('/search/chapters', SearchController.findChapters.bind(this))
|
this.router.get('/search/chapters', SearchController.findChapters.bind(this))
|
||||||
this.router.get('/search/providers/books', SearchController.getBookProviders.bind(this))
|
this.router.get('/search/providers', SearchController.getAllProviders.bind(this))
|
||||||
this.router.get('/search/providers/books/covers', SearchController.getBookCoverProviders.bind(this))
|
|
||||||
this.router.get('/search/providers/podcasts', SearchController.getPodcastProviders.bind(this))
|
|
||||||
this.router.get('/search/providers/podcasts/covers', SearchController.getPodcastCoverProviders.bind(this))
|
|
||||||
this.router.get('/search/providers/authors', SearchController.getAuthorProviders.bind(this))
|
|
||||||
this.router.get('/search/providers/chapters', SearchController.getChapterProviders.bind(this))
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Cache Routes (Admin and up)
|
// Cache Routes (Admin and up)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user