Take the 2-minute tour ×
Web Applications Stack Exchange is a question and answer site for power users of web applications. It's 100% free, no registration required.

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?

share|improve this question

4 Answers 4

up vote 4 down vote accepted

As Backing up Last.FM scrobbles explains you should be able to use the script lastexport.py in LastToLibre. To use it:

  1. Download lastexport.py.
  2. 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.

  3. 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.

share|improve this answer

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.

http://www.last.fm/settings/dataexporter

share|improve this answer

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.

share|improve this answer
    
Yes, thanks, the answer seems to be the user.getRecentTracks API call with appropriate parameters, see: last.fm/api/show/user.getRecentTracks –  akent Feb 25 '12 at 5:17
    
There is a script to do the export via the API. –  N.N. Dec 17 '12 at 15:46

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
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.