Skip to content

Instantly share code, notes, and snippets.

@markpbaggett
Last active February 28, 2024 00:06
Show Gist options
  • Save markpbaggett/65f6dd4cb5a0387350d7bfb7680d3eff to your computer and use it in GitHub Desktop.
Save markpbaggett/65f6dd4cb5a0387350d7bfb7680d3eff to your computer and use it in GitHub Desktop.
Upgrade a IIIF Presentation Manifest from 2 to 3
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();
@markpbaggett
Copy link
Author

markpbaggett commented Feb 27, 2024

node upgrade.js https://cdm17217.contentdm.oclc.org/iiif/2/maps:718/manifest.json output.json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment