-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #200 from markpbaggett/recipe_0014
Add Recipe 0014 and add add_item() to AccompanyingCanvas
- Loading branch information
Showing
4 changed files
with
85 additions
and
6 deletions.
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 @@ | ||
# "Audio Presentation with Accompanying Image" | ||
| | **Cookbook URLs** | | ||
|--------------|-------------------| | ||
| **Recipe:** | [https://iiif.io/api/cookbook/recipe/0014-accompanyingcanvas/](https://iiif.io/api/cookbook/recipe/0014-accompanyingcanvas/) | | ||
| **JSON-LD:** | [https://iiif.io/api/cookbook/recipe/0014-accompanyingcanvas/manifest.json](https://iiif.io/api/cookbook/recipe/0014-accompanyingcanvas/manifest.json) | | ||
|
||
### Method 1 - Use AccompanyingCanvas and add_item() helper | ||
```python | ||
--8<-- "docs/recipes/scripts/0014-accompanyingcanvas-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,62 @@ | ||
from iiif_prezi3 import Manifest, ResourceItem, AnnotationPage, Annotation, config, AccompanyingCanvas | ||
|
||
base_url = "https://iiif.io/api/cookbook/recipe/0014-accompanyingcanvas" | ||
|
||
config.configs['helpers.auto_fields.AutoLang'].auto_lang = "en" | ||
accompanying_canvas = AccompanyingCanvas( | ||
id=f"{base_url}/canvas/accompanying", | ||
label="First page of score for Gustav Mahler, Symphony No. 3", | ||
height=998, | ||
width=772, | ||
) | ||
manifest = Manifest( | ||
id=f"{base_url}/manifest.json", | ||
label="Partial audio recording of Gustav Mahler's _Symphony No. 3_", | ||
) | ||
ac_anno_body = ResourceItem( | ||
id="https://iiif.io/api/image/3.0/example/reference/4b45bba3ea612ee46f5371ce84dbcd89-mahler-0/full/,998/0/default.jpg", | ||
type="Image", | ||
format="image/jpeg", | ||
height=998, | ||
width=772, | ||
) | ||
ac_anno_body.make_service( | ||
id="https://iiif.io/api/image/3.0/example/reference/4b45bba3ea612ee46f5371ce84dbcd89-mahler-0", | ||
type="ImageService3", | ||
profile="level1" | ||
) | ||
ac_anno_page = AnnotationPage( | ||
id=f"{base_url}/canvas/accompanying/annotation/page" | ||
) | ||
ac_anno = Annotation( | ||
id=f"{base_url}/canvas/accompanying/annotation/image", | ||
motivation="painting", | ||
body=ac_anno_body, | ||
target=f"{base_url}/canvas/accompanying" | ||
) | ||
ac_anno_page.add_item(ac_anno) | ||
accompanying_canvas.add_item(ac_anno_page) | ||
canvas = manifest.make_canvas( | ||
id=f"{base_url}/canvas/p1", | ||
label="Gustav Mahler, Symphony No. 3, CD 1", | ||
duration=1985.024, | ||
accompanyingCanvas=accompanying_canvas | ||
) | ||
anno_body = ResourceItem( | ||
id="https://fixtures.iiif.io/audio/indiana/mahler-symphony-3/CD1/medium/128Kbps.mp4", | ||
type="Sound", | ||
format="video/mp4", | ||
duration=1985.024, | ||
) | ||
anno_page = AnnotationPage( | ||
id=f"{base_url}/canvas/page/p1" | ||
) | ||
anno = Annotation( | ||
id=f"{base_url}/canvas/page/annotation/segment1-audio", | ||
motivation="painting", | ||
body=anno_body, | ||
target=canvas.id | ||
) | ||
anno_page.add_item(anno) | ||
canvas.add_item(anno_page) | ||
print(manifest.json(indent=2)) |
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
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