/Last.fm-to-iTunes-Playcount-Sync

A small script to sync your iTunes play count with your Last.fm listening data. Good to use if you've had to rebuild your library.

Primary LanguageRuby

Last.fm to iTunes Play Count Sync

About

This is a simple, stupid script to sync your playcount data from Last.fm to iTunes.

Say you’ve moved to a new laptop and didn’t move your iTunes Library data over. Or, you’ve had to rebuild your iTunes library and lost your play count data. If you’re anal retentive like me or use crazy smart playlists like me, not having correct play count data is pretty annoying.

All this tool does is grab all of your play count info from Last.fm’s weekly charts, and then goes through your iTunes library and tries to match each track to a Last.fm play count. It isn’t all that smart, so you may have to go through and change the names of some tracks to match what Last.fm has. Other than that, it seems to work pretty well.

Added bonus: Look at iTunes while the script is running and see the play counts update live. Pretty damn cool, eh?

Prerequisites

OS X 10.5
Nokogiri Gem (gem install nokogiri)
Appscript Gem (gem install rb-appscript)

Usage

  
    ruby lastfm2itunes.rb (your Last.fm username) 
    # Example:
    ruby lastfm2itunes.rb praetorian42
  

It’ll tell you what it is doing while it is running. It’ll cache the listening data as a marshalled hash in case you need to re-run the script to fix naming issues, or if you just want to play around with the listening data, which is easy: Marshal.load(File.read(“cached_lastfm_data.rbmarshal”))

Note: I’ve only used this script in Ruby 1.9.1. I don’t see any reason why it wouldn’t work in 1.8, but let me know about any incompatibilities.

As always, if you find any bugs: fork, fix and send a pull request.