Skip to content

Instantly share code, notes, and snippets.

@igneus
Created April 19, 2021 14:55
Show Gist options
  • Save igneus/d0a77f2a197ce18e9a1d0aeac852bdfe to your computer and use it in GitHub Desktop.
Save igneus/d0a77f2a197ce18e9a1d0aeac852bdfe to your computer and use it in GitHub Desktop.
hymnologica.cz - check which Cantus IDs are available at CantusIndex
# reads Cantus IDs on stdin, tries to fetch every one from CantusIndex, prints result
require 'mechanize'
def exists?(cantusid)
uri = "http://www.cantusindex.org/id/#{cantusid}"
agent = Mechanize.new
begin
agent.get uri
rescue Mechanize::ResponseCodeError
return false
end
true
end
ARGF.each do |cantusid|
cantusid.strip!
puts(cantusid + ',' + exists?(cantusid).to_s)
sleep 2
end
# prints all sequence Cantus IDs available at hymnologica.cz
require 'mechanize'
uri = 'http://hymnologica.cz/sequences-ids'
agent = Mechanize.new
page = agent.get uri
page.parser.css('table.views-table tbody tr td:first').collect do |i|
puts i.text.strip
end
#!/bin/bash
ruby hymnologica_sequence_id_list.rb | ruby cantusindex_missing_ids.rb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment