Scrobble to Last.fm with Pianobar
by Hunter Haugen
Pianobar is an excellent command-line Pandora client. It has support for calling external commands when songs play, pause, skip, et cetera via the event_command directive. With this, we can add a little scrobbling script and get our listening tracks sent to Last.fm.
First, cd to ~/.config/pianobar (or mkdir if it doesn’t exist) and paste https://gist.github.com/833064 in as scrobble.py, and chmod +x it. You’ll have to open scrobble.py and add your Last.fm API key (get one from http://www.last.fm/api) and username/password.
Next, go to pylast and get pylast.py and put it in the same directoy as scrobble.py.
Finally, open or create ~/.config/pianobar/config and put in these lines:
user = email@domain.com password = somethinglong event_command = /Users/username/.config/pianobar/scrobble.py
Bonus: If you’re a Pandora One subscriber, you can get the high-quality stream by adding the audio_format = mp3-hifi directive.
(Note: Due to shortcomings in pianobar, your password can’t have funny characters like & in it.)
When you start pianobar, it should start showing up on Last.fm after the first song finishes. If there are problems then pianobar should print them to stderr.
Edit 2011-06-02: The gist has been updated to support Now Playing. Update your scrobble.py with the new version and pianobar should automatically start updating last.fm with Now Playing.
[…] station. What is even better is that Pianobar can be used to scrobble songs to Last.fm. I found this blog post which made it extremely easy to get it all working with some tweaking to the config file in the […]
Hi, i don’t know anything about code.
so, could u plz tell me what to do after i have done all the above? because there are nothing that can run when opened, they are all codes and stuff, which i not good at.
thx!
by the way, I’m running mac os x lion :)
Sorry Ben, but this is a pretty technical blog post. If you want to enter the commands above, you can use `Terminal.app` and google around for some Introduction to Using Terminal. That should get you started.
This doesn’t seem to support “Now Playing”. Any suggestions on getting this functionality to work?
Regardless, thanks for pointing out how to get scrobbling working.
Not sure what changed (as I haven’t done anything), but Now Playing as well as normal scrobbling works great.
Thanks again :D
This solutions no longer works :(
Hi, you could make this script also submit loved tracks by adding the following code under the network.scrobble(~~~) line.
if fields[“rating”] == “1”:
track=network.get_track(artist = artist, title = title)
track.love()
Thanks!
This works really well, thanks for making it so quick and easy to get setup and going.
Really appreciate the time you took to put this together. Working a treat, so fast and easy!
Instead of downloading pylast from the url provided I used ‘easy_install pylast’ and now playing is working for me.