Created
May 15, 2012 15:46
-
-
Save itochan/2702782 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# -*- coding: utf-8 -*- | |
require "net/http" | |
require "rexml/document" | |
require "growl" | |
XML_PATH = "http://www.j-wave.co.jp/top/xml/now_on_air_song.xml" | |
TITLE = "ソラガール" | |
ARTIST = "PACO" | |
Growl.notify do | |
self.title = "soragirl.rb" | |
self.message = "running soragirl" | |
end | |
prev_song = "" | |
loop do | |
source = Net::HTTP.get(URI.parse(XML_PATH)) | |
xml = REXML::Document.new(source) | |
data = xml.elements["now_on_air_song/data"].attributes | |
now_song = data["information"].gsub(/\s\d\d:\d\d/, "") | |
unless now_song == prev_song | |
puts "#{Time.now.to_s}: #{now_song}" | |
if now_song == "「#{TITLE}」 #{ARTIST}" | |
Growl.notify do | |
self.title = "soragirl.rb" | |
self.message = "Now Playing: #{now_song}" | |
end | |
end | |
end | |
prev_song = now_song | |
sleep 20 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment