in Links

How to Export Your Listening History on a Mac

My goal was simple: I wanted to export all of the tracks I’ve listened and stored in my 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 data to, but it works just as well as a standalone backup.

I saved 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 -u last.fm_user_name

Make sure you replace last.fm_user_name with your own 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.