Skip to content

Instantly share code, notes, and snippets.

@njh
Created May 3, 2011 15:47
Show Gist options
  • Save njh/953586 to your computer and use it in GitHub Desktop.
Save njh/953586 to your computer and use it in GitHub Desktop.
Ruby code to get all the episode PIDs for a BBC Brand
#!/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