Skip to content

Commit 0d9a212

Browse files
authored
Merge pull request #77 from internetarchive/spring-2024
Merging spring 2024 fixes
2 parents d057a04 + fd9f88a commit 0d9a212

16 files changed

+707
-39
lines changed

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,12 @@ docs/_build/
5858

5959
# PyBuilder
6060
target/
61+
62+
# Cache dir
63+
cache/
64+
65+
# PyCharm
66+
.idea/
67+
68+
# Old folder from v2?
69+
media/

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ Unit tests are in the `tests` folder and can be run with:
3939
python -m unittest discover -s tests
4040
```
4141

42+
Run single test:
43+
```
44+
python -m unittest tests.test_video.TestVideo.test_vtt_autogenerated
45+
```
46+
4247
Retrieve large.jpg as 800px wide JPEG
4348
* http://127.0.0.1:8080/iiif/large.jpg/full/800,/0/default.jpg
4449

iiify/app.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from flask_caching import Cache
99
from iiif2 import iiif, web
1010
from .resolver import ia_resolver, create_manifest, create_manifest3, getids, collection, \
11-
purify_domain, cantaloupe_resolver, create_collection3, IsCollection
11+
purify_domain, cantaloupe_resolver, create_collection3, IsCollection, create_annotations
1212
from .configs import options, cors, approot, cache_root, media_root, \
1313
cache_expr, version, image_server, cache_timeouts
1414
from urllib.parse import quote
@@ -17,7 +17,7 @@
1717
app = Flask(__name__)
1818
# disabling sorting of the output json
1919
app.config['JSON_SORT_KEYS'] = False
20-
app.config['CACHE_TYPE'] = "FileSystemCache"
20+
app.config['CACHE_TYPE'] = "FileSystemCache" if os.environ.get("FLASK_CACHE_DISABLE", None) != "true" else "NullCache"
2121
app.config['CACHE_DIR'] = "cache"
2222
cors = CORS(app) if cors else None
2323
cache = Cache(app)
@@ -191,6 +191,11 @@ def manifest3(identifier):
191191
raise excpt
192192
# abort(404)
193193

194+
@app.route('/iiif/<version>/annotations/<identifier>/<fileName>/<canvas_no>.json')
195+
@cache.cached(timeout=cache_timeouts["long"], forced_update=cache_bust)
196+
def annnotations(version, identifier, fileName, canvas_no):
197+
domain = purify_domain(request.args.get('domain', request.url_root))
198+
return ldjsonify(create_annotations(version, identifier, fileName, canvas_no, domain=domain))
194199

195200
@app.route('/iiif/<identifier>/manifest.json')
196201
@cache.cached(timeout=cache_timeouts["long"], forced_update=cache_bust)
@@ -199,7 +204,7 @@ def manifest(identifier):
199204

200205
@app.route('/iiif/2/<identifier>/manifest.json')
201206
def manifest2(identifier):
202-
domain = "https://iiif.archivelab.org/iiif/"
207+
domain = purify_domain(request.args.get('domain', request.url_root))
203208
page = None
204209
if '$' in identifier:
205210
identifier, page = identifier.split('$')

iiify/configs/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import sys
1515
import types
1616
import configparser
17+
import json
1718

1819
path = os.path.dirname(os.path.realpath(__file__))
1920
approot = os.path.abspath(os.path.join(path, os.pardir))
@@ -75,3 +76,6 @@ def getdef(self, section, option, default_value):
7576
"long": 432000, # 5 days
7677
"longest": 2592000 # 30 days
7778
}
79+
80+
with open('%s/links.json' % path, 'r') as file:
81+
LINKS = json.load(file)

iiify/configs/links.json

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
{
2+
"Animated GIF": {
3+
"field": "rendering",
4+
"type": "Image",
5+
"format": "image/gif"
6+
},
7+
"Text PDF": {
8+
"field": "rendering",
9+
"type": "Text",
10+
"format": "application/pdf"
11+
},
12+
"Abbyy GZ": {
13+
"field": "rendering",
14+
"type": "Dataset",
15+
"format": "application/gzip"
16+
},
17+
"Archive BitTorrent": {
18+
"field": "rendering",
19+
"type": "Dataset",
20+
"format": "application/x-bittorrent"
21+
},
22+
"Grayscale PDF": {
23+
"field": "rendering",
24+
"type": "Text",
25+
"format": "application/pdf"
26+
},
27+
"chOCR": {
28+
"field": "rendering",
29+
"type": "Text",
30+
"format": "application/gzip"
31+
},
32+
"DjVuTXT": {
33+
"field": "rendering",
34+
"type": "Text",
35+
"format": "text/plain"
36+
},
37+
"Djvu XML": {
38+
"field": "rendering",
39+
"type": "Dataset",
40+
"format": "application/xml"
41+
},
42+
"hOCR": {
43+
"field": "rendering",
44+
"type": "Text",
45+
"format": "text/html"
46+
},
47+
"Single Page Processed JP2 ZIP": {
48+
"field": "rendering",
49+
"type": "Image",
50+
"format": "application/zip"
51+
},
52+
"OCR Search Text": {
53+
"field": "rendering",
54+
"type": "Text",
55+
"format": "application/gzip"
56+
},
57+
"Single Page Original JP2 Tar": {
58+
"field": "rendering",
59+
"type": "Image",
60+
"format": "application/x-tar"
61+
},
62+
"DjVu": {
63+
"field": "rendering",
64+
"type": "Image",
65+
"format": "image/vnd.djvu"
66+
},
67+
"Cloth Cover Detection Log": {
68+
"field": "seeAlso",
69+
"type": "Text",
70+
"format": "text/plain"
71+
},
72+
"Dublin Core": {
73+
"field": "seeAlso",
74+
"type": "Dataset",
75+
"format": "application/xml"
76+
},
77+
"OCR Page Index": {
78+
"field": "seeAlso",
79+
"type": "Dataset",
80+
"format": "application/json"
81+
},
82+
"MARC": {
83+
"field": "seeAlso",
84+
"type": "Dataset",
85+
"format": "application/xml"
86+
},
87+
"MARC Binary": {
88+
"field": "seeAlso",
89+
"type": "Dataset",
90+
"format": "application/marc"
91+
},
92+
"MARC Source": {
93+
"field": "seeAlso",
94+
"type": "Dataset",
95+
"format": "application/xml"
96+
},
97+
"Page Numbers JSON": {
98+
"field": "seeAlso",
99+
"type": "Dataset",
100+
"format": "application/json"
101+
},
102+
"Scandata": {
103+
"field": "seeAlso",
104+
"type": "Dataset",
105+
"format": "application/xml"
106+
},
107+
"SubRip": {
108+
"field": "rendering",
109+
"type": "Text",
110+
"format": "text/plain"
111+
},
112+
"Web Video Text Tracks": {
113+
"field": "rendering",
114+
"type": "Text",
115+
"format": "text/vtt"
116+
},
117+
"Intermediate ASR JSON": {
118+
"field": "rendering",
119+
"type": "Text",
120+
"format": "application/json"
121+
},
122+
"Whisper ASR JSON": {
123+
"field": "rendering",
124+
"type": "Text",
125+
"format": "application/json"
126+
},
127+
"Storj Upload Log": {
128+
"field": "seeAlso",
129+
"type": "Text",
130+
"format": "text/plain"
131+
},
132+
"Storj Upload Trigger": {
133+
"field": "seeAlso",
134+
"type": "Text",
135+
"format": "text/plain"
136+
}
137+
}

0 commit comments

Comments
 (0)