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.
2006-06-05 05:13 am (UTC)
bash$ dcop amarok playlist saveCurrentPlaylist && xsltproc ~/hacks/amarok.xsl ~/.kde/share/apps/amarok/current.xml -o ...And are you using my FreeBSD port of mt-daapd ?
2006-06-05 05:16 am (UTC)
2006-06-05 06:52 am (UTC)
When you have a hammer ...
2006-06-05 10:18 am (UTC)
One of those cases where it was done in ruby because *Premshree* was between the chair and keyboard ...
Re: When you have a hammer ...
2006-06-05 10:26 am (UTC)
And to a certain extent, I'd like to give credit to the syntax of the language.
Maybe you could force such intuitive clarity in a shell-script. I certainly can't.
Re: When you have a hammer ...
2006-06-05 10:29 am (UTC)
Apple Script: The Natural Language Metaphor.
Worship the right stuff :)
Re: When you have a hammer ...
2006-06-05 12:06 pm (UTC)
Re: When you have a hammer ...
2006-06-05 11:54 am (UTC)
Tip
2006-06-05 08:21 am (UTC)
#!/usr/bin/env ruby. It searchesPATHforrubyand executes it. This obviously makes the script more portable. Some people are bothered by it because you don't have much control over which version is picked but I think that if you need that much control you should just edit the darn line.Re: Tip
2006-06-06 12:55 pm (UTC)
Re: Tip
(Anonymous)
2006-07-13 09:21 am (UTC)
If you were on linux
2006-06-06 08:45 am (UTC)
You would be *using* amarok. :)
Re: If you were on linux
2006-06-06 12:39 pm (UTC)
Compiling kdelibs now...
Flickr.rb??
(Anonymous)
2006-06-12 09:06 pm (UTC)
Was out looking for the flickr.rb that you wrote, do you know where can I get the latest version? Couldn't find it on rubyforge ;(
Re: Flickr.rb??
2006-06-13 07:44 am (UTC)
2006-06-15 07:26 am (UTC)
please write me to maq005@yahoo.com or maqs24@gmail.com
Another alternative
(Anonymous)
2006-07-13 09:22 am (UTC)