Skip to content

map_folios.py fails for IIIF Presentation 3 manifests #954

@kyrieb-ekat

Description

@kyrieb-ekat

This would be the root cause of the wonkiness in the folios!

The folio mapping tool (cantusdata/views/map_folios.py) hardcodes IIIF
Presentation 2 manifest structure, causing it to fail for any manuscript
whose manifest uses the Presentation 3 format.

Root cause:

_extract_uris_from_manifest() accesses:

manifest_data["sequences"][0]["canvases"]

This key (sequences) does not exist in Presentation 3 manifests, which
use items instead. The canvas image structure also differs:

# Presentation 2
canvas["images"][0]["resource"]["service"]["@id"]

# Presentation 3
canvas["items"][0]["items"][0]["body"]["service"]["id"]

Additionally, the function fetches the manifest directly via urllib rather
than going through the manifest proxy, meaning none of the postprocessing
in cantusdata/helpers/postprocess_iiif.py is applied.

Steps to reproduce:

  1. Add a manuscript with a IIIF Presentation 3 manifest URL via the admin
  2. Import its chants
  3. Navigate to /admin/map_folios/ and attempt to map the manuscript
  4. Observe a KeyError: 'sequences'

Expected behaviour: The mapping tool correctly extracts image URIs from
both Presentation 2 and Presentation 3 manifests.

Suggested fix: Update _extract_uris_from_manifest() to detect the
manifest version via @context (as Diva's parser does) and branch
accordingly. Routing the fetch through the manifest proxy would also ensure
consistent postprocessing.

Metadata

Metadata

Assignees

Labels

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions