Skip to content

Instantly share code, notes, and snippets.

@bess
Created March 5, 2019 15:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bess/ef153c4ba83249a86854d673efc0e3f5 to your computer and use it in GitHub Desktop.
Save bess/ef153c4ba83249a86854d673efc0e3f5 to your computer and use it in GitHub Desktop.
A query to get iiif manifests and arks for LADNN
# How to use this file:
# Put it on a californica server in /home/deploy
# cd /opt/californica/current
# RAILS_ENV=production bundle exec rails runner "eval(File.read '/home/deploy/ladnn_iiif_report.rb')"
# NOTE: You may need to update the manifest url if you use it on a server other than californica-stage
# NOTE: At the time of this writing, the ARK is stored in the identifier field, which is multi-valued,
# and does not have the 'ark:' prefix on it. Those assumptions might change and this script will need
# to change to match the current practice for ARK storage.
require 'csv'
ladnn = Work.where(publisher: "Los Angeles Daily News")
puts "Found #{ladnn.count} objects"
CSV.open("ladnn_iiif.csv", "wb", write_headers: true, headers: ["IIIF Image API URL", "Item ARK", "IIIF manifest URL"]) do |csv|
ladnn.each do |work|
ark = "ark:/#{work.identifier.first}"
manifest = "https://californica-stage.library.ucla.edu/concern/works/#{work.id}/manifest"
file_id = work.members.first.files.first.id
image_api_url = ENV['IIIF_SERVER_URL'] + file_id.gsub('/', '%2F')
puts ark
csv << [image_api_url, ark, manifest]
end
end
puts 'export complete.'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment