Skip to content

Commit

Permalink
fix(serializers): cleanup get_folio to return the correct page
Browse files Browse the repository at this point in the history
  • Loading branch information
b1rger committed Sep 30, 2024
1 parent fceff0d commit 1f4a7f4
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions apis_ontology/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,21 @@ def get_folio(obj):
page = f"{page:03d}"
if obj.folio:
page = obj.folio
if "-" in obj.folio:
page = obj.folio.split("-")[0]
if "–" in obj.folio:
page = obj.folio.split("–")[0]
if page:
if match := NUMBER.match(page):
page = match["number"]
if page.endswith("v") or page.endswith("r"):
page = page[:-1]
suffix = ""
if page.endswith("v"):
suffix = "v"
pagenr = page[:-1]
if page.endswith("r"):
suffix = "r"
pagenr = page[:-1]
try:
page = int(page)
page = f"{page:03d}"
pagenr = int(pagenr)
page = f"{pagenr:03d}"
except Exception:
pass
page += suffix
if page:
matches = [scanfile for scanfile in iiif_titles()[title] if page in scanfile]
if matches:
Expand Down

0 comments on commit 1f4a7f4

Please sign in to comment.