Skip to content

Instantly share code, notes, and snippets.

@franckverrot
Forked from jsmestad/tv_rage_spec.rb
Created October 4, 2009 07:17
Show Gist options
  • Save franckverrot/201225 to your computer and use it in GitHub Desktop.
Save franckverrot/201225 to your computer and use it in GitHub Desktop.
require "rubygems"
require "hpricot"
require "open-uri"
class TvRage
def self.full_schedule(country='US')
doc = self.fetch_xml('http://services.tvrage.com/feeds/fullschedule.php', 'country' => country, '24_format' => '1')
p "full_schedule - #{doc.class}"
doc.search('//show').each {|show| process_show(show) }
end
def self.fetch_xml(url, params={})
uri = url
unless params.empty?
uri << '?' + params.to_a.collect { |param| param.join('=') }.join('&')
end
doc = open(uri) do |file| Hpricot::XML(file) end
p "fetch_xml - #{doc.class}"
return doc
end
def self.process_show(show_node)
p show_node.to_s
end
end
TvRage.full_schedule
Output: different, but seems to work
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment