Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cover not showing on merge toolbar or author page #9064

Open
RayBB opened this issue Apr 10, 2024 · 6 comments · May be fixed by #9131
Open

Cover not showing on merge toolbar or author page #9064

RayBB opened this issue Apr 10, 2024 · 6 comments · May be fixed by #9131
Assignees
Labels
Lead: @scottbarnes Issues overseen by Scott (Community Imports) Module: Cover Service Cover Store (book covers service) Priority: 3 Issues that we can consider at our leisure. [managed] Type: Bug Something isn't working. [managed]

Comments

@RayBB
Copy link
Collaborator

RayBB commented Apr 10, 2024

Problem

Why does this cover, which has been there since last year, not show on either of these page spots?

Evidence / Screenshot

image image

Relevant URL(s)

Reproducing the bug

  1. Go to ...
  2. Do ...
  • Expected behavior:
  • Actual behavior:

Context

  • Browser (Chrome, Safari, Firefox, etc):
  • OS (Windows, Mac, etc):
  • Logged in (Y/N): Y
  • Environment (prod, dev, local): prod

Notes from this Issue's Lead

Proposal & constraints

Related files

Stakeholders

@RayBB RayBB added Type: Bug Something isn't working. [managed] Needs: Triage This issue needs triage. The team needs to decide who should own it, what to do, by when. [managed] Needs: Lead labels Apr 10, 2024
@jjessieyang
Copy link

Hi! I would like to try to work on this task, could I be assigned to this?

@RayBB
Copy link
Collaborator Author

RayBB commented Apr 11, 2024

@jjessieyang I assigned you to work on it. Good luck!

@RayBB RayBB changed the title Cover now showing on merge toolbar or author page Cover not showing on merge toolbar or author page Apr 11, 2024
@jjessieyang
Copy link

I'm having some trouble setting things up locally. I think I've followed all the guides for setting up docker, production book data, etc. as best I can, but I still can't see any books other than what's provided in the pre-loaded dataset or links to view by Subjects. I've read through issue #1864 but I still can't get it to work locally. How should I go about working on this task? This is my first time contributing to an open source project so any advice is greatly appreciated. Thank you!

@RayBB
Copy link
Collaborator Author

RayBB commented Apr 12, 2024

@jjessieyang
In this case, you don't need those particular books. However, if you want to load those you can run a command like this to load those particular books.
docker compose exec -e PYTHONPATH=. web bash -c "./scripts/copydocs.py --search 'author_key:OL12180252A' --search-limit 100"

Let me know if you have further questions.

@jjessieyang
Copy link

Okay thank you! Do you have any suggestions on where I should look to fix this bug? I think I'm also just a bit confused why this book is the only one that has this error.

@scottbarnes
Copy link
Collaborator

scottbarnes commented Apr 15, 2024

@jjessieyang, one approach can be to try to figure out what's different between the working case and the not working case. Here, it looks as if this cover is coming from Internet Archive's cover service rather than from Open Library's. Were I to hazard a guess as to what's going on, I would say that the places that the cover doesn't show up aren't using Internet Archive's cover service as a fall back.

If you visit https://openlibrary.org/works/OL33647732W.json and https://openlibrary.org/books/OL45606286M.json you'll see that this book doesn't have a cover, yet curiously one shows up. C.f. https://openlibrary.org/works/OL66554W.json, which does have a cover.

If you mouse over the cover image where it does display for the book in this issue, you can see that unlike many covers on Open Library, the link isn't to covers.openlibrary.org/something, but to https://archive.org/download/heraldosdelpacha0000chur/page/cover_w180_h360.jpg.

If you do git grep "archive.org/download" there are some promising targets, including return f"https://archive.org/download/{itemid}/page/cover_w{w}_h{h}.jpg" from openlibrary/plugins/upstream/models.py, which looks pretty spot on. That will lead to get_ia_cover() and get_cover_url(), which will probably begin to unravel the mystery:

def get_cover_url(self, size):
if cover := self.get_cover():
return cover.url(size)
elif self.ocaid:
return self.get_ia_cover(self.ocaid, size)
def get_ia_cover(self, itemid, size):
image_sizes = {"S": (116, 58), "M": (180, 360), "L": (500, 500)}
w, h = image_sizes[size.upper()]
return f"https://archive.org/download/{itemid}/page/cover_w{w}_h{h}.jpg"

Note: a better git grep might be git grep -E "download/.+/page/cover_.+"

From here you'll want to look into how the 'broken' images are being loaded. As a quick sketch, you might want to right click -> 'inspect' the elements that are broken. For example, if you do that on image in the lower left of the screen where it says "1 edition selected" (i.e. the place with the red arrow pointing to it in the first image in this issue summary), you'll see:

<img title="OL45606286M" src="https://covers.openlibrary.org/b/olid/OL45606286M-M.jpg?default=https://openlibrary.org/images/icons/avatar_book-lg.png">

With the help of git grep, you should find your way to utils/SelectionManager/SelectionManager.js. You'll see there that the image resolution strategy is different.

Hopefully that gets you started.

If you get stuck, please ask questions.

@mekarpeles mekarpeles added Priority: 3 Issues that we can consider at our leisure. [managed] Lead: @scottbarnes Issues overseen by Scott (Community Imports) Module: Cover Service Cover Store (book covers service) and removed Needs: Triage This issue needs triage. The team needs to decide who should own it, what to do, by when. [managed] Needs: Lead labels Apr 15, 2024
@jjessieyang jjessieyang linked a pull request Apr 21, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Lead: @scottbarnes Issues overseen by Scott (Community Imports) Module: Cover Service Cover Store (book covers service) Priority: 3 Issues that we can consider at our leisure. [managed] Type: Bug Something isn't working. [managed]
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants