in Links

How to Export Your Last.fm Listening History on a Mac

My goal was simple: I wanted to export all of the tracks I’ve listened and stored in my Last.fm account. I don’t have any real experience working with APIs, but thanks to Jeroen Baert’s post, which I found via this StackExchange thread, I found a handy Python script that even a newb can run.

The script was originally written for use in moving your Last.fm data to Libre.fm, but it works just as well as a standalone backup.

I saved lastexport.py to my home folder (the one with your Mac username) and opened up a Terminal window. Then, I just pasted the following command into the Terminal prompt and pressed Enter:

python lastexport.py -u last.fm_user_name

Make sure you replace last.fm_user_name with your own Last.fm user name. The script will store the results in a text file called exported_tracks.txt, located in your Home folder or whatever other folder you saved the script in. The data in the text file is a little messy, but it’s all there.

If you know how to make the data prettier, don’t hesitate to get in touch with me.