Skip to content

Commit

Permalink
Encoding thumbnail urls (#83)
Browse files Browse the repository at this point in the history
* Encoding thumbnail urls
* Fixing missing video in #82

---------

Co-authored-by: Mek <[email protected]>
  • Loading branch information
glenrobson and mekarpeles authored Oct 8, 2024
1 parent 7d2b336 commit 4bfadf8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
6 changes: 4 additions & 2 deletions iiify/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ def addThumbnails(manifest, identifier, files):
mimetype = "image/png"

thumbnails.append({
"id": f"{ARCHIVE}/download/{identifier}/{file['name']}",
"id": f"{ARCHIVE}/download/{quote(identifier)}/{quote(file['name'])}",
"type": "Image",
"format": mimetype,
})
Expand Down Expand Up @@ -722,7 +722,9 @@ def create_manifest3(identifier, domain=None, page=None):
duration = float(file['length'])
filedata = file

normalised_id = mp4File.rsplit(".", 1)[0]
# create the canvases for each original
for file in [f for f in originals if f['format'] in ['MPEG4', 'h.264 HD', 'h.264 MPEG4', '512Kb MPEG4', 'HiRes MPEG4', 'MPEG2', 'h.264', 'Matroska', 'Ogg Video', 'Ogg Theora', 'WebM', 'Windows Media', 'Cinepack','QuickTime']]:
normalised_id = file['name'].rsplit(".", 1)[0]
slugged_id = normalised_id.replace(" ", "-")
c_id = f"{URI_PRIFIX}/{identifier}/{slugged_id}/canvas"
c = Canvas(id=c_id, label=normalised_id, duration=duration, height=int(filedata['height']), width=int(filedata['width']))
Expand Down
17 changes: 17 additions & 0 deletions tests/test_manifests.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,23 @@ def test_multi_file(self):
manifest = resp.json
self.assertEqual(len(manifest['items']),6, f"Expected five canvases, but got {len(manifest['items'])}")

def test_encoded_thumb(self):
resp = self.test_app.get("/iiif/3/steamboat-willie-16mm-film-scan-4k-lossless/manifest.json")
self.assertEqual(resp.status_code, 200)
manifest = resp.json
self.assertEqual(len(manifest['thumbnail']),15, f"Expected 15 thumbnails, but got {len(manifest['thumbnail'])}")
self.assertEqual(manifest['thumbnail'][0]['id'],"https://archive.org/download/steamboat-willie-16mm-film-scan-4k-lossless/steamboat-willie-16mm-film-scan-4k-lossless.thumbs/Steamboat%20Willie%20%5B16mm%20Film%20Scan%5D_ProRes%20%283400x2550%29_000001.jpg", f"Expected URL to be encoded")

self.assertEqual(len(manifest['items']),1, f"Expected 1 canvas, but got {len(manifest['items'])}")

def test_hd_manifest(self):
resp = self.test_app.get("/iiif/3/cc4ia-Polar_Plunge_Promo_-_2018/manifest.json")
self.assertEqual(resp.status_code, 200)
manifest = resp.json

self.assertEqual(len(manifest['items']),1, f"Expected 1 canvas, but got {len(manifest['items'])}")



''' to test:
kaled_jalil (no derivatives)
Expand Down

0 comments on commit 4bfadf8

Please sign in to comment.