Ruby:从IceCast服务器捕获歌曲标题信息

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Ruby:从IceCast服务器捕获歌曲标题信息相关的知识,希望对你有一定的参考价值。

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 + " " + item.link + " " + item.description + " "
  24.   end
  25. =end
  26. end

以上是关于Ruby:从IceCast服务器捕获歌曲标题信息的主要内容,如果未能解决你的问题,请参考以下文章