Skip to content

Commit

Permalink
fix: fixed thumbnail for google
Browse files Browse the repository at this point in the history
  • Loading branch information
mbret committed May 27, 2024
1 parent a5235d6 commit 0e4d1fd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
8 changes: 7 additions & 1 deletion packages/api/src/libs/google/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ export type Item = {
averageRating?: number
readingModes?: ReadingMode[]
description?: string
imageLinks?: { thumbnail?: string; smallThumbnails?: string }
imageLinks?: {
thumbnail?: string
smallThumbnails?: string
small?: string
medium?: string
large?: string
}
maturityRating?: "NOT_MATURE"
seriesInfo?: {
bookDisplayNumber?: string // number as string
Expand Down
12 changes: 8 additions & 4 deletions packages/api/src/libs/metadata/google/parseGoogleMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@ export const parseGoogleMetadata = (

if (!item) return {}

coverLink = item.volumeInfo.imageLinks?.thumbnail?.replace(
"zoom=1",
"zoom=2"
)
// lookup highest required resolution
const imageLinks = item.volumeInfo.imageLinks ?? {}
coverLink =
imageLinks["large"] ??
imageLinks["medium"] ??
imageLinks["thumbnail"] ??
imageLinks["small"] ??
imageLinks["smallThumbnails"]

let title = item.volumeInfo.title

Expand Down

0 comments on commit 0e4d1fd

Please sign in to comment.