Skip to content

Commit

Permalink
fix cover image loading on author page (#9967)
Browse files Browse the repository at this point in the history
  • Loading branch information
siddarth2810 authored Nov 3, 2024
1 parent e953316 commit b8cea03
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions openlibrary/book_providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,14 +550,8 @@ def get_cover_url(ed_or_solr: Edition | dict) -> str | None:
return cover.url(size) if cover else None

# Solr edition
elif ed_or_solr['key'].startswith('/books/'):
if ed_or_solr.get('cover_i'):
return (
get_coverstore_public_url()
+ f'/b/id/{ed_or_solr["cover_i"]}-{size}.jpg'
)
else:
return None
elif ed_or_solr['key'].startswith('/books/') and ed_or_solr.get('cover_i'):
return get_coverstore_public_url() + f'/b/id/{ed_or_solr["cover_i"]}-{size}.jpg'

# Solr document augmented with availability
availability = ed_or_solr.get('availability', {}) or {}
Expand All @@ -567,7 +561,7 @@ def get_cover_url(ed_or_solr: Edition | dict) -> str | None:
return f"{get_coverstore_public_url()}/b/olid/{olid}-{size}.jpg"
if availability.get('identifier'):
ocaid = ed_or_solr['availability']['identifier']
return f"//archive.org/services/img/{ocaid}"
return f"https://archive.org/download/{ocaid}/page/cover_w180_h360.jpg"

# Plain solr - we don't know which edition is which here, so this is most
# preferable
Expand Down

0 comments on commit b8cea03

Please sign in to comment.