Building Tracklog

Article · October 2026

Tracklog turns your Apple Music library into a SQL database and shows you your listening stats, all inside your browser.

Try it live ↗ Source on GitHub ↗

Why

Apple Music doesn't give you much: no all-time stats, no Wrapped whenever you want it. But it does let you export your whole library (Library.xml) with play counts, skips and dates. I wanted to practice real SQL on data I actually care about, so: what if that file became a proper database, and every stat on the page was just a query you could read?

What you get

Drop in your Library.xml (or try the sample) and you get total hours, top songs and artists with album covers, each playlist's most-played song, genres, forgotten favourites (30+ plays, nothing in six months), most skipped, and when you added stuff. There's also a SQL console to write your own queries.

No server, no account. The file never leaves your computer.

How it works

Library.xml ─► parse ─► SQLite in the browser ─► one SQL query per card ─► charts

It's SQLite running in the browser through sql.js, with plain HTML, CSS and JS: no framework, no build step, about 1,500 lines total. Your library gets parsed into a normalized schema (artists → albums → tracks, plus playlists), and every card on the dashboard is one query in its own .sql file, so you can see exactly where each number comes from.

Here's one I like, each playlist's most-played song in one pass:

WITH ranked AS (
  SELECT p.name AS playlist,
         v.title || ' – ' || v.artist AS top_song,
         ROW_NUMBER() OVER (PARTITION BY p.playlist_id ORDER BY v.play_count DESC) AS rn,
         SUM(v.play_count) OVER (PARTITION BY p.playlist_id) AS plays
  FROM playlists p
  JOIN playlist_tracks pt ON pt.playlist_id = p.playlist_id
  JOIN v_tracks v ON v.track_id = pt.track_id
)
SELECT playlist, plays, top_song FROM ranked WHERE rn = 1 ORDER BY plays DESC;

The annoying part: album covers

Library.xml has zero images, and a music dashboard without covers looks dead. So every song gets looked up on the iTunes Search API, which turned out to be the hardest part of the whole thing:

  • Search "See You Again" and you get a dozen different songs, so it matches exact title and artist and skips live, remix and karaoke versions.
  • Some songs just don't show up, so it falls back to anything from the same album (same cover anyway).
  • If nothing matches, you get a placeholder instead of the wrong cover.
  • Apple allows ~20 searches a minute, so lookups are spaced out and back off when blocked.
  • Every cover gets cached, so repeat visits load instantly.
697songs in my real library
~20,000plays across about 1,266 hours
39 / 39songs on the dashboard got the right cover
~1,500lines for the whole app

Tested on my own Apple Music library.

Building it with AI

I built Tracklog with Claude. I'd describe what I wanted, it'd write the code, and I'd test it on my own library and push back when something was off. It started as a Python script, went through four names (Apple Music analyzer → Liner Notes → Heavy Rotation → Tracklog) and three designs before landing on the "Ink & Sage" look I mocked up myself.

My job was mostly judgment: deciding what the dashboard should say, noticing when numbers looked wrong, and asking "where's the SQL?" until the code was readable.

Shipping it

Before sharing it I did a proper launch pass: link previews and SEO, a 404 page, upload errors that actually make sense, a strict Content-Security-Policy, an integrity hash on sql.js, and a privacy page that matches what the code really does (only the title, artist and album of songs on screen go to Apple for covers, and you can turn that off).

What's next

Diffing weekly exports to rebuild listening history and find streaks (a classic gaps-and-islands SQL problem), time-of-day patterns once Apple's full privacy export arrives, and CSV export.

Try it live ↗ View on GitHub ↗ ← Back to home