Posted By

chrisaiv on 01/04/11


Tagged

ruby xml


Versions (?)

Ruby: Capturing Song Title information from an IceCast Server


 / Published in: Ruby
 

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

  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  

You need to login to post a comment.