-
Notifications
You must be signed in to change notification settings - Fork 12
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
Add recipe for 0074 Multiple Language Captions. #197
Merged
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
be7deba
Add recipe for 0074.
markpbaggett cb1eab3
Init refactor.
markpbaggett cbcf8dd
Init refactor.
markpbaggett 119abe0
Refactor to better use library.
markpbaggett c905e61
Use Choice class.
markpbaggett 3edd8a9
Replace gross dict.
markpbaggett File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
``` |
79 changes: 79 additions & 0 deletions
79
docs/recipes/scripts/0074-multiple-language-captions-method1.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
from iiif_prezi3 import Manifest, ResourceItem, AnnotationPage, Annotation | ||
|
||
manifest = Manifest( | ||
id="https://iiif.io/api/cookbook/recipe/0074-multiple-language-captions/manifest.json", | ||
label={"it": ["Per voi signore. Modelli francesi"]}, | ||
rights="http://rightsstatements.org/vocab/InC/1.0/", | ||
requiredStatement={ | ||
"label": { | ||
"en": [ | ||
"Rights" | ||
] | ||
}, | ||
"value": { | ||
"en": [ | ||
"All rights reserved Cinecittà Luce spa" | ||
] | ||
} | ||
} | ||
) | ||
manifest.add_label( | ||
language="en", | ||
value="For ladies. French models" | ||
) | ||
canvas = manifest.make_canvas(id="https://iiif.io/api/cookbook/recipe/0074-multiple-language-captions/canvas") | ||
painting_anno_body = ResourceItem( | ||
id="https://fixtures.iiif.io/video/europeana/Per_voi_signore_Modelli_francesi.mp4", | ||
type="Video", | ||
format="video/mp4" | ||
) | ||
painting_anno_page = AnnotationPage( | ||
id="https://iiif.io/api/cookbook/recipe/0074-multiple-language-captions/canvas/page" | ||
) | ||
painting_anno = Annotation( | ||
id="https://iiif.io/api/cookbook/recipe/0074-multiple-language-captions/canvas/page/annotation", | ||
motivation="painting", | ||
body=painting_anno_body, | ||
target=canvas.id | ||
) | ||
hwd = {"height": 384, "width": 288, "duration": 65.0} | ||
italian_captions = { | ||
"id": "https://iiif.io/api/cookbook/recipe/0074-multiple-language-captions/Per_voi_signore_Modelli_francesi_it.vtt", | ||
"type": "Text", | ||
"format": "text/vtt", | ||
"label": { | ||
"it": [ | ||
"Sottotitoli in formato WebVTT" | ||
] | ||
}, | ||
"language": "it" | ||
} | ||
english_captions = { | ||
"id": "https://iiif.io/api/cookbook/recipe/0074-multiple-language-captions/Per_voi_signore_Modelli_francesi_en.vtt", | ||
"type": "Text", | ||
"format": "text/vtt", | ||
"label": { | ||
"en": [ | ||
"Captions in WebVTT format" | ||
] | ||
}, | ||
"language": "en" | ||
} | ||
painting_anno_body.set_hwd(**hwd) | ||
canvas.set_hwd(**hwd) | ||
painting_anno_page.add_item(painting_anno) | ||
canvas.add_item(painting_anno_page) | ||
captions = canvas.make_annotation( | ||
id="https://iiif.io/api/cookbook/recipe/0074-multiple-language-captions/manifest.json/subtitles_captions-files-vtt", | ||
motivation="supplementing", | ||
body={ | ||
"type": "Choice", | ||
"items": [ | ||
english_captions, | ||
italian_captions | ||
] | ||
}, | ||
target="https://iiif.io/api/cookbook/recipe/0074-multiple-language-captions/canvas", | ||
anno_page_id="https://iiif.io/api/cookbook/recipe/0074-multiple-language-captions/manifest.json/anno/page/1" | ||
) | ||
print(manifest.json(indent=2)) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be done using the iiif-prezi library or is it missing this level of Annotation customisation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@glenrobson apologies. I was asleep at the wheel on this initially.
I've refactored, and I think this should all be pure iiif-prezi3 now (unless I've overlooked something).