PQRSPQRS

Skribidi: YouTube Music to Last.fm Scrobbler

2026-03-29· 3 min readSide Projects

iOS, YouTube Music and Last.fm - you get to choose only two. YouTube Music app on iOS doesn't support live scrobbling. If Last.fm Scrobbler for YouTube Music is a must, then you have to move out of iOS. Or if you want to stick to iOS and scrobble to Last.fm, then you have to switch to Spotify or Apple Music.

YouTube Music to Last.fm Scrobbler - Image created using Gemini

While we were discussing this, Prashanth HN came up with an idea of a chrome extension and built it. But it has its own limitation. For the scrobbling to happen, the user has to manually fetch and scrobble to Last.fm while on the YT Music page on your desktop. This brings in a couple of constraints - a manual step (you need to remember and sync the data every now and then) and YT Music has a limited listen history (if you forget to sync for a few days, your data is lost).

These two constraints got me thinking.

Why Not Automate It?

I started digging around if there are any third party services that solve this problem. There are, but I have to share the cookie details with them. So I decided to build my own. How hard could it be? Especially when you have Claude as a personal assistant. The plan was simple - every hour or two fetch my YouTube Music history and scrobble it to Last.fm. No manual effort - let GitHub Actions take care of the schedule. Simple enough!

To read the YT Music history, the initial plan was to use Google OAuth to get the listening history from YT Music. But soon I found out that it's a dead end. YouTube Music's internal API only accepts authentication tokens from YouTube's own apps. The workaround? Browser cookies. Instead of OAuth, I export my login session from Chrome's developer tools and use that to authenticate. It's a bit manual, but it works reliably, and the session lasts 1–3 months before needing a refresh.

But There Are No Timestamps!

Then arrived the next curve ball, YouTube Music doesn't tell you when you listened to something. Your history just says "Today" or "Yesterday" or "Monday." That's it, no timestamps! So instead of tracking exact play times, I went ahead with an approximation: whenever the script runs, it assumes songs were played about 3 minutes apart, counting backwards from now. Not perfect, but good enough for a personal music diary. The script runs every two hours, takes a snapshot of the last 50 songs played, compares with the previously saved snapshot, scrobbles the newly played songs.

Lack of timestamps brought in another challenge - if you listen to a song more than once, it just shows only once in the history. That means, if the song in the new snapshot was found in the saved snapshot then it stops scrobbling further. If you replay a song, it jumps back to the top of your history. The script would see it, recognize it from the snapshot, and stop - missing any genuinely new songs that were played after the replay. The fix was simple - instead of stopping at the first known song, scan all 50 entries and scrobble anything not in the snapshot.

What It Looks Like Now

  1. A GitHub Actions cron job fires every 2 hours
  2. It fetches your top 50 recently played tracks from YT Music (via browser cookie auth)
  3. It compares them against the last saved snapshot to find new plays
  4. New tracks are scrobbled to Last.fm with approximate timestamps (spaced 3 minutes apart)
  5. The updated snapshot is committed back to the repo for the next run

The cookie authentication expires periodically. Currently one needs to update the cookie manually in GitHub Secrets. I'm working on a Chrome Extension if that can be either automated or made a simple click of a button to fix it.

Give it a try and share your feedback - skribidi-scrobbler