Created
May 3, 2011 15:47
-
-
Save njh/953586 to your computer and use it in GitHub Desktop.
Ruby code to get all the episode PIDs for a BBC Brand
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
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'rdf' | |
require 'rdf/rdfxml' | |
PROGRAMMES_URL = 'http://www.bbc.co.uk/programmes' | |
PO = RDF::Vocabulary.new("http://purl.org/ontology/po/") | |
brand_pid = 'b0081dq5' | |
brand_rdf = "#{PROGRAMMES_URL}/#{brand_pid}.rdf" | |
brand_uri = RDF::URI("#{PROGRAMMES_URL}/#{brand_pid}#programme") | |
graph = RDF::Graph.load(brand_rdf) | |
episode_pids = graph.query([brand_uri, PO::episode, nil]).map do |statement| | |
statement.object.basename | |
end | |
p episode_pids |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment