def create_manifest(self, imgfiles): """create manifest""" # to be set in sysargs or via imagemagick imageWidth = int(self.width) imageHeight = int(self.height) identifier = "test file import" # setup factory factory = ManifestFactory() factory.set_base_metadata_uri("http://www.example.org/metadata/") factory.set_base_image_uri("http://www.example.org/iiif/") factory.set_iiif_image_info(version="2.0", lvl="2") # setup manifest mf = factory.manifest(label="Manifest") mf.viewingHint = "paged" mf.set_metadata({ "test label": "test value", "next label": "next value" }) mf.attribution = "Provided by Bodleian Library, Oxford, using ManifestFactory code from the Houghton Library, Harvard University" mf.viewingHint = "paged" mf.description = "Description of Manuscript Goes Here" seq = mf.sequence() # loop through images in path for img in imgfiles: # get path, full image name and extension imgPath, imgFullName = os.path.split(img) imgName, imgExt = os.path.splitext(imgFullName) # Mostly identity will come from incrementing number (f1r, f1v,...) # or the image's identity cvs = seq.canvas(ident="c%s" % imgName, label="Canvas %s" % imgName) cvs.set_hw(imageWidth, imageHeight) anno = cvs.annotation() al = cvs.annotationList("foo") # for demo purposes adds choices img = factory.image(imgFullName, iiif=True) img2 = factory.image(imgName + 'b' + imgExt, iiif=True) chc = anno.choice(img, [img2]) json = mf.toString(compact=False) # write to text file text_file = open(identifier.replace(" ", "") + ".json", "w") text_file.write(json) text_file.close() return json
[6, '', '1140,757,271,50'], [7, '', '1412,757,339,50'], [8, '0,14', '1750,757,191,50'], [8, '14,23', '990,878,100,50'], [9, '', '1090,878,255,50'], [10, '', '1346,878,390,50'], [11, '0,20', '1733,878,209,50'], [11, '20,29', '994,1002,85,50'], [12, '', '1076,1002,415,50'], [13, '', '1488,1002,222,50'], [14, '0,19', '1713,1002,224,50'], [14, '19,32', '988,1122,152,50'], [15, '', '1139,1122,217,50'], [16, '', '1358,1122,253,50'], [17, '', '1614,1122,271,50'], [18, '0,4', '1884,1122,71,50'], [18, '4,18', '987,1252,148,50'], [19, '', '1136,1252,260,50'], [20, '', '1396,1252,243,50'], [21, '0,26', '1638,1252,308,50'], [21, '26,30', '989,1372,47,50'], [22, '', '1038,1372,401,50']] factory = ManifestFactory() fac.set_base_metadata_uri("http://www.shared-canvas.org/impl/demo2c/") mf = factory.manifest(label="Worldes Blisce") mf.description = "The only remaining leaf of a 300+ folio music manuscript that was split up and used as fly leaves for other manuscripts. This leaf contains the only copy of this particular song, World's Bliss." mf.attribution = "Provided by the Parker Library, University of Cambridge" seq = mf.sequence(label="Single Leaf") cvs = seq.canvas(ident="c1", label="Worldes Blisce") cvs.set_hw(1480, 2288) anno = cvs.annotation() cvs.image("http://www.shared-canvas.org/mss/iiif/2/res/blisce-rc.jpg") texts = cvs.annotationList("text-f1", label="Transcription") audios = cvs.annotationList("audio-f1", label="Performance") mp3fn = 'blisce.mp3#t=npt:' for a in audioInfo: aanno = audios.annotation()
lines = data.split('\r\n') keys = lines[0].split('\t') keys = [x.lower() for x in keys] lines = lines[1:] for l in lines: if l: fields = l.split('\t') linfo = dict(zip(keys, fields)) bkid = linfo['book_identifier'] bookinfo = books[bkid] try: manifest = manifests[bkid] seq = manifest.sequences[0] except: manifest = fac.manifest(bkid, label=linfo['title']) manifest.set_metadata({'Author': linfo['first_author'], 'Place of Publication': linfo['pubplace'], 'Publisher': linfo['publisher'], "Date": linfo['date'], "Shelfmarks" : bookinfo['shelfmarks'], 'Issuance': bookinfo['issuance']}) manifest.attribution = "British Library" manifest.seeAlso = bookinfo['flickr_url_to_book_images'] seq = manifest.sequence("s1", label="Regular Order") manifests[bkid] = manifest cvs = seq.canvas(linfo['flickr_id'], label="p. %03d (detail)" % int(linfo['page'])) anno = cvs.annotation("%s-image" % linfo['flickr_id']) imgs = [] if linfo['flickr_original_source']: orig = fac.image(linfo['flickr_original_source']) orig.set_hw(int(linfo['flickr_original_height']), int(linfo['flickr_original_width']))
def do_record(rec, rx, host, s, cxn, sequence, lastrec): deleted = rec.xpath('./o:header/@status', namespaces=ALLNS) if deleted: return format = rec.xpath('./o:metadata/odc:dc/dc:format/text()', namespaces=ALLNS) # Strip out non images skip = 0 for f in format: if f.find('/') > -1 and (not f.startswith('image/') or f.endswith('/pdf')): skip = 1 break if skip: return # request info to see if we're compound object (cpd) # if we are, then work backwards from current ID to find records for individual pages # Then reverse the order and call it a Manifest :) identifier = rec.xpath('./o:header/o:identifier/text()', namespaces=ALLNS)[0] idx = int(identifier[identifier.rfind('/')+1:]) ajaxinfo = get_json('http://%s/utils/ajaxhelper/?action=1&CISOROOT=%s&CISOPTR=%s' % (host, s, idx)) try: if not ajaxinfo['imageinfo'].has_key('type'): return except: print 'http://%s/utils/ajaxhelper/?action=1&CISOROOT=%s&CISOPTR=%s' % (host, s, idx) print ajaxinfo raise if ajaxinfo['imageinfo']['type'] == 'cpd': # Compound Object to process separately # Walk backwards through images until hit previous entry in OAI list # make a folder... print "--- Compound Object: %s" % idx sys.stdout.flush() if os.path.exists('%s/%s/manifest.json' % (s,idx)): return try: os.mkdir("%s/%s" % (s, idx)) except: pass os.chdir("%s/%s" % (s, idx)) if rx == 0: # Need to check last record of previous chunk if lastrec: previd = lastrec.xpath('./o:header/o:identifier/text()', namespaces=ALLNS)[0] start_image = int(previd[previd.rfind('/')+1:])+1 else: start_image = 1 else: prev = recs[rx-1] previd = prev.xpath('./o:header/o:identifier/text()', namespaces=ALLNS)[0] start_image = int(previd[previd.rfind('/')+1:])+1 pages = [] for imgid in range(start_image, idx): pinfo = {'id': imgid} # get H/W from ajax iajax = get_json('http://%s/utils/ajaxhelper/?action=1&CISOROOT=%s&CISOPTR=%s' % (host, s, imgid)) if not iajax['imageinfo'].has_key('height'): continue pinfo['h'] = iajax['imageinfo']['height'] pinfo['w'] = iajax['imageinfo']['width'] if (int(pinfo['h']) == 0 or int(pinfo['w']) == 0): continue try: pinfo['title'] = iajax['imageinfo']['title']['0'] except: pinfo['title'] = "Image %s" % imgid cxn.put("%s::%s::%s" % (host, s, imgid), "%s,%s" % (pinfo['w'], pinfo['h'])) pages.append(pinfo) if not pages: # back to host directory os.chdir('../..') return title = rec.xpath('./o:metadata/odc:dc/dc:title/text()', namespaces=ALLNS) creator = rec.xpath('./o:metadata/odc:dc/dc:creator/text()', namespaces=ALLNS) date = rec.xpath('./o:metadata/odc:dc/dc:date/text()', namespaces=ALLNS) description = rec.xpath('./o:metadata/odc:dc/dc:description/text()', namespaces=ALLNS) language = rec.xpath('./o:metadata/odc:dc/dc:language/text()', namespaces=ALLNS) # reinstantiate factory for subdir. not great but ... cfac = ManifestFactory() cfac.set_base_metadata_uri(BASE_MD_URL + "/%s/%s/%s/" % (host, s, idx)) cfac.set_base_image_uri(BASE_IMG_URL + "/%s/%s/" % (host, s)) cfac.set_base_metadata_dir(os.getcwd()) cfac.set_iiif_image_info("2.0", "1") fac.set_debug('error') cmanifest = cfac.manifest(label=title[0]) try: cmanifest.set_metadata({"Creator": creator[0]}) except: pass try: cmanifest.set_metadata({"Date": date[0]}) except: pass try: cmanifest.set_metadata({"Language": language[0]}) except: pass try: cmanifest.description = description[0] except: pass cmanifest.viewingHint = "paged" cseq = cmanifest.sequence() for p in pages: cvs = cseq.canvas(ident="p%s" % p['id'], label=p['title']) cvs.set_hw(int(p['h']), int(p['w'])) anno = cvs.annotation() img = anno.image(str(p['id']), iiif=True) img.height = p['h'] img.width = p['w'] try: cmanifest.toFile(compact=False) except: print "FAILED TO WRITE %s/%s/manifest.json" % (s, idx) # back to host directory os.chdir('../..') else: # We're just a collection of images h = ajaxinfo['imageinfo']['height'] w = ajaxinfo['imageinfo']['width'] if int(h) == 0 or int(w) == 0: return ttl = ajaxinfo['imageinfo']['title']['0'] cxn.put("%s::%s::%s" % (host, s, idx), "%s,%s" % (w, h)) cvs = sequence.canvas(ident="p%s" % idx, label=ttl) cvs.set_hw(int(h), int(w)) anno = cvs.annotation() img = anno.image(str(idx), iiif=True) img.height = h img.width = w
resDirectory = "/Users/azaroth/Dropbox/IIIF/demos/mirador/data/" minFolio= 1 maxFolio = 258 fac = ManifestFactory() fac.set_base_metadata_uri("http://www.shared-canvas.org/impl/demo1d/res_human/") fac.set_base_image_uri("http://www.shared-canvas.org/iiif/") fac.set_base_metdata_dir("/Users/azaroth/Dropbox/SharedCanvas/impl/demo1d/res_human/") fac.set_iiif_image_conformance(1.1, 2) fac.set_debug("error") # warn will warn for recommendations, by default rubricCss = ".red {color: red}" initialCss = ".bold {font-weight: bold}" mf = fac.manifest(ident="manifest", label="Pierpont Morgan MS.804") mf.set_metadata({"Dates": "Author's version circa 1380, scribed circa 1400, illuminations circa 1420"}) mf.attribution = "Held at the Pierpont Morgan Library" mf.viewingHint = "paged" mf.viewingDirection = "left-to-right" seq = mf.sequence(ident="normal", label="Normal Order") for f in range(minFolio, maxFolio+1): for rv in ['r', 'v']: # View in Sequence folio = 'f%s%s' % (f, rv) if folio == "f258v": # Ends at 258r, skip continue
nss = {"atom": "http://www.w3.org/2005/Atom"} dom = etree.XML(data) subs = dom.xpath('//atom:summary[@type="html"]/text()', namespaces=nss) fac = ManifestFactory() fac.set_base_metadata_uri("http://iiif-dev.localhost/prezi/mw/") fac.set_base_image_uri("http://dlss-dev-azaroth.stanford.edu/services/iiif/") fac.set_base_metadata_dir("/Users/azaroth/Dropbox/Rob/Web/iiif-dev/prezi/mw") fac.set_iiif_image_info(2.0, 2) fac.set_debug("error") # warn will warn for recommendations, by default label = "Wikimedia Pictures of the Day" mf = fac.manifest(ident="manifest", label=label) mf.viewingHint = "individuals" seq = mf.sequence(ident="normal", label="Normal Order") c = 0 for s in subs: hdom = etree.HTML(s) title = hdom.xpath("//span")[0] title = etree.tostring(title) title = title.replace(" ", "") url = hdom.xpath("//img/@src")[0] url = url.replace("thumb/", "") f = url.find("/300px-")
if not os.path.exists(destimg): fh = urllib.urlopen(imguri) data = fh.read() fh.close() if data: fh = file(destimg, 'w') fh.write(data) fh.close() pairs.append((objn, limgid[:-4])) return pairs pairs = fetch_content(q1, 'q1') # Make a manifest mfst = fac.manifest(label="12th Century Manuscripts") mfst.attribution = "Victoria and Albert Museum" seq = mfst.sequence() # Some objects have many images in image_set, skip if >2 and make new object for (objn, imgid) in pairs: # build per canvas metadata fh = file('cache/%s.json' % objn) data = fh.read() fh.close() rec = json.loads(data)[0] fields = rec['fields'] if len(fields['image_set']) > 2: continue
fh = urllib.urlopen(imguri) data = fh.read() fh.close() if data: fh = file(destimg, 'w') fh.write(data) fh.close() pairs.append((objn, limgid[:-4])) return pairs pairs = fetch_content(q1, 'q1') # Make a manifest mfst = fac.manifest(label="12th Century Manuscripts") mfst.attribution = "Victoria and Albert Museum" seq = mfst.sequence() # Some objects have many images in image_set, skip if >2 and make new object for (objn, imgid) in pairs: # build per canvas metadata fh = file('cache/%s.json' % objn) data = fh.read() fh.close() rec = json.loads(data)[0] fields = rec['fields'] if len(fields['image_set']) > 2: continue
for result in results["results"]["bindings"]: exhib = result['exhibition']['value'] name = result['name']['value'] eident = os.path.split(exhib)[1] basemd = "http://iiif-dev.localhost/prezi/yale/" + eident basedir = "/Users/azaroth/Dropbox/Rob/Web/iiif-dev/prezi/yale/" + eident # Make Manifest & Sequence try: os.mkdir(basedir) except: pass # already exists fac.set_base_metadata_uri(basemd) fac.set_base_metadata_dir(basedir) mfst = fac.manifest(label=name) seq = mfst.sequence() # Now find all objects in that exhibition to be canvases q2 = """ SELECT DISTINCT ?obj ?label { ?obj crm:P12i_was_present_at <%s> ; rdfs:label ?label . } """ % exhib sparql.setQuery(prefixes + q2) results2 = sparql.query().convert() for res2 in results2["results"]["bindings"]: uri = res2['obj']['value']
from factory import ManifestFactory imageWidth = 693 imageHeight = 786 identifier = "test" # Configure the factory fac = ManifestFactory() fac.set_base_metadata_uri("http://ids.lib.harvard.edu/iiif/metadata/") fac.set_base_image_uri("http://ids.lib.harvard.edu/ids/view/" + identifier + '/') fac.set_iiif_image_conformance(1.1, 1) # Build the Manifest mf = fac.manifest(ident="manifest", label="Example Manifest") mf.set_metadata({"test label":"test value", "next label":"next value"}) mf.attribution = "Provided by the Houghton Library, Harvard University" mf.viewingHint = "paged" mf.description = "Description of Manuscript MS Richardson 44 Goes Here" # And walk through the pages seq = mf.sequence(ident="normal", label="Normal Order") for st in range(3): # Build the Canvas cvs = seq.canvas(ident="c%s" % st,label="Test Canvas %s" % st) cvs.set_hw(imageHeight, imageWidth) # Build the Image Annotation anno = cvs.annotation(ident="a%s" % st)
q2 = qt % (k, uri, v) sparql.setQuery(q2) results2 = sparql.query().convert() for r2 in results2["results"]["bindings"]: thing[k].append(r2[k]["value"]) # And now make the Manifest objid = os.path.split(uri)[-1] try: os.mkdir(basedir + "/" + objid) except: pass # already exists fac.set_base_metadata_uri(basemd + objid) fac.set_base_metadata_dir(basedir + "/" + objid) mfst = fac.manifest() # Most British Museum objects don't have titles lbl = thing.get("title") # Maybe there's some with more than one? if len(lbl) > 1: mfst.label = lbl elif len(lbl): mfst.label = lbl[0] else: mfst.label = thing.get("typeLabel", [""])[0] desc = thing.get("desc") if len(desc) > 1: desc.sort(key=lambda x: len(x), reverse=True) # longest description first mfst.description = desc
cells = l.split('\t') for r in range(len(cells)): row[r] = cells[r] fields.append(row) fields = fields[1:] resDirectory = "/Users/azaroth/Dropbox/IIIF/demos/mirador/data/vhmml/" fac = ManifestFactory() fac.set_base_metadata_uri("http://localhost/demos/mirador/data/vhmml/") fac.set_base_image_uri("http://localhost/services/image/iiif2/") fac.set_debug("error") # warn will warn for recommendations, by default mf = fac.manifest(label=fields[0][0]) mf.set_metadata({"Date": fields[0][6], "City": fields[0][19], "Library": fields[0][20], "Country of Origin": fields[0][21], "Genre": fields[0][22], "Total Folios": fields[0][28]}) mf.attribution = fields[0][14] + "\n" + fields[0][18] mf.viewingHint = "paged" mf.viewingDirection = "left-to-right" seq = mf.sequence(ident="normal", label="Normal Order") imageHeight = 1239 imageWidth = 800 for row in fields: folio = row[28]
from factory import ManifestFactory imageWidth = 693 imageHeight = 786 identifier = "test" # Configure the factory fac = ManifestFactory() fac.set_base_metadata_uri("http://ids.lib.harvard.edu/iiif/metadata/") fac.set_base_image_uri("http://ids.lib.harvard.edu/ids/view/" + identifier + '/') fac.set_iiif_image_conformance(1.1, 1) # Build the Manifest mf = fac.manifest(ident="manifest", label="Example Manifest") mf.set_metadata({"test label": "test value", "next label": "next value"}) mf.attribution = "Provided by the Houghton Library, Harvard University" mf.viewingHint = "paged" mf.description = "Description of Manuscript MS Richardson 44 Goes Here" # And walk through the pages seq = mf.sequence(ident="normal", label="Normal Order") for st in range(3): # Build the Canvas cvs = seq.canvas(ident="c%s" % st, label="Test Canvas %s" % st) cvs.set_hw(imageHeight, imageWidth) # Build the Image Annotation anno = cvs.annotation(ident="a%s" % st) img = anno.image(ident="image-%s" % st, iiif=True)
def do_record(rec, rx, host, s, cxn, sequence, lastrec): deleted = rec.xpath('./o:header/@status', namespaces=ALLNS) if deleted: return format = rec.xpath('./o:metadata/odc:dc/dc:format/text()', namespaces=ALLNS) # Strip out non images skip = 0 for f in format: if f.find('/') > -1 and (not f.startswith('image/') or f.endswith('/pdf')): skip = 1 break if skip: return # request info to see if we're compound object (cpd) # if we are, then work backwards from current ID to find records for individual pages # Then reverse the order and call it a Manifest :) identifier = rec.xpath('./o:header/o:identifier/text()', namespaces=ALLNS)[0] idx = int(identifier[identifier.rfind('/') + 1:]) ajaxinfo = get_json( 'http://%s/utils/ajaxhelper/?action=1&CISOROOT=%s&CISOPTR=%s' % (host, s, idx)) try: if not ajaxinfo['imageinfo'].has_key('type'): return except: print 'http://%s/utils/ajaxhelper/?action=1&CISOROOT=%s&CISOPTR=%s' % ( host, s, idx) print ajaxinfo raise if ajaxinfo['imageinfo']['type'] == 'cpd': # Compound Object to process separately # Walk backwards through images until hit previous entry in OAI list # make a folder... print "--- Compound Object: %s" % idx sys.stdout.flush() if os.path.exists('%s/%s/manifest.json' % (s, idx)): return try: os.mkdir("%s/%s" % (s, idx)) except: pass os.chdir("%s/%s" % (s, idx)) if rx == 0: # Need to check last record of previous chunk if lastrec: previd = lastrec.xpath('./o:header/o:identifier/text()', namespaces=ALLNS)[0] start_image = int(previd[previd.rfind('/') + 1:]) + 1 else: start_image = 1 else: prev = recs[rx - 1] previd = prev.xpath('./o:header/o:identifier/text()', namespaces=ALLNS)[0] start_image = int(previd[previd.rfind('/') + 1:]) + 1 pages = [] for imgid in range(start_image, idx): pinfo = {'id': imgid} # get H/W from ajax iajax = get_json( 'http://%s/utils/ajaxhelper/?action=1&CISOROOT=%s&CISOPTR=%s' % (host, s, imgid)) if not iajax['imageinfo'].has_key('height'): continue pinfo['h'] = iajax['imageinfo']['height'] pinfo['w'] = iajax['imageinfo']['width'] if (int(pinfo['h']) == 0 or int(pinfo['w']) == 0): continue try: pinfo['title'] = iajax['imageinfo']['title']['0'] except: pinfo['title'] = "Image %s" % imgid cxn.put("%s::%s::%s" % (host, s, imgid), "%s,%s" % (pinfo['w'], pinfo['h'])) pages.append(pinfo) if not pages: # back to host directory os.chdir('../..') return title = rec.xpath('./o:metadata/odc:dc/dc:title/text()', namespaces=ALLNS) creator = rec.xpath('./o:metadata/odc:dc/dc:creator/text()', namespaces=ALLNS) date = rec.xpath('./o:metadata/odc:dc/dc:date/text()', namespaces=ALLNS) description = rec.xpath('./o:metadata/odc:dc/dc:description/text()', namespaces=ALLNS) language = rec.xpath('./o:metadata/odc:dc/dc:language/text()', namespaces=ALLNS) # reinstantiate factory for subdir. not great but ... cfac = ManifestFactory() cfac.set_base_metadata_uri(BASE_MD_URL + "/%s/%s/%s/" % (host, s, idx)) cfac.set_base_image_uri(BASE_IMG_URL + "/%s/%s/" % (host, s)) cfac.set_base_metadata_dir(os.getcwd()) cfac.set_iiif_image_info("2.0", "1") fac.set_debug('error') cmanifest = cfac.manifest(label=title[0]) try: cmanifest.set_metadata({"Creator": creator[0]}) except: pass try: cmanifest.set_metadata({"Date": date[0]}) except: pass try: cmanifest.set_metadata({"Language": language[0]}) except: pass try: cmanifest.description = description[0] except: pass cmanifest.viewingHint = "paged" cseq = cmanifest.sequence() for p in pages: cvs = cseq.canvas(ident="p%s" % p['id'], label=p['title']) cvs.set_hw(int(p['h']), int(p['w'])) anno = cvs.annotation() img = anno.image(str(p['id']), iiif=True) img.height = p['h'] img.width = p['w'] try: cmanifest.toFile(compact=False) except: print "FAILED TO WRITE %s/%s/manifest.json" % (s, idx) # back to host directory os.chdir('../..') else: # We're just a collection of images h = ajaxinfo['imageinfo']['height'] w = ajaxinfo['imageinfo']['width'] if int(h) == 0 or int(w) == 0: return ttl = ajaxinfo['imageinfo']['title']['0'] cxn.put("%s::%s::%s" % (host, s, idx), "%s,%s" % (w, h)) cvs = sequence.canvas(ident="p%s" % idx, label=ttl) cvs.set_hw(int(h), int(w)) anno = cvs.annotation() img = anno.image(str(idx), iiif=True) img.height = h img.width = w
print "Processing Set: %s" % sinfo['name'] except: print "Processing Set: %s" % s sys.stdout.flush() if os.path.exists(s): continue os.mkdir(s) fac = ManifestFactory() fac.set_base_metadata_uri(BASE_MD_URL + "/%s/%s/" % (host, s)) fac.set_base_metadata_dir(os.path.join(os.getcwd(), s)) fac.set_base_image_uri(BASE_IMG_URL + "/%s/%s/" % (host, s)) fac.set_iiif_image_info("2.0", "1") fac.set_debug('error') manifest = fac.manifest(label=sinfo['name']) if sinfo['desc']: manifest.description = str(sinfo['desc']) manifest.attribution = "Converted from http://%s/" % host manifest.viewingHint = "individuals" sequence = manifest.sequence() dom = get_xml( 'http://%s/oai/oai.php?verb=ListRecords&set=%s&metadataPrefix=oai_dc' % (host, s)) recs = dom.xpath('/o:OAI-PMH/o:ListRecords/o:record', namespaces=ALLNS) lastrec = None for rx in range(len(recs)): rec = recs[rx] do_record(rec, rx, host, s, cxn, sequence, lastrec) rt = dom.xpath('/o:OAI-PMH/o:ListRecords/o:resumptionToken/text()',
BASEURL = "http://iiif.io/api/presentation/2.0/example/errors/" HOMEDIR = "../source/api/presentation/2.0/example/errors/" IMAGE_BASEURL = "http://iiif.io/api/image/2.0/example/" # Configure a factory for the fake Manifests fac = ManifestFactory() fac.set_base_metadata_uri(BASEURL) fac.set_base_metadata_dir(HOMEDIR) fac.set_base_image_uri(IMAGE_BASEURL) fac.set_iiif_image_info(2.0, 1) fac.set_debug('error') coll = fac.collection(label="Collection of Errors") TEST_ID = 0 mf = fac.manifest(label="manifest") s = mf.sequence() c = s.canvas(ident="c1", label="canvas") c.set_hw(1, 1) basejs = mf.toJSON(top=True) anno = c.annotation() anno.image(ident="http://example.net/image.jpg", iiif=False) basejs_image = mf.toJSON(top=True) def make_test(data, name): global TEST_ID, BASEURL, HOMEDIR, coll name = "%s: %s" % (TEST_ID, name) myid = BASEURL + "%s/manifest.json" % TEST_ID mf = coll.manifest(ident=myid, label=name)
def create_manifest(self): """create manifest""" # to be set in sysargs or via imagemagick imageWidth = int(self.width) imageHeight = int(self.height) identifier = "test" fh = file(self.path) data = fh.read() fh.close() dom = etree.XML(data) metsNS = 'http://www.loc.gov/METS/' modsNS = 'http://www.loc.gov/mods/v3' xlinkNS = 'http://www.w3.org/1999/xlink' ALLNS = {'mets': metsNS, 'mods': modsNS, 'xlink': xlinkNS} # Extract basic info identifier = dom.xpath( '/mets:mets/mets:dmdSec/mets:mdWrap[@MDTYPE="MODS"]/mets:xmlData/mods:mods/mods:recordInfo/mods:recordIdentifier/text()', namespaces=ALLNS)[0] mflabel = dom.xpath( '/mets:mets/mets:structMap[@TYPE="LOGICAL"]/mets:div[@TYPE="manuscript"]/@LABEL', namespaces=ALLNS)[0] manifestType = 'sc:Manifest' # Extract image info images = dom.xpath( '/mets:mets/mets:fileSec/mets:fileGrp/mets:file[@MIMETYPE="image/jpeg"]', namespaces=ALLNS) struct = dom.xpath( '/mets:mets/mets:structMap[@TYPE="PHYSICAL"]/mets:div[@TYPE="physSequence"]/mets:div', namespaces=ALLNS) imageHash = {} for img in images: imageHash[img.xpath('./@ID', namespaces=ALLNS)[0]] = img.xpath( './mets:FLocat/@xlink:href', namespaces=ALLNS)[0] # Configure the factory fac = ManifestFactory() fac.set_base_metadata_uri(self.baseimguri) fac.set_base_image_uri(self.basemetadatauri + identifier + '/') fac.set_iiif_image_conformance(1.1, 1) # Build the Manifest mf = fac.manifest(ident="manifest", label=mflabel) mf.attribution = "Provided by the Bodleian Library, Oxford University" mf.viewingHint = "paged" if manifestType == "PAGEDOBJECT" else "individuals" mf.description = "Description of Manuscript Goes Here" # And walk through the pages seq = mf.sequence(ident="normal", label="Normal Order") for st in struct: # Find label, and image ID label = st.xpath('./@ORDERLABEL', namespaces=ALLNS)[0] image = imageHash[st.xpath('./mets:fptr[1]/@FILEID', namespaces=ALLNS)[0]] # Build the Canvas cvs = seq.canvas(ident="c%s" % image, label=label) cvs.set_hw(imageHeight, imageWidth) # Build the Image Annotation anno = cvs.annotation(ident="a%s" % image) img = anno.image(ident="%s" % image, iiif=True) img.set_hw(imageHeight, imageWidth) # Serialize mfjs = mf.toJSON() srlzd = json.dumps(mfjs, sort_keys=True, indent=2) # write to textfile text_file = open(mflabel.replace(" ", "") + ".json", "w") text_file.write(srlzd) text_file.close() return srlzd
q2 = qt % (k, uri, v) sparql.setQuery(q2) results2 = sparql.query().convert() for r2 in results2['results']['bindings']: thing[k].append(r2[k]['value']) # And now make the Manifest objid = os.path.split(uri)[-1] try: os.mkdir(basedir + '/' + objid) except: pass # already exists fac.set_base_metadata_uri(basemd + objid) fac.set_base_metadata_dir(basedir + '/' + objid) mfst = fac.manifest() # Most British Museum objects don't have titles lbl = thing.get('title') # Maybe there's some with more than one? if len(lbl) > 1: mfst.label = lbl elif len(lbl): mfst.label = lbl[0] else: mfst.label = thing.get('typeLabel', [''])[0] desc = thing.get('desc') if len(desc) > 1: desc.sort(key=lambda x: len(x), reverse=True) # longest description first mfst.description = desc
minFolio = 1 maxFolio = 258 fac = ManifestFactory() fac.set_base_metadata_uri( "http://www.shared-canvas.org/impl/demo1d/res_human/") fac.set_base_image_uri("http://www.shared-canvas.org/iiif/") fac.set_base_metdata_dir( "/Users/azaroth/Dropbox/SharedCanvas/impl/demo1d/res_human/") fac.set_iiif_image_conformance(1.1, 2) fac.set_debug("error") # warn will warn for recommendations, by default rubricCss = ".red {color: red}" initialCss = ".bold {font-weight: bold}" mf = fac.manifest(ident="manifest", label="Pierpont Morgan MS.804") mf.set_metadata({ "Dates": "Author's version circa 1380, scribed circa 1400, illuminations circa 1420" }) mf.attribution = "Held at the Pierpont Morgan Library" mf.viewingHint = "paged" mf.viewingDirection = "left-to-right" seq = mf.sequence(ident="normal", label="Normal Order") for f in range(minFolio, maxFolio + 1): for rv in ['r', 'v']: # View in Sequence folio = 'f%s%s' % (f, rv)
BASEURL = "http://iiif.io/api/presentation/2.0/example/errors/" HOMEDIR = "../source/api/presentation/2.0/example/errors/" IMAGE_BASEURL = "http://iiif.io/api/image/2.0/example/" # Configure a factory for the fake Manifests fac = ManifestFactory() fac.set_base_metadata_uri(BASEURL) fac.set_base_metadata_dir(HOMEDIR) fac.set_base_image_uri(IMAGE_BASEURL) fac.set_iiif_image_info(2.0, 1) fac.set_debug('error') coll = fac.collection(label="Collection of Errors") TEST_ID = 0 mf = fac.manifest(label="manifest") s = mf.sequence() c = s.canvas(ident="c1", label="canvas") c.set_hw(1,1) basejs = mf.toJSON(top=True) anno = c.annotation() anno.image(ident="http://example.net/image.jpg", iiif=False) basejs_image = mf.toJSON(top=True) def make_test(data, name): global TEST_ID, BASEURL, HOMEDIR, coll name = "%s: %s" % (TEST_ID, name) myid = BASEURL + "%s/manifest.json" % TEST_ID mf = coll.manifest(ident=myid, label = name)
#!/usr/bin/env python # -*- coding: Windows-1252 -*- import sys from factory import ManifestFactory msref = "add_ms_10289" fac = ManifestFactory() fac.set_base_metadata_uri("http://sanddragon.bl.uk/IIIFMetadataService/") fac.set_base_image_uri("http://sanddragon.bl.uk/IIIFImageService/") fac.set_iiif_image_conformance(1.1, 2) # Version, ComplianceLevel fac.set_debug("warn") # 'error' will turn off warnings manifest = fac.manifest(ident="add_ms_10289", label="Add MS 10289") mddate = u'1275 - 1300'.encode('utf-8') mdtitle = "Li Romanz du Mont Saint-Michel, a miscellany of romances, moralistic and religious texts and medical recipes" mdlocation = "British Library" mdcontents = u"Contents: ff. 1r-64r: Guillaume de Saint Pair or Guillelme de Seint Paier, Li romanz du Mont Saint Michel or Roman de Mont Saint Michel, incipit, 'Molz pelerins qui vunt al munt', explicit, 'Longue de corne ou il est mis'. ff. 64r-81v: Andreu de Costances, Une estoire de la resurrection de Jesu Crist, or Verse Gospel of Nicodemus in verse, incipit, 'Seignors mestre Andreu de costances..', explicit, 'Les boens mist hors lessa les maux'; f. 81v: Recipe for a lotion to whiten the skin, incipit, 'Ogneme[n]t espue por blanchir'; ff. 82r-121r: Roman de la destruction de Jerusalem or Le livre de Titus ou de Vespasian, a chanson de geste, incipit, 'Seignors or entende chevalier seriant', explicit, 'nel doit len pas mescroire'; ff. 122r-129r: Medical recipes or Secrets de medecine, incipit 'A la dolor deu chief polieul cuit..', explicit, 'tant q[ue] il sue cest ce qui plus vaut'. f. 129v: De saint Nicaise, in Latin, incipit 'Sanctus Nichasius habuit mac[u]lam in oculo'; ff. 129v-132v: André or Andreu de Costances: Le romanz des Franceis or Arflet, incipit, 'Reis arflet de nohundrelande', explicit, 'Q[ue]r p[ar]tot dit veir cest la fin.'; f. 132v: List of twelve pairs of France, incipit, 'Dux burgondie'; ff. 133r-172r: Petrus Alphonsus: Fables, a French translation of the Disciplina Clericalis entitled Chatoiment d'un pere a son fils, incipit, 'Qui veut henor eu siecle aveir', explicit, 'Garni le tienge en son vivant'; ff. 172r-175r: Robert de Blois, Compendium Amoris, extracts from Chastoiement des Dames, incipit,'[M]einte gent parolent damors', explicit, 'lor veut dex li dont honte ame'; ff. 175v-178v: Colin Malet: Fabliau de Juglet or Jouglet, incipit, 'Jadis en coste mon ferrant', explicit, 'Q[ue] assez miez [con]chie lui'. Decoration: A historiated initial in colours with frame in red of two pilgrims with staffs (f. 1r). An ink drawing in brown of the church of Mont Saint Michel burning with flames in red (f. 45v). Two puzzle initials in red and blue with penwork decoration (ff. 82r,133r). Initials in blue with penwork decoration in red or in red with penwork decoration in blue at the beginning of chapters. Small initials in blue or red at the beginning of lines, some with pen-flourishing in blue; line fillers in red or blue (ff. 1r-64v). Paraphs in red or blue. Rubrics in red." mdlanguages = "Old French, Anglo-Norman, Latin" mdphysical = "Materials: Parchment. Dimensions: 190 x 135mm (written space: 145 x 75/110mm). Foliation: ff. 179 (f. 179 is a parchment flyleaf fragment + 4 unfoliated paper flyleaves at the beginning and at the end). Script: Gothic, written above the top line. Layout: Parts written in two columns. Binding: BM/BL in-house. Rebound in 1959." mdownership = u"Origin: France, N.W. (Normandy). Provenance: The abbey of Mont Saint-Michel, dated ?1280: inscribed 'anno octog[esimo]', (f. 64r); a 15th-century ownership inscription, 'Iste liber est de thesauraria montis' is in the outer margin of f. 1r. Jaques Cujas, humanist scholar and legal expert (b. 1529, d. 1590), perhaps taken by him, as authorised by Nicolas le Fevre on behalf of Louis XIII, from the abbey library in c.1582 (see Genevieve Nortier, Les bibliotheques médiévales des abbayes bénédictines de Normandie (Caen: Caron et cie, 1966), p. 151); his books were dispersed at his death and this manuscript may have returned to the abbey then.In the 1739 catalogue of the abbey of Mont Saint Michel: see Bernard de Montfaucon, Bibliotheca bibliothecarum manuscriptorum nova, 2 vols (1739), II, p. 1360), no. 216: 'Histoire du Mont St Michel en vers, faite du temps de l'Abbé Robert de Torigny' (r. 1154-1186). In 1799 the manuscripts of the abbey library were moved to Avranches, but a number were lost. The present manuscript was removed from the collection between 1799 and 1835, when the first inventory was made in Avranches.Richard Heber, landowner and book collector (b.1773, d. 1833), probably bought by him in Europe in the early 18th century; his sale, 20 February 1836, lot 1702; purchased by the British Museum." mdbibliography = u"Catalogue of Additions to the Manuscripts in the British Museum in the Years 1836-1846 (London: British Museum, 1843), p. 27. H. L. D. Ward and J. A. Herbert, Catalogue of Romances in the Department of Manuscripts in the British Museum, 3 vols (London: British Museum, 1883-1910), I (1883), pp. 179-80, 812-13; II (1893), pp. 259-65. John Howard Fox, Robert de Blois, son oeuvre didactique et narrative. Étude linguistique et littéraire suivie d'une édition critique avec commentaire et glossaire de 'l'Enseignement des princes' et du 'Chastoiement des dames' (Paris: Nizet, 1950), [an edition of the text, ff. 172-175r]. Anthony J. Holden, 'Le Roman des Franceis' in Etudes de langue et de littérature du moyen age: Offertes à Felix Lecoy (Paris: Honoré Champion, 1973), pp. 213-33 (p. 214). Félix Lecoy, 'À propos du Romanz des Franceis d'André de Coutances', Phonétique et linguistique romanes. Mélanges offerts à M. Georges Straka, Revue de linguistique romane, 34, (1970), pp. 123-25. R. Graham Birrell, 'Regional vocabulary in Le Roman du Mont Saint-Michel', Romania, 100 (1979), 260-70 (p. 261). Willem Noomen, 'Auteur, narrateur, récitant de fabliaux, le témoignage des prologues et des épilogues', Cahiers de civilisation médiévale, 35 (1992), 313-50 (pp. 321-22). Ruth Dean and Maureen Bolton, Anglo-Norman Literature, A Guide to Texts and Manuscripts (London: Anglo-Norman Text Society, 1999), nos. 220.1, 501r. Le Jongleur par lui-meme: Choix de dits et de fabliaux, ed. by Willem Noomen (Louvain: Peeters, 2003), pp. 276-311 [includes an edition of the text on ff. 175-178]. Lydie Lansard, 'De l'Évangile de Nicodème au Roman de la Résurrection d'André de Coutances', Apocrypha, 16, (2005), pp. 229-51. Le Roman du Mont Saint-Michel (xiie siècle), ed. by Catherine Bougy, Les manuscrits de Mont Saint Michel, Textes fondateurs, 2 vols (Avranches: Presses Universitaires de Caen, 2009), II, pp. 43-45, pl. I-IV, VI-IX, XI,XII [contains a description and edition of ff. 1-64], online at http://www.unicaen.fr/services/puc/sources/gsp/index.php?page=sommaire [accessed 05.11.2013]. Lydie Lansard and Laurent Brun, 'London, British Library Additional 10289', Arlima, Archives de littérature du Moyen Age (University of Ottawa, 2010) at http://www.arlima.net/mss/united_kingdom/london/british_library/additional/010289.html [accessed 15.11.2013]." manifest.set_metadata({ "Date": mddate, "Title": mdtitle, "Location": mdlocation, "Contents": mdcontents, "Languages": mdlanguages,
from factory import ManifestFactory import os # Example script to build a manifest out of all the images in a directory destdir = "/path/to/images" fac = ManifestFactory() fac.set_debug("error") fac.set_base_image_uri("http://localhost/iiif") fac.set_base_image_dir(destdir) fac.set_iiif_image_info() fac.set_base_metadata_uri("http://localhost/prezi/") fac.set_base_metadata_dir("/path/to/prezi/") mflbl = os.path.split(destdir)[1].replace("_", " ").title() mfst = fac.manifest(label=mflbl) seq = mfst.sequence() for fn in os.listdir(destdir): ident = fn[:-4] title = ident.replace("_", " ").title() cvs = seq.canvas(ident=ident, label=title) cvs.add_image_annotation(ident, True) mfst.toFile(compact=False)
mdhash["Bibliography"] = """<div> <b>1936</b> Venturi, Lionello. Cézanne: son art, son oeuvre. 2 vols. Paris, 1936. <b>1967</b> Chappuis, Adrien. Album de Paul Cézanne (sketchbook facsimile). Paris: Berggruen & Cie, 1967. <b>1973</b> Chappuis, Adrien. The Drawings of Paul Cezanne. 2 vols. Greenwich: New York Graphic Society, 1973. <b>1983</b> Rewald, John. Paul Cézanne: The Watercolors. Boston: Little, Brown & Company, 1983. </div>""" mdhash["Catalog Raisonné Ref"] = "Chappuis 1973, no. 1149, State and others" mdhash["Accessioning Number"] = "1992.51.9" mdhash["Page Size"] = "15.2 x 23.7 cm (6 x 9 5/16 in.)" description = "Sketchbook with 71 drawings in graphite, pen and brown ink, and watercolor; the sketchbook contains 46 sheets, several which are blank; the end papers, the recto of the first page, and half the verso of the final page were used for notes, lists, and arithmetical figuring; a draft of a letter to the critic Octave Mirbeau is on page II (recto)" attribution = "Held by the National Gallery of Art" mf = fac.manifest(ident="manifest", label=label) mf.set_metadata(mdhash) mf.description = description mf.viewingHint = "paged" mf.viewingDirection = "left-to-right" seq = mf.sequence(ident="normal", label="Normal Order") cvs1 = seq.canvas(ident="cover", label="Cover") cvs1.set_image_annotation("76219") for s in subs: title = s.xpath('./dt[@class="title"]/a/text()')[0] date = s.xpath('./dd[@class="created"]/text()')[0] link = s.xpath('./dd/a/@href')[0][-10:-5]
#!/usr/bin/env python # -*- coding: Windows-1252 -*- import sys from factory import ManifestFactory msref = "add_ms_10289" fac = ManifestFactory() fac.set_base_metadata_uri("http://sanddragon.bl.uk/IIIFMetadataService/") fac.set_base_image_uri("http://sanddragon.bl.uk/IIIFImageService/") fac.set_iiif_image_conformance(1.1, 2) # Version, ComplianceLevel fac.set_debug("warn") # 'error' will turn off warnings manifest = fac.manifest(ident="add_ms_10289", label="Add MS 10289") mddate = u'1275 - 1300'.encode('utf-8') mdtitle = "Li Romanz du Mont Saint-Michel, a miscellany of romances, moralistic and religious texts and medical recipes" mdlocation = "British Library" mdcontents = u"Contents: ff. 1r-64r: Guillaume de Saint Pair or Guillelme de Seint Paier, Li romanz du Mont Saint Michel or Roman de Mont Saint Michel, incipit, 'Molz pelerins qui vunt al munt', explicit, 'Longue de corne ou il est mis'. ff. 64r-81v: Andreu de Costances, Une estoire de la resurrection de Jesu Crist, or Verse Gospel of Nicodemus in verse, incipit, 'Seignors mestre Andreu de costances..', explicit, 'Les boens mist hors lessa les maux'; f. 81v: Recipe for a lotion to whiten the skin, incipit, 'Ogneme[n]t espue por blanchir'; ff. 82r-121r: Roman de la destruction de Jerusalem or Le livre de Titus ou de Vespasian, a chanson de geste, incipit, 'Seignors or entende chevalier seriant', explicit, 'nel doit len pas mescroire'; ff. 122r-129r: Medical recipes or Secrets de medecine, incipit 'A la dolor deu chief polieul cuit..', explicit, 'tant q[ue] il sue cest ce qui plus vaut'. f. 129v: De saint Nicaise, in Latin, incipit 'Sanctus Nichasius habuit mac[u]lam in oculo'; ff. 129v-132v: André or Andreu de Costances: Le romanz des Franceis or Arflet, incipit, 'Reis arflet de nohundrelande', explicit, 'Q[ue]r p[ar]tot dit veir cest la fin.'; f. 132v: List of twelve pairs of France, incipit, 'Dux burgondie'; ff. 133r-172r: Petrus Alphonsus: Fables, a French translation of the Disciplina Clericalis entitled Chatoiment d'un pere a son fils, incipit, 'Qui veut henor eu siecle aveir', explicit, 'Garni le tienge en son vivant'; ff. 172r-175r: Robert de Blois, Compendium Amoris, extracts from Chastoiement des Dames, incipit,'[M]einte gent parolent damors', explicit, 'lor veut dex li dont honte ame'; ff. 175v-178v: Colin Malet: Fabliau de Juglet or Jouglet, incipit, 'Jadis en coste mon ferrant', explicit, 'Q[ue] assez miez [con]chie lui'. Decoration: A historiated initial in colours with frame in red of two pilgrims with staffs (f. 1r). An ink drawing in brown of the church of Mont Saint Michel burning with flames in red (f. 45v). Two puzzle initials in red and blue with penwork decoration (ff. 82r,133r). Initials in blue with penwork decoration in red or in red with penwork decoration in blue at the beginning of chapters. Small initials in blue or red at the beginning of lines, some with pen-flourishing in blue; line fillers in red or blue (ff. 1r-64v). Paraphs in red or blue. Rubrics in red." mdlanguages = "Old French, Anglo-Norman, Latin" mdphysical = "Materials: Parchment. Dimensions: 190 x 135mm (written space: 145 x 75/110mm). Foliation: ff. 179 (f. 179 is a parchment flyleaf fragment + 4 unfoliated paper flyleaves at the beginning and at the end). Script: Gothic, written above the top line. Layout: Parts written in two columns. Binding: BM/BL in-house. Rebound in 1959." mdownership = u"Origin: France, N.W. (Normandy). Provenance: The abbey of Mont Saint-Michel, dated ?1280: inscribed 'anno octog[esimo]', (f. 64r); a 15th-century ownership inscription, 'Iste liber est de thesauraria montis' is in the outer margin of f. 1r. Jaques Cujas, humanist scholar and legal expert (b. 1529, d. 1590), perhaps taken by him, as authorised by Nicolas le Fevre on behalf of Louis XIII, from the abbey library in c.1582 (see Genevieve Nortier, Les bibliotheques médiévales des abbayes bénédictines de Normandie (Caen: Caron et cie, 1966), p. 151); his books were dispersed at his death and this manuscript may have returned to the abbey then.In the 1739 catalogue of the abbey of Mont Saint Michel: see Bernard de Montfaucon, Bibliotheca bibliothecarum manuscriptorum nova, 2 vols (1739), II, p. 1360), no. 216: 'Histoire du Mont St Michel en vers, faite du temps de l'Abbé Robert de Torigny' (r. 1154-1186). In 1799 the manuscripts of the abbey library were moved to Avranches, but a number were lost. The present manuscript was removed from the collection between 1799 and 1835, when the first inventory was made in Avranches.Richard Heber, landowner and book collector (b.1773, d. 1833), probably bought by him in Europe in the early 18th century; his sale, 20 February 1836, lot 1702; purchased by the British Museum." mdbibliography = u"Catalogue of Additions to the Manuscripts in the British Museum in the Years 1836-1846 (London: British Museum, 1843), p. 27. H. L. D. Ward and J. A. Herbert, Catalogue of Romances in the Department of Manuscripts in the British Museum, 3 vols (London: British Museum, 1883-1910), I (1883), pp. 179-80, 812-13; II (1893), pp. 259-65. John Howard Fox, Robert de Blois, son oeuvre didactique et narrative. Étude linguistique et littéraire suivie d'une édition critique avec commentaire et glossaire de 'l'Enseignement des princes' et du 'Chastoiement des dames' (Paris: Nizet, 1950), [an edition of the text, ff. 172-175r]. Anthony J. Holden, 'Le Roman des Franceis' in Etudes de langue et de littérature du moyen age: Offertes à Felix Lecoy (Paris: Honoré Champion, 1973), pp. 213-33 (p. 214). Félix Lecoy, 'À propos du Romanz des Franceis d'André de Coutances', Phonétique et linguistique romanes. Mélanges offerts à M. Georges Straka, Revue de linguistique romane, 34, (1970), pp. 123-25. R. Graham Birrell, 'Regional vocabulary in Le Roman du Mont Saint-Michel', Romania, 100 (1979), 260-70 (p. 261). Willem Noomen, 'Auteur, narrateur, récitant de fabliaux, le témoignage des prologues et des épilogues', Cahiers de civilisation médiévale, 35 (1992), 313-50 (pp. 321-22). Ruth Dean and Maureen Bolton, Anglo-Norman Literature, A Guide to Texts and Manuscripts (London: Anglo-Norman Text Society, 1999), nos. 220.1, 501r. Le Jongleur par lui-meme: Choix de dits et de fabliaux, ed. by Willem Noomen (Louvain: Peeters, 2003), pp. 276-311 [includes an edition of the text on ff. 175-178]. Lydie Lansard, 'De l'Évangile de Nicodème au Roman de la Résurrection d'André de Coutances', Apocrypha, 16, (2005), pp. 229-51. Le Roman du Mont Saint-Michel (xiie siècle), ed. by Catherine Bougy, Les manuscrits de Mont Saint Michel, Textes fondateurs, 2 vols (Avranches: Presses Universitaires de Caen, 2009), II, pp. 43-45, pl. I-IV, VI-IX, XI,XII [contains a description and edition of ff. 1-64], online at http://www.unicaen.fr/services/puc/sources/gsp/index.php?page=sommaire [accessed 05.11.2013]. Lydie Lansard and Laurent Brun, 'London, British Library Additional 10289', Arlima, Archives de littérature du Moyen Age (University of Ottawa, 2010) at http://www.arlima.net/mss/united_kingdom/london/british_library/additional/010289.html [accessed 15.11.2013]." manifest.set_metadata({"Date": mddate, "Title": mdtitle, "Location": mdlocation,"Contents": mdcontents, "Languages": mdlanguages, "Physical Description": mdphysical, "Ownership": mdownership, "Bibliography": mdbibliography}) manifest.description = "Li Romanz du Mont Saint-Michel, a miscellany of romances, moralistic and religious texts and medical recipes" manifest.viewingDirection = "left-to-right" seq = manifest.sequence(ident="normal", label="Normal Order")
destdir = "/path/to/images/fitzwilliam" fac = ManifestFactory() fac.set_base_image_uri("http://iiif-dev.localhost/services/2.0") fac.set_iiif_image_info(version="2.0") basemd = "http://localhost/prezi/fitz/" basedir = "/path/to/htdocs/prezi/fitz/" fac.set_base_metadata_uri(basemd) fac.set_base_metadata_dir(basedir) fh = urllib.urlopen(baseq+q) data = fh.read() fh.close() results = json.loads(data) mfst = fac.manifest(label="Marlay Cuttings") seq = mfst.sequence() for res in results['results']: if not res.has_key('image'): continue ident = res.get('identifier') name = res.get('Name') title = res.get('Title', name) img = res['image']['thumbnailURI'] # And grab the thumbnail, such as it is... dest = "fitz_%s.jpg" % ident destfn = os.path.join(destdir, dest) if not os.path.exists(destfn): print "Fetching %s: %s" % (title, img)
print "Processing Set: %s" % sinfo['name'] except: print "Processing Set: %s" % s sys.stdout.flush() if os.path.exists(s): continue os.mkdir(s) fac = ManifestFactory() fac.set_base_metadata_uri(BASE_MD_URL + "/%s/%s/" % (host, s)) fac.set_base_metadata_dir(os.path.join(os.getcwd(), s)) fac.set_base_image_uri(BASE_IMG_URL + "/%s/%s/" % (host, s)) fac.set_iiif_image_info("2.0", "1") fac.set_debug('error') manifest = fac.manifest(label=sinfo['name']) if sinfo['desc']: manifest.description = str(sinfo['desc']) manifest.attribution = "Converted from http://%s/" % host manifest.viewingHint = "individuals" sequence = manifest.sequence() dom = get_xml('http://%s/oai/oai.php?verb=ListRecords&set=%s&metadataPrefix=oai_dc' % (host, s)) recs = dom.xpath('/o:OAI-PMH/o:ListRecords/o:record', namespaces=ALLNS) lastrec = None for rx in range(len(recs)): rec = recs[rx] do_record(rec, rx, host, s, cxn, sequence, lastrec) rt = dom.xpath('/o:OAI-PMH/o:ListRecords/o:resumptionToken/text()', namespaces=ALLNS) while rt: lastrec = recs[-1]