Update:Select largest cover image from Google Books provider #1244

This commit is contained in:
advplyr 2022-12-15 17:54:02 -06:00
parent 4fcdeda447
commit a68ade2b3d

View File

@ -15,7 +15,13 @@ class GoogleBooks {
cleanResult(item) { cleanResult(item) {
var { id, volumeInfo } = item var { id, volumeInfo } = item
if (!volumeInfo) return null if (!volumeInfo) return null
var { title, subtitle, authors, publisher, publisherDate, description, industryIdentifiers, categories, imageLinks } = volumeInfo const { title, subtitle, authors, publisher, publisherDate, description, industryIdentifiers, categories, imageLinks } = volumeInfo
let cover = null
// Selects the largest cover assuming the largest is the last key in the object
if (imageLinks && Object.keys(imageLinks).length) {
cover = imageLinks[Object.keys(imageLinks).pop()] || null
}
return { return {
id, id,
@ -25,7 +31,7 @@ class GoogleBooks {
publisher, publisher,
publishedYear: publisherDate ? publisherDate.split('-')[0] : null, publishedYear: publisherDate ? publisherDate.split('-')[0] : null,
description, description,
cover: imageLinks && imageLinks.thumbnail ? imageLinks.thumbnail : null, cover,
genres: categories && Array.isArray(categories) ? [...categories] : null, genres: categories && Array.isArray(categories) ? [...categories] : null,
isbn: this.extractIsbn(industryIdentifiers) isbn: this.extractIsbn(industryIdentifiers)
} }