Shortcuts for archiving Apple Music playlists

I’m sort of a nut about metadata and archiving my digital stuff. I also like lists and enjoy listening to music. It’s all of those things that led me to my ongoing bi-monthly playlist project, where I collect the songs that strike me during a set period of time. These are time-capsules I’ve rather enjoyed making and will hopefully enjoy revisiting years down the road.

I make my lists on Apple Music, which allows me to share them on my profile with friends that follow me. What’s great about this platform, and I’m sure Spotify is the same, is that I can add a title, description and artwork specific to the playlist that is visible to all that come across it. I’m very particular about the sequencing of my playlists and equally as anal-retentive about the consistency of the metadata. These are parts of a set, after all.

So, I have this set of playlists that are just how I like them and visible to other Apple Music subscribers. Now what? Well, as with most things, I’d like to catalog them in a secondary location. I want a text-based backup, hosted on my blog here. That seemed easy enough when I started the task, but I quickly realized that hand typing each track name and artist was not a chore I wanted to undertake, especially not more than once. Cue automation!

This Shortcut asks me to choose a Playlist from a list, then runs two nested loops that grabs the title and artist name for each track and stores them in two variables. These variables are used in a text area with some light formatting to create a line of text with the pertinent information. The shortcut then combines the output of each outer loop into a single list. This is copied to the clipboard for pasting into my CMS from my iPhone or Mac.

Here’s an example of the output:

"Mr. Moonlight" - The Beatles
"Fell Asleep With a Vision" - The Spirit Of The Beehive
"The Leanover" - Life Without Buildings
"Nowhere2go" - Earl Sweatshirt
"Heaven" - Charly Bliss
"Archie, Marry Me" - Alvvays
"I Always Wanna Die (Sometimes)" - The 1975
"Left and Leaving" - The Weakerthans
"Pretty Good" - John Prine
"Revolution Lover" - Left at London
"Hurt" - Johnny Cash
"Ain't No Sunshine" - Bill Withers
"The Gold" - Manchester Orchestra & Phoebe Bridgers
"I Am a Man of Constant Sorrow" - The Soggy Bottom Boys
"I Like America & America Likes Me" - The 1975
"Let Me Down Slowly" - Alec Benjamin
"In My Dream" - The Action
"Too Late to Turn Back Now" - Cornelius Brothers & Sister Rose
"Never My Love" - The Association
"What Is Life" - George Harrison

Great! List done. Now I’d like to archive the artwork as well, but I don’t have all of the images used in my Camera Roll any more. Those that I do have are full images, not cropped to the proper proportions. I could go through the effort of tracking down the images on Unsplash again and manually cropping them, but that’s even more time intensive than the text was. No problem, I’ll just have shortcuts pull them for me like I did the titles and artist names.

Nope! ‘The Get Details of Music’ action can get a lot, but it can only touch the metadata assigned to the music itself, not the playlist. For this task, I had to look to the web and use some RegEx magic.

Note: This Shortcut seems to work on all user-generated playlists, but fails on some Apple-curated ones. Essentials and Deep Cuts can be grabbed, but others will crash the shortcut. I have not investigated why and I make no promises that I will.

Admittedly, this Shortcut could very easily be refined, however I managed to get the result I needed early in testing, so quit before I lost a few hours to HTML stripping.

We start in the Apple Music app, sharing the playlist we want the artwork for. Choosing the Photo From Playlist Shortcut from the menu will send the URL for the playlist into a chain that grabs the source of the page, then looks for the following RegEx pattern.

(http(s?):)([/|.|\w|\s|-])*\.(?:jpg|gif|png)( 3x)

This will find all of the image URLs on the page ending with “ 3x”. This string is appended to the end of URLs pointing to the highest resolution version of a given image served by Apple on the webpage. This includes the playlist artwork and song artworks.

Depending on the length of the playlist, this may return a LOT of results. My CA001 playlist returns 93 results. I only only need the first though, which is the artwork for the Playlist. Here is the URL for the first matched item.

https://is3-ssl.mzstatic.com/image/thumb/SG-S3-US-Std-Image-000001/v4/36/be/d5/36bed521-15ce-d164-f358-ef3d7301fc75/image/939x939cc.jpg 3x

The image (939x939px) is displayed on the screen for output. I AirDropped mine to my desktop to plug in on Squarespace.

Get the Shortcuts Here