Skip to content

Commit

Permalink
Use Choice class.
Browse files Browse the repository at this point in the history
  • Loading branch information
markpbaggett committed Dec 6, 2024
1 parent 119abe0 commit c905e61
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions docs/recipes/scripts/0074-multiple-language-captions-method1.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from iiif_prezi3 import Manifest, ResourceItem, AnnotationPage, Annotation, KeyValueString, config
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"
Expand All @@ -14,36 +14,26 @@
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)

anno_body = ResourceItem(
id="https://fixtures.iiif.io/video/indiana/lunchroom_manners/high/lunchroom_manners_1024kb.mp4",
type="Choice",
format="video/mp4"
)

italian_captions = ResourceItem(
id=f"{base_url}/Per_voi_signore_Modelli_francesi_it.vtt",
type="Text",
Expand All @@ -58,16 +48,15 @@
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={
"type": "Choice",
"items": [english_captions, italian_captions]
},
body=choice,
target=canvas.id,
anno_page_id=f"{base_url}/manifest.json/anno/page/1"
)

print(manifest.json(indent=2))

0 comments on commit c905e61

Please sign in to comment.