Cleanup audiobookcovers.com addition

This commit is contained in:
advplyr 2023-04-21 16:17:52 -05:00
parent 1342897858
commit 84839bea44
3 changed files with 10 additions and 14 deletions

View File

@ -49,7 +49,7 @@
</div> </div>
<form @submit.prevent="submitSearchForm"> <form @submit.prevent="submitSearchForm">
<div class="flex items-center justify-start -mx-1 h-20"> <div class="flex items-center justify-start -mx-1 h-20">
<div class="w-45 px-1"> <div class="w-48 px-1">
<ui-dropdown v-model="provider" :items="providers" :label="$strings.LabelProvider" small /> <ui-dropdown v-model="provider" :items="providers" :label="$strings.LabelProvider" small />
</div> </div>
<div class="w-72 px-1"> <div class="w-72 px-1">

View File

@ -163,12 +163,8 @@ class BookFinder {
async getAudiobookCoversResults(search) { async getAudiobookCoversResults(search) {
const covers = await this.audiobookCovers.search(search) const covers = await this.audiobookCovers.search(search)
if (this.verbose) Logger.debug(`AudiobookCovers Book Search Results: ${books.length || 0}`) if (this.verbose) Logger.debug(`AudiobookCovers Search Results: ${covers.length || 0}`)
if (covers.errorCode) { return covers || []
Logger.error(`AusiobookCovers Search Error ${books.errorCode}`)
return []
}
return covers
} }
async getiTunesAudiobooksResults(title, author) { async getiTunesAudiobooksResults(title, author) {
@ -206,8 +202,6 @@ class BookFinder {
books = await this.getGoogleBooksResults(title, author) books = await this.getGoogleBooksResults(title, author)
} }
console.log(books)
if (!books.length && !options.currentlyTryingCleaned) { if (!books.length && !options.currentlyTryingCleaned) {
var cleanedTitle = this.cleanTitleForCompares(title) var cleanedTitle = this.cleanTitleForCompares(title)
var cleanedAuthor = this.cleanAuthorForCompares(author) var cleanedAuthor = this.cleanAuthorForCompares(author)
@ -218,13 +212,15 @@ class BookFinder {
return this.search(provider, cleanedTitle, cleanedAuthor, isbn, asin, options) return this.search(provider, cleanedTitle, cleanedAuthor, isbn, asin, options)
} }
if (["google", "audible", "itunes", 'fantlab'].includes(provider)) return books if (provider === 'openlibrary') {
books.sort((a, b) => {
return books.sort((a, b) => {
return a.totalDistance - b.totalDistance return a.totalDistance - b.totalDistance
}) })
} }
return books
}
async findCovers(provider, title, author, options = {}) { async findCovers(provider, title, author, options = {}) {
var searchResults = await this.search(provider, title, author, options) var searchResults = await this.search(provider, title, author, options)
Logger.debug(`[BookFinder] FindCovers search results: ${searchResults.length}`) Logger.debug(`[BookFinder] FindCovers search results: ${searchResults.length}`)

View File

@ -14,7 +14,7 @@ class AudiobookCovers {
Logger.error('[AudiobookCovers] Cover search error', error) Logger.error('[AudiobookCovers] Cover search error', error)
return [] return []
}) })
return items.map(item => { return { cover: item.filename } }) return items.map(item => ({ cover: item.filename }))
} }
} }