From 089864eb1b5a3e328c7e2dd1415f80ead0416fc0 Mon Sep 17 00:00:00 2001 From: Mike Bennett Date: Thu, 1 Jun 2023 19:40:42 +0200 Subject: [PATCH] Add first pass video manifest --- iiify/resolver.py | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/iiify/resolver.py b/iiify/resolver.py index c599f1d..2cd4fdf 100644 --- a/iiify/resolver.py +++ b/iiify/resolver.py @@ -33,7 +33,8 @@ def to_mimetype(format): "VBR MP3": "audio/mp3", "Flac": "audio/flac", "Ogg Vorbis": "audio/ogg", - "WAVE": "audio/wav" + "WAVE": "audio/wav", + "MPEG4": "video/mp4" } return formats.get(format, "application/octet-stream") @@ -340,6 +341,30 @@ def create_manifest3(identifier, domain=None, page=None): ap.add_item(anno) c.add_item(ap) manifest.add_item(c) + + elif mediatype == "movies": + canvas_files = [f for f in metadata['files'] if f['source'].lower() == 'original' and f['format'] == "MPEG4"] + for file in canvas_files: + normalised_id = file['name'].rsplit(".", 1)[0] + slugged_id = normalised_id.replace(" ", "-") + c_id = f"https://iiif.archivelab.org/iiif/{identifier}/{slugged_id}/canvas" + c = Canvas(id=c_id, label=normalised_id, duration=float(file['length']), height=int(file['height']), width=int(file['width'])) + ap = AnnotationPage(id=f"https://iiif.archivelab.org/iiif/{identifier}/{slugged_id}/page") + anno = Annotation(id=f"https://iiif.archivelab.org/iiif/{identifier}/{slugged_id}/annotation", motivation="painting", target=c.id) + r = ResourceItem( + id=f"https://archive.org/download/{identifier}/{file['name'].replace(' ', '%20')}", + type='Video', + format=to_mimetype(file['format']), + label={"none": [file['format']]}, + duration=float(file['length']), + height=int(file['height']), + width=int(file['width']) + ) + anno.body = r + ap.add_item(anno) + c.add_item(ap) + manifest.add_item(c) + else: print (f'Unknown mediatype "{mediatype}"')