Skip to content

Instantly share code, notes, and snippets.

@JamesHarrison
Created February 23, 2012 01:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JamesHarrison/1889003 to your computer and use it in GitHub Desktop.
Save JamesHarrison/1889003 to your computer and use it in GitHub Desktop.
#!/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