
I wrote myself a small Dart web app that consists of just 1 Dart file (so the smallest of the small). Using the last.fm API, it fetches every track played from my library through this Last.fm API method: 👻 This link is now just a fossil from the days when people still trusted the internet.. And I learned a lot of new things about Dart. Originally I wanted to write it in PHP, but there was a major problem there – the missing HttpRequest class. Sure, there are several such classes in external packages, but I couldn’t get them imported into VS, and I even tried compiling them for Windows when their Windows version wasn’t available.
Good thing I didn’t try installing Linux again :/. Now it finally works flawlessly. I wrote this program because I’ve been waiting 5 days for the email with my export from last.fm. They’re supposed to send it within 7 days, but I’ve stopped believing it will come. On top of that, the third-party Python script was buggy and slow, because it didn’t use the API but parsed web pages instead. So that’s another plus of my program – when last.fm moves/changes/renames some HTML elements, the other program stops working.
In my opinion, the chance that the API changes is smaller than the chance that the look of the site changes. The program downloads data in XML and also generates XML, which is another advantage, because the Python script produced a plain text file. As you can see in the pictures, the website showed 72806 scrobbled tracks, but the program downloaded “only” 72756. If your library contains an artist/title/album/etc. with characters such as < , > and other XML special characters, the program fails to parse it and discards the whole chunk.
A chunk is a list of songs from the last.fm library of a given size, which you choose yourself. The minimum size is logically about 1, the maximum roughly 1000. Those aren’t my limits; with a chunk size above 1000 the program sometimes crashed with an HTTP error 500 - Internal Server Error. Back to the point – it’s better to choose smaller chunks(20-50). The program will run longer, even considerably longer, but if it hits an XML error, it discards a smaller portion of songs. I’ll publish the Dart script as soon as I make it more user-friendly. For now I don’t enter anything into forms anywhere, because everything is in the code. I don’t know yet whether anyone interested will have to enter their own API Key and Secret, or whether I’ll somehow hash them into my program.
The program works like this:
- Last.fm asks whether you trust the application, and after you confirm, the page freezes on last.fm. That’s the standard behavior. FF asks what you want to do about the page not responding, but you can check “don’t show this again” and click wait. In Chrome and Opera no window about an unresponsive script pops up. In IE the script doesn’t work at all, probably due to Google’s strategy of “implement the Dart VM in IE, otherwise websites compiled from Dart won’t work in IE“.
- Open the developer console; in Chrome you can open it with
ctrl+shift+i, for example. You’ll see which chunk the program is on and any errors. - The program prints all your scrobbles, sorted by play count in descending order, as XML into the browser window, where you select everything (
ctrl+a) and paste it wherever you want.

And now I’m off to nuke my entire music library and start fresh from scratch, without Gigi ;). The web application is at www.sunamo.cz and you can read the source code at 👻 This link is deader than Flash Player..