Last active
February 28, 2024 00:06
-
-
Save markpbaggett/65f6dd4cb5a0387350d7bfb7680d3eff to your computer and use it in GitHub Desktop.
Upgrade a IIIF Presentation Manifest from 2 to 3
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
const fs = require('fs'); | |
const { fetch } = require('@iiif/helpers'); | |
async function main() { | |
try { | |
const [,, manifestUrl, outputFile] = process.argv; | |
if (!manifestUrl || !outputFile) { | |
console.error('Usage: node script.js <manifestUrl> <outputFile>'); | |
return; | |
} | |
const manifest = await fetch(manifestUrl); | |
manifest['id'] = `https://raw.githubusercontent.com/markpbaggett/static_iiif/main/manifests/${outputFile}` | |
let manifestJSON = JSON.stringify(manifest, null, 2); | |
fs.writeFile(outputFile, manifestJSON, 'utf8', (err) => { | |
if (err) { | |
console.error('Error writing file:', err); | |
} else { | |
console.log(`Manifest has been written to ${outputFile}`); | |
} | |
}); | |
} catch (error) { | |
console.error('Error fetching or writing manifest:', error); | |
} | |
} | |
main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
node upgrade.js https://cdm17217.contentdm.oclc.org/iiif/2/maps:718/manifest.json output.json