Add AudiobookCovers.com metadata provider

AudiobookCovers.com acts as a cover-only metadata provider, therefore will only show up in the covers selector.
This commit is contained in:
Spenser Bushey 2023-04-19 22:13:52 -07:00
parent 6ae3ad508e
commit f9ed412e4e
4 changed files with 51 additions and 3 deletions

View file

@ -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)