Skip to content

Commit

Permalink
fix(serializers): undo last commit and add folio fix
Browse files Browse the repository at this point in the history
  • Loading branch information
b1rger committed Sep 30, 2024
1 parent 1f4a7f4 commit ac4aa45
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions apis_ontology/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,22 @@ 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]
suffix = ""
if page.endswith("v"):
suffix = "v"
pagenr = page[:-1]
if page.endswith("r"):
suffix = "r"
pagenr = page[:-1]
if page.endswith("v") or page.endswith("r"):
suffix = page[-1:]
if page:
if match := NUMBER.match(page):
page = match["number"]
if page.endswith("v") or page.endswith("r"):
page = page[:-1]
try:
pagenr = int(pagenr)
page = f"{pagenr:03d}"
page = int(page)
page = f"{page:03d}{suffix}"
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 ac4aa45

Please sign in to comment.