I listen to KCRW’s Eclectic 24 stream all day long these days. I used to have a script that was handy for getting the artist and title from the current track of a ‘net radio stream from iTunes and making a Things todo out of it for later followup. I added the script to FastScripts, assigned it to a keyboard shortcut, and it lets me just notice that I like a song, hit a keystroke, and know that the track info has been tucked away in a todo for later, so I can explore the artist a little better without breaking flow now.
That script was also a decent example of the old rb-appscript library, which allows you to write Ruby to automate Mac apps with Apple events instead of AppleScript. It was a little wonky, but it definitely made it much easier to write pretty neat desktop automations that would have involved wrangling a bunch of OSAXen with their own weird ideas.
Sadly, when I picked up my all-day stream listening habit again under The Current Circumstances, I found it wasn’t working very well: a lot of streams aren’t Doing it Right any longer, including KCRW.
Fortunately, at least, KCRW keeps its historical playlist info in JSON, so it only took about 20 minutes to:
- Discover that rb-appscript is dead, but there’s a drop-in replacement for it called rb-scpt that works fine even if Apple is quietly killing a few supporting APIs.
- Poke around in the source for the KCRW playlist page to figure out where it hides the JSON.
- Take out the parts that talk to iTunes/Music to get the track info and replace them with a quick “what’s item
0in the playlist JSON”?
rb-scpt is drop-in enough that I didn’t have to change any of that stuff from rb-appscript.