The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
What’s playing

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Premshree Pillai

Posts: 478
Nickname: premshree
Registered: Mar, 2004

Premshree Pillai is a Ruby evangelist, working with Yahoo!.
What’s playing Posted: Jun 4, 2006 5:50 PM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Premshree Pillai.
Original Post: What’s playing
Feed Title: Premshree's Personal Weblog
Feed URL: http://premshree.livejournal.com/data/rss
Feed Description: Premshree's Weblog
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Premshree Pillai
Latest Posts From Premshree's Personal Weblog

Advertisement

I play all my music from iTunes now (most of it is on my FreeBSD box, though, served using mt-daapd). Anyway, time to update my current song script:

#!/opt/local/bin/ruby

require "rubygems"
require "net/ssh"
require "net/sftp"

script = <<SCRIPT
        tell application "iTunes"
                set {art, nm} to {artist of current track, name of current track}
                set disp to art & " - " & nm
                if disp is "" then
                        set disp to current stream title
                end if
                return disp
        end tell
SCRIPT

song = `osascript -ss -e '#{script}'`.chomp

exit if song == ""

`convert -fill black -pointsize 12 'label:#{song}' curr_song.png`

Net::SFTP.start("<host>", "<username>", "<password>") do |sftp|
        File.open("songs.txt", "a") { |f| f.write "#{song} (#{Time.now.to_s})\n" }
        ["songs.txt", "curr_song.png"].each { |file|
                sftp.put_file(file, "public_html/journal/#{file}")
        }       
end

Yeah, that’s a bit of AppleScript in there.

I’ve set it up to run every ten minutes. It also generates a list of all the songs I’ve played. I can probably use that data to figure not-so-useful patterns.

Read: What&rsquo;s playing

Topic: Making the cover of LinuxJournal Previous Topic   Next Topic Topic: Truth

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use