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.