mirror of
				https://github.com/advplyr/audiobookshelf.git
				synced 2025-10-27 11:18:14 +01:00 
			
		
		
		
	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:
		
							parent
							
								
									6ae3ad508e
								
							
						
					
					
						commit
						f9ed412e4e
					
				@ -49,13 +49,13 @@
 | 
				
			|||||||
    </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-40 px-1">
 | 
					        <div class="w-45 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">
 | 
				
			||||||
          <ui-text-input-with-label v-model="searchTitle" :label="searchTitleLabel" :placeholder="$strings.PlaceholderSearch" />
 | 
					          <ui-text-input-with-label v-model="searchTitle" :label="searchTitleLabel" :placeholder="$strings.PlaceholderSearch" />
 | 
				
			||||||
        </div>
 | 
					        </div>
 | 
				
			||||||
        <div v-show="provider != 'itunes'" class="w-72 px-1">
 | 
					        <div v-show="provider != 'itunes' && provider != 'audiobookcovers'" class="w-72 px-1">
 | 
				
			||||||
          <ui-text-input-with-label v-model="searchAuthor" :label="$strings.LabelAuthor" />
 | 
					          <ui-text-input-with-label v-model="searchAuthor" :label="$strings.LabelAuthor" />
 | 
				
			||||||
        </div>
 | 
					        </div>
 | 
				
			||||||
        <ui-btn class="mt-5 ml-1" type="submit">{{ $strings.ButtonSearch }}</ui-btn>
 | 
					        <ui-btn class="mt-5 ml-1" type="submit">{{ $strings.ButtonSearch }}</ui-btn>
 | 
				
			||||||
@ -128,7 +128,7 @@ export default {
 | 
				
			|||||||
    },
 | 
					    },
 | 
				
			||||||
    providers() {
 | 
					    providers() {
 | 
				
			||||||
      if (this.isPodcast) return this.$store.state.scanners.podcastProviders
 | 
					      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() {
 | 
					    searchTitleLabel() {
 | 
				
			||||||
      if (this.provider.startsWith('audible')) return this.$strings.LabelSearchTitleOrASIN
 | 
					      if (this.provider.startsWith('audible')) return this.$strings.LabelSearchTitleOrASIN
 | 
				
			||||||
 | 
				
			|||||||
@ -63,6 +63,12 @@ export const state = () => ({
 | 
				
			|||||||
      text: 'iTunes',
 | 
					      text: 'iTunes',
 | 
				
			||||||
      value: 'itunes'
 | 
					      value: 'itunes'
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					  ],
 | 
				
			||||||
 | 
					  coverOnlyProviders: [
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      text: 'AudiobookCovers.com',
 | 
				
			||||||
 | 
					      value: 'audiobookcovers'
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
  ]
 | 
					  ]
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -4,6 +4,7 @@ const Audible = require('../providers/Audible')
 | 
				
			|||||||
const iTunes = require('../providers/iTunes')
 | 
					const iTunes = require('../providers/iTunes')
 | 
				
			||||||
const Audnexus = require('../providers/Audnexus')
 | 
					const Audnexus = require('../providers/Audnexus')
 | 
				
			||||||
const FantLab = require('../providers/FantLab')
 | 
					const FantLab = require('../providers/FantLab')
 | 
				
			||||||
 | 
					const AudiobookCovers = require('../providers/AudiobookCovers')
 | 
				
			||||||
const Logger = require('../Logger')
 | 
					const Logger = require('../Logger')
 | 
				
			||||||
const { levenshteinDistance } = require('../utils/index')
 | 
					const { levenshteinDistance } = require('../utils/index')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -15,6 +16,7 @@ class BookFinder {
 | 
				
			|||||||
    this.iTunesApi = new iTunes()
 | 
					    this.iTunesApi = new iTunes()
 | 
				
			||||||
    this.audnexus = new Audnexus()
 | 
					    this.audnexus = new Audnexus()
 | 
				
			||||||
    this.fantLab = new FantLab()
 | 
					    this.fantLab = new FantLab()
 | 
				
			||||||
 | 
					    this.audiobookCovers = new AudiobookCovers()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    this.verbose = false
 | 
					    this.verbose = false
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@ -159,6 +161,16 @@ class BookFinder {
 | 
				
			|||||||
    return books
 | 
					    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) {
 | 
					  async getiTunesAudiobooksResults(title, author) {
 | 
				
			||||||
    return this.iTunesApi.searchAudiobooks(title)
 | 
					    return this.iTunesApi.searchAudiobooks(title)
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@ -187,11 +199,15 @@ class BookFinder {
 | 
				
			|||||||
      books = await this.getOpenLibResults(title, author, maxTitleDistance, maxAuthorDistance)
 | 
					      books = await this.getOpenLibResults(title, author, maxTitleDistance, maxAuthorDistance)
 | 
				
			||||||
    } else if (provider === 'fantlab') {
 | 
					    } else if (provider === 'fantlab') {
 | 
				
			||||||
      books = await this.getFantLabResults(title, author)
 | 
					      books = await this.getFantLabResults(title, author)
 | 
				
			||||||
 | 
					    } else if (provider === 'audiobookcovers') {
 | 
				
			||||||
 | 
					      books = await this.getAudiobookCoversResults(title)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    else {
 | 
					    else {
 | 
				
			||||||
      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)
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										26
									
								
								server/providers/AudiobookCovers.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								server/providers/AudiobookCovers.js
									
									
									
									
									
										Normal file
									
								
							@ -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
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user