Scrobbling iPhone played tracks to Last.fm
UPDATE: Now an even better solution — scrobble tracks straight from your iPhone to last.fm, as you play them: http://www.installerapps.com/2007/11/30/mobilescrobbler/
If you are obsessed with ensuring that your Last.fm profile is up-to-date with the most accurate music statistics for you, then you would be disappointed to discover that iScrobbler (the alternative Last.fm client for OS X that allows scrobbling tracks from your iPod) doesn’t support the iPhone or iPod Touch!
The problem is that the iPhone and iPod Touch no longer use the “volume mounting” method in iTunes (that is, where iTunes reads information from the iPod_Control folder on your iPod volume). This means iScrobbler is currently unable to detect when an iPhone or iPod touch has been plugged in.
There is a workaround described on the iScrobbler discussion forums, which involves mounting a DMG image that is a “Fake iPod” to fire the event in iTunes that allows iScrobbler to read the playlist and scrobble the tracks that you’ve listened to.
Unfortunately, this workaround means you have to load the DMG and unload it manually when you plug in or eject your device, so I wrote a shell script that detects the insertion of an iPhone (using iPhuc — sorry iPod Touch users, I don’t think this will work for you) and automatically mounts the iPod DMG to allow iScrobbler to do it’s magic.
http://www.spockboy.com/iscrobbler-iphone-automount/
There are two ways to run this script:
- Using cron. You can set the script to run once a minute and then exit. If it detects the iPhone, it will mount the “Fake iPod” DMG. If there is no iPhone, it will unmount it. You’ll want something like this in your user crontab (`crontab -e’ from Terminal):
# Run the iPhone automount daemon every minute
* * * * * /usr/local/bin/iscrobbler-iphone-automount/iscrobbler-iphone-automount.sh -qThis is how I like to roll, as it means it only spawns the iPhuc process once a minute and then kills it and exits (little system resources). You’ll want to use the -q parameter to make it quiet (to avoid cron emails).
- The alternative is to run it as a daemon and have it invoke iPhuc which waits for the iPhone to be inserted. When the iPhone is not inserted, the script respawns iPhuc every 10 seconds (or however long you specify at the top of the script) to check if an iPhone is present.You’ll need to use the -D parameter to tell the script to stay running. Also it does not spawn a daemon process itself, so you’ll need to run it inside nohup or similar. Try this from Terminal:
nohup /usr/local/bin/iscrobbler-iphone-automount/iscrobbler-iphone-automount.sh -q -D &
Piece of cake! But let’s hope iScrobbler gets fixed soon to avoid these nasty workarounds!
Comments(2)
Note that you can now scrobble tracks straight to last.fm from your iPhone. Check out MobileScrobbler.
http://www.installerapps.com/2007/11/30/mobilescrobbler/
I’m not sure how well this will come through (because of the XML) but I thought I’d contribute the launchd equivalent of your cron job.
Label
com.iscrobbler.fakeipod
ProgramArguments
/usr/local/bin/iscrobbler-iphone-automount/iscrobbler-iphone-automount.sh
-q
StartCalendarInterval
Thanks for the script.