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

Encoding thumbnail urls #83

Merged
merged 3 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
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
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
Loading