26 Sep 2008 22:36
TAGS: dev lastfm python
My girlfriend was very unhappy with me not having my played songs submitted to Last.fm social music revolution portal.
That was because used to use Music Player Daemon and its various clients. Most of the clients don't implement the AudioScrobbler protocol, but as a matter of fact this is not needed, because there can be a separate MPD client meant just to submit the info to last.fm, running in parallel to one actually playing music.
I used to use scmpc for this reason, but since I bought my new laptop and migrated to Ubuntu I quit it — because the application was not in their repo.
Today I decided to find some short python-based implementation of audioscrobbler and enrich one of MPD clients with the Last.fm integration. I found pympd really good — nice looking, having plugin architecture, clean and simple. So I decided it to be my new favorite MPD client. Then I quick-hacked some random plugin and created a new one including almost 100% source from python-scrobbler project. The plugin:
- sends "now playing" info to Last.fm on each track-change and loading of plugin
- sends "song played" info to Last.fm on track-change and plugin unload event if song was listened at least to the half of its total length and is longer than 30 seconds.
Now the Last.fm user and password are hardcoded, but I hope to create a quick-and-dirty configuration window for it.
I had some problems with time convertion. The python-scrobbler sources suggest using datetime.utcnow() method while actually using datetime.now() is giving the right results.
You can check my Last.fm records:
- July — submitted by scmpc from Gentoo — the old computer
- first records in October — submitted with MY PLUGIN
- two hours gap — before fixing UTC issue, the songs were submitted as played two hours earlier (timezone difference)
So it seems working!
It's a pretty cool Python day today.