This python script was written to solve one very specific problem - updating the last.fm site with the information found in the .scrobbler.log file. This log file is created by (some, many, all?) portable MP3 players and is documented on the Audioscrobbler web site here.
My friend and I each bought a Sansa e260 player from Woot.com and immediately installed the excellent alternative OS, Rockbox. If you turn on the correct setting, it will create a file called ‘.scrobbler.log’, which basically lists the song you played and when you listened to it. See here for more information.
But unfortunately, the options for taking this file and using it to update your last.fm profile are pretty limited, especially on Linux. My friend was complianing about being unable to find a command line updater, as he didn’t want to bother with a fancy GUI and didn’t trust his authentication data to any old random web site. And as I as looking for a simple Python project, I began to write scroblog.
First up was a search for an Python scrobbler interface last.fm’s Audioscrobbler interface (api documentation is found here) is a pretty simple one, with just login, now_playing and submitting. Fortunately, I found exhuma’s straightforward scrobbler.py interface, so I was off and running.
Mind you, this is my first “real” Python script, so there are probably some oddities in it. It basically parses the tab delimited scrobbler log file, then uses the scrobbler.submit call to queue up the info. Periodically, scrobbler.flush is called to actually send the data to last.fm. You need to pass in at least the usernam and password for your last.fm profile. The complete list of options:
The list of options are:
- -u/–username : the last.fm profile name. Required
- -p/–password : the profile’s password. Required
- -f/–filename : the full path to the scrobbler log file to read. The default is ‘./.scrobbler.log’
- -q/–queue : max number of records to queue up before submitting the whole bunch. Default is 40. This is so the last.fm servers don’t feel like they are under attack, so don’t make this number too small. Too big and you might lose some info if there is a problem with the data
- -t/–timezone : scroblog currently ignores the timezone field in the .scrobbler.log file, because my Sansa says it is Unknown, so I’m not sure what the format is. The timestamp in the file is localtime, so we need to know what to add or subtract to this to get UTC (GMT). The default is to use Python’s timezone value, which should work unless you are running this on a computer that is in a different timezone than the one you have your MP3 player set to. It is the number of seconds to add to the localtime found in the log file in order to get a UTC timestamp. For instance, for US Eastern Daylight Saving time, this value is 18000.
You can download the file here. Just ‘tar xzvf scrobbler-1.0.tgz’ it in its own folder, move your .scrobbler.log file over and run ‘./scroblog -u username -p password’ command. Your last.fm page can take a little while to get completely caught up.
Please don’t hesitate to drop me an email if you use this program. Also if you think of other options, features or find a bug, please let me know. Thanks for using it! You can see my last.fm profile page here.
Edit (Feb. 15) : Fixed a couple of minor bugs in scroblog, so it is now v1.1. I created a link so that http://www.buddydog.org/scroblog.zip always links to the latest version.
2 Comments
Hello
I have a Sansa e260 player from Woot.com, this is real cool mp3 player
One Trackback/Pingback
[...] MP3 player, meet last.fm | Linux Brain Dump A Pythonese way to Scrobble. I’m thinking of rigging up a Python script that keeps a random (but parameterized) stream of music flowing using Justeport to my Airport Express, and it would be nice to have it update last.fm. (tags: music airtunes python) [...]
Post a Comment