diff --git a/client/components/modals/item/tabs/Cover.vue b/client/components/modals/item/tabs/Cover.vue index 3cbad218..42931744 100644 --- a/client/components/modals/item/tabs/Cover.vue +++ b/client/components/modals/item/tabs/Cover.vue @@ -49,13 +49,13 @@
-
+
-
+
{{ $strings.ButtonSearch }} @@ -128,7 +128,7 @@ export default { }, providers() { if (this.isPodcast) return this.$store.state.scanners.podcastProviders - return this.$store.state.scanners.providers + return [...this.$store.state.scanners.providers, ...this.$store.state.scanners.coverOnlyProviders] }, searchTitleLabel() { if (this.provider.startsWith('audible')) return this.$strings.LabelSearchTitleOrASIN diff --git a/client/store/scanners.js b/client/store/scanners.js index 0a339a03..9a330f4f 100644 --- a/client/store/scanners.js +++ b/client/store/scanners.js @@ -63,6 +63,12 @@ export const state = () => ({ text: 'iTunes', value: 'itunes' } + ], + coverOnlyProviders: [ + { + text: 'AudiobookCovers.com', + value: 'audiobookcovers' + } ] }) diff --git a/server/finders/BookFinder.js b/server/finders/BookFinder.js index a7d5b730..7716301f 100644 --- a/server/finders/BookFinder.js +++ b/server/finders/BookFinder.js @@ -4,6 +4,7 @@ const Audible = require('../providers/Audible') const iTunes = require('../providers/iTunes') const Audnexus = require('../providers/Audnexus') const FantLab = require('../providers/FantLab') +const AudiobookCovers = require('../providers/AudiobookCovers') const Logger = require('../Logger') const { levenshteinDistance } = require('../utils/index') @@ -15,6 +16,7 @@ class BookFinder { this.iTunesApi = new iTunes() this.audnexus = new Audnexus() this.fantLab = new FantLab() + this.audiobookCovers = new AudiobookCovers() this.verbose = false } @@ -159,6 +161,16 @@ class BookFinder { return books } + async getAudiobookCoversResults(search) { + const covers = await this.audiobookCovers.search(search) + if (this.verbose) Logger.debug(`AudiobookCovers Book Search Results: ${books.length || 0}`) + if (covers.errorCode) { + Logger.error(`AusiobookCovers Search Error ${books.errorCode}`) + return [] + } + return covers + } + async getiTunesAudiobooksResults(title, author) { return this.iTunesApi.searchAudiobooks(title) } @@ -187,11 +199,15 @@ class BookFinder { books = await this.getOpenLibResults(title, author, maxTitleDistance, maxAuthorDistance) } else if (provider === 'fantlab') { books = await this.getFantLabResults(title, author) + } else if (provider === 'audiobookcovers') { + books = await this.getAudiobookCoversResults(title) } else { books = await this.getGoogleBooksResults(title, author) } + console.log(books) + if (!books.length && !options.currentlyTryingCleaned) { var cleanedTitle = this.cleanTitleForCompares(title) var cleanedAuthor = this.cleanAuthorForCompares(author) diff --git a/server/providers/AudiobookCovers.js b/server/providers/AudiobookCovers.js new file mode 100644 index 00000000..b969fba3 --- /dev/null +++ b/server/providers/AudiobookCovers.js @@ -0,0 +1,26 @@ +const axios = require('axios') +const Logger = require('../Logger') + +class AudiobookCovers { + constructor() { } + + async search(search) { + const url = `https://api.audiobookcovers.com/cover/bytext/` + const params = new URLSearchParams([['q', search]]) + const items = await axios.get(url, { params }).then((res) => { + if (!res || !res.data) return [] + return res.data + }).catch(error => { + Logger.error('[AudiobookCovers] Cover search error', error) + return [] + }) + // console.log(items) + // return items as an array of objects, each object contains: + // cover: item.filename + return items.map(item => { return { cover: item.filename } }) + } +} + + + +module.exports = AudiobookCovers