Ruby: Capturing Song Title information from an IceCast Server


/ Published in: Ruby
Save to your folder(s)

IceCast server's sometimes offer meta-data information on a particular piece. Here's an example of a data scrape from Classical KUSC


Copy this code and paste it in your HTML
  1. require 'cgi'
  2. require 'rss'
  3. require 'open-uri'
  4. require 'rexml/document'
  5.  
  6. xspf = "http://915.kuscstream.org:8000/kuscaudio128.mp3.xspf"
  7.  
  8. open( xspf ) do |http|
  9. response = http.read
  10.  
  11. xml = REXML::Document.new( response )
  12. xml.elements.each do |t|
  13. puts t
  14. end
  15.  
  16. =begin
  17. result = RSS::Parser.parse(response, false)
  18.   puts result
  19.  
  20.   items = result.playlist
  21.   puts items
  22.   items.each do |item|
  23.   # puts "Title:" + item.title + "\n" + item.link + " \n" + item.description + "\n"
  24.   end
  25. =end
  26. end

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.