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

All 8* covers now in zips #9712

Merged
merged 1 commit into from
Aug 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions openlibrary/coverstore/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,14 @@ def zipview_url_from_id(coverid, size):
return f"{protocol}://archive.org/download/{itemid}/{zipfile}/{filename}"


def tarview_url_from_id(coverid: int, size: str | None) -> str:
def old_zipview_url_from_id(coverid: int, size: str | None) -> str:
"""
The path for images in the old style, e.g. item `l_covers_0008` scheme
"""
prefix = f"{size.lower()}_" if size else ""
pid = "%010d" % coverid
item_id = f"{prefix}covers_{pid[:4]}"
item_tar = f"{prefix}covers_{pid[:4]}_{pid[4:6]}.tar"
item_tar = f"{prefix}covers_{pid[:4]}_{pid[4:6]}.zip"
item_file = f"{pid}{'-' + size.upper() if size else ''}"
protocol = web.ctx.protocol
return f"{protocol}://archive.org/download/{item_id}/{item_tar}/{item_file}.jpg"
Expand Down Expand Up @@ -279,12 +282,8 @@ def notfound():
# - the naming scheme is the older scheme used by .tar files
# (eg item `l_covers_0008` instead of `olcovers9`
# - the db is not yet updated with their correct URLs
if size == "L" and 8_820_000 > value >= 8_000_000:
return web.found(tarview_url_from_id(value, size).replace('.tar', '.zip'))

# covers_0008 batches [_00, _82] are tar'd / zip'd in archive.org items
if 8_820_000 > value >= 8_000_000:
return web.found(tarview_url_from_id(value, size))
return web.found(old_zipview_url_from_id(value, size))

d = self.get_details(value, size.lower())
if not d:
Expand Down
Loading