What's the best way to export a complete history of my last.fm scrobbles? The data seems to be there on the website so in theory it could be screen scraped if all else fails but is there an easier way?
7 Answers
As Backing up Last.FM scrobbles explains you should be able to use the script lastexport.py in LastToLibre. To use it:
- Download lastexport.py.
Run it with the following terminal command:
python lastexport.py -u last.fm_user_name
Note that this requires you to have Python installed and that you replace
last.fm_user_name
with your last.fm user name. Also note that if you got real time stats hidden (under privacy settings) you have to enable it for this to work.You can now find the exported tracks in the same directory as the script. By default it will be named exported_tracks.txt
The script also allows for exporting loved and banned tracks. By default it exports scrobbles but you can change the behavior by setting the flags -t
to either loved
or banned
.
If you want to backup loved songs you can use sync_songs. It requires Ruby which can be installed via
sudo apt-get install ruby1.9.1.
on Debian-based systems. The simplest way to install sync_songs is via RubyGems (which can be installed via sudo apt-get install rubygems1.9.1
on Debian-based systems):
sudo gem install sync_songs
For details and other ways to install see the readme.
To use it with Last.fm you need an API account as described in services.org. It is free and quite easy to get such an account. Once you have an account you can backuo Last.fm loved tracks to a CSV file by first a creating an empty file and then issuing the following
sync_songs sync --color -vs smith:lastfm:loved file_path:csv:library
You need to replace smith
with your Last.fm user name and file_path
with the path to the empty file.
Update: Last.fm now provides a web-based way of doing this: you hit the button, and you get an e-mail with a download link when the data is ready.
-
9
Maybe there is something at Build Last.fm you could use?
Rather than screen scraping, they do have an api that you could use to pull your library among other functions.
-
Yes, thanks, the answer seems to be the user.getRecentTracks API call with appropriate parameters, see: last.fm/api/show/user.getRecentTracks– akentFeb 25, 2012 at 5:17
-
You can use Ben Foxall's Last.fm to CSV exporter, which will fetch the pages of your history and save it in CSV format. The code is available on Github if you want to incorporate into a JS project.
If you have Node.js you can use the lastfmexport command-line utility. It supports line-delimited JSON and tab-separated CSV. It has a very small memory footprint as it continually streams to file instead of buffering the entire scrobble history in memory.
npm install lastfmexport -g
-
Thanks! python version crashed at 1MB but this one worked great, plus makes either JSON or CSV, python output looked harder to deal with. Aug 19, 2015 at 19:38
Also, you can export your Scrobbles in XML or CSV with a web utility I wrote. It uses the Last.fm API to pull all your scrobble data into one file you can download. Large libraries (playcount > 100k) do take some time though.
As a developer that's really interested in statistics for my own play history, I ended up writing a web-based tool to get my Last.fm scrobble history. While I did find a few tools online, they were either broken and/or required the user to download script files and manually run the backup process on their own computer. In the meantime, I see there are a couple other working, web-based options. If none of the others happen to work for what you're trying to do, give this one a shot. It will back up all of your Last.fm scrobble data by year in JSON format, and allow you to download a .zip file with the full history.
Here's a link to the tool: Last.fm Backup
-
2
-
This might also be helpful: Your answer is in another castle: when is an answer not an answer?– aleFeb 11, 2016 at 17:58
-
I have undeleted this because of the disclosure, but have only let it stand because this is a broad question that has survived from the olden days. This is an exception due to the effort that has been shown.– jonscaFeb 14, 2016 at 0:31