0

I'd like the most direct way, on a Mac, to launch an Apple Music "radio" station e.g.

  • via the command line, without having to manually navigate to the radio tab in iTunes, waiting for it to load, scrolling to find the station etc.
  • avoid having to load a URL in Safari first, then wait for iTunes to load (annoying there always seems to be a few seconds delay between the webpage loading and iTunes navigating to the stream).

I attempted to do it with AppleScript.

The link to stations (get it via right click and Share Station) is in this format:

https://itunes.apple.com/gb/station/classical/ra.123456789

(I've obfuscated the numeric ID, just in case it's unique to the logged in user).

Whenever I tell iTunes to open the actual URL, instead what it does is open the last "ordinary" (non-Apple) station I played.

[AppleScript]
tell application "iTunes" to open location "https://itunes.apple.com/gb/station/classical/ra.123456789?ign-mscache=1"

Yet if you look at the webpage the http:// URL gives you (the Connecting to the iTunes Store one) there doesn't seem to be anything different/special in the body onload javascript.

1
  • Five years on (and with the loss of any proper radio service in Apple Music) I'd like to highly recommend the PyRadio command-line app, which will also appeal to people familiar with Vim keybindings. Commented Feb 7 at 11:13

1 Answer 1

1

You don't need AppleScript - can do it from the commandline directly with the right URI.

open "itmss://itunes.apple.com/us/station/listen-in-apple-music/idra.985499994?cmd=AddStation"

You're calling itmss:// because you need to hit iTunes itself.

Then, replace the code into the idra.XXXXXXXXX bit. I'm in the USA, so it's /us/station, but I suspect /gb/station would work for you, if you're in the UK.

FYI - you can actually just cmd-space and and paste just the URL into Spotlight to have it run it and open the station in iTunes directly.

2
  • Excellent, thanks! (and yes it works with /gb) For others reading, note the URL must still contain 'station', and you don't include the name of the station, just its ID. Commented Feb 14, 2019 at 10:36
  • You can also use musics instead of itmss, which appears to be how the Apple Music website does it now.
    – ma1234
    Commented Feb 7, 2023 at 23:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .