Created
August 16, 2009 01:03
-
-
Save lindsayevans/168513 to your computer and use it in GitHub Desktop.
This file contains 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
# Tweets the currently playing song from iTunes | |
# Requirements: | |
# Grackle: http://github.com/hayesdavis/grackle/tree/master | |
# rb-itunes: http://rubyforge.org/projects/rb-itunes/ | |
require 'rubygems' | |
require 'rb-itunes' | |
require 'grackle' | |
@@delay = 1 # in seconds | |
@@twitter_username = 'YOUR_TWITTER_USERNAME' | |
@@twitter_password = 'YOUR_TWITTER_PASWORD' | |
@@current_track = '' | |
@@itunes = ItunesApp.new | |
@@twitter_client = Grackle::Client.new(:auth=>{:type=>:basic,:username=>@@twitter_username,:password=>@@twitter_password}) | |
def get_current_track | |
@@itunes.current_track.name + ' - ' + @@itunes.current_track.artist | |
end | |
while true | |
sleep @@delay | |
current_track = get_current_track | |
if current_track != '' && current_track != @@current_track | |
@@current_track = current_track | |
puts current_track | |
@@twitter_client.statuses.update! :status => '"' + current_track + '" ♫' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment