Created
February 23, 2012 01:21
-
-
Save JamesHarrison/1889003 to your computer and use it in GitHub Desktop.
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 | |
# Example script showing how to extract website content and set RDS parameters | |
require 'rubygems' | |
require 'nokogiri' | |
require 'open-uri' | |
begin | |
rt = "" | |
doc = Nokogiri::HTML(open('http://insanityradio.com/')) | |
doc.css('#whatson_now .showdesc a').each do |l| | |
rt = l.content rescue "" | |
end | |
# If we've found a valid show name on the page, use it | |
if rt.size > 2 | |
rt << " on Insanity Radio" | |
else # If not, set a default | |
rt << "The Jukebox on Insanity Radio" | |
end | |
# Run our RDS radiotext setter script to set the RT1 parameter | |
puts `/home/insanity/control/set_radiotext.rb "#{rt}"` | |
rescue Exception => e | |
puts "Couldn't set the radiotext" | |
puts e.inspect | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment