diff --git a/docs/recipes/0074-multiple-language-captions.md b/docs/recipes/0074-multiple-language-captions.md new file mode 100644 index 0000000..8c09cdf --- /dev/null +++ b/docs/recipes/0074-multiple-language-captions.md @@ -0,0 +1,10 @@ +# Using Caption and Subtitle Files in Multiple Languages with Video Content +| | **Cookbook URLs** | +|--------------|-------------------| +| **Recipe:** | [https://iiif.io/api/cookbook/recipe/0074-multiple-language-captions/](https://iiif.io/api/cookbook/recipe/0074-multiple-language-captions/) | +| **JSON-LD:** | [https://iiif.io/api/cookbook/recipe/0074-multiple-language-captions/manifest.json](https://iiif.io/api/cookbook/recipe/0074-multiple-language-captions/manifest.json) | + +### Method 1 - Construct Supplementing Annotation Using the `make_annotation` helper and a dictionary of the `body` properties +```python +--8<-- "docs/recipes/scripts/0074-multiple-language-captions-method1.py" +``` \ No newline at end of file diff --git a/docs/recipes/scripts/0074-multiple-language-captions-method1.py b/docs/recipes/scripts/0074-multiple-language-captions-method1.py new file mode 100644 index 0000000..d210170 --- /dev/null +++ b/docs/recipes/scripts/0074-multiple-language-captions-method1.py @@ -0,0 +1,62 @@ +from iiif_prezi3 import Manifest, ResourceItem, AnnotationPage, Annotation, KeyValueString, config, Choice + +config.configs['helpers.auto_fields.AutoLang'].auto_lang = "en" +base_url = "https://iiif.io/api/cookbook/recipe/0074-multiple-language-captions" + +manifest = Manifest( + id=f"{base_url}/manifest.json", + label="For ladies. French models", + rights="http://rightsstatements.org/vocab/InC/1.0/", + requiredStatement=KeyValueString(label="Rights", value="All rights reserved Cinecittà Luce spa") +) +manifest.add_label(language="it", value="Per voi signore. Modelli francesi") + +canvas = manifest.make_canvas( + id=f"{base_url}/canvas" +) +video_resource = ResourceItem( + id="https://fixtures.iiif.io/video/europeana/Per_voi_signore_Modelli_francesi.mp4", + type="Video", + format="video/mp4" +) +video_hwd = {"height": 384, "width": 288, "duration": 65.0} +video_resource.set_hwd(**video_hwd) +canvas.set_hwd(**video_hwd) +painting_annotation = Annotation( + id=f"{base_url}/canvas/page/annotation", + motivation="painting", + body=video_resource, + target=canvas.id +) +annotation_page = AnnotationPage( + id=f"{base_url}/canvas/page" +) +annotation_page.add_item(painting_annotation) +canvas.add_item(annotation_page) + +italian_captions = ResourceItem( + id=f"{base_url}/Per_voi_signore_Modelli_francesi_it.vtt", + type="Text", + format="text/vtt", + language="it", +) +italian_captions.add_label(language="it", value="Sottotitoli in formato WebVTT") +english_captions = ResourceItem( + id=f"{base_url}/Per_voi_signore_Modelli_francesi_en.vtt", + type="Text", + format="text/vtt", + language="en" +) +english_captions.add_label(language="en", value="Captions in WebVTT format") +choice = Choice( + items=[english_captions, italian_captions] +) + +caption_annotation = canvas.make_annotation( + id=f"{base_url}/manifest.json/subtitles_captions-files-vtt", + motivation="supplementing", + body=choice, + target=canvas.id, + anno_page_id=f"{base_url}/manifest.json/anno/page/1" +) +print(manifest.json(indent=2))