This is the first post of my series Automate. All posts in this series.
In this post I describe how I created an Automator application, which will record the latest episode of a Spotify podcast, fill out metadata like title and description and generate a file for metadata for a podcast client to subscribe to.
If you want to follow along, you need a machine with macOS and the following installed:
You also need a bit of knowledge in Apple Script, Bash scripting and JSON and be comfortable in a terminal.
Create Audio Hijack session
Audio Hijack is an application that can do complex audio pipelines, often used for recording podcasts or live streaming. We use this to capture the output of Spotify to a file. Audio Hijack has a concept of sessions, meaning various saved pipelines.
To prepare things, start Audio Hijack and create a new session based on
Application Audio template.
This post assumes you only have on session. If you have multiple, make sure
it’s at the first position.
In the session, select Spotify as Application and change the Recorder to
128 kbps (or whatever you prefer).
I recommend disabling the Output Device, but it’s helpful if you want to debug
After saving, it should look similar to this:
We need various metadata about the latest show, like title, Spotify uri or
To get those, we use the
Spotify Web API.
You need to create a Spotify App by going to the
developer dashboard and create a
client id. Fill out the fields and you’ll get a
Client ID and a
We also need the Spotify ID of the podcast you want to mirror.
To get that, click the three dots on the podcast page in Spotify,
Copy Spotify URI.
The uri looks something like
abcdef is your
Lastly, there needs to be a folder where the podcast lives.
We use a tool in our last step to generate the RSS feed, so we can
subscribe to the podcast from our favourite podcast app.
Fot the tool to work, we need to have a
podcast.toml similar to this
but without the
[[episodes]] parts in our folder.
There also needs to be an empty subfolder called
Let’s do this
1. Create an automator project
Open the Automator app and choose New Document. Then click on Application to build a .app file you can launch later.
2. Get latest episode metadata
We need the following attributes of the latest episode:
- Spotify URI
- Release date
We use Bash to get the data, so drag a new Run Shell Script onto your workflow with the following contents:
We need the metadata again later, so save it in a variable by dragging
the Set value of variable below the Bash action and giving it a name
3. Start recording process
Now we get to the messy part. Drag a Run AppleScript action to the end of the workflow and paste the following code.
Read the comments (lines starting with
--) to know what it’s doing.
Make sure the checkbox next to Automator in System Settings →
Security & Privacy → Accessibility) is checked, otherwise you will get an error
and the keyboard shortcuts won’t work.
4. Save release date to it’s own variable
We use the publish date of the episode as filename, so we need to get this first.
Drag the action Get Value of Variable into your workflow and select the
Metadata variable (or whatever you called it).
After that, drag a Run AppleScript action at the end with the following
Set the variable
ReleaseDate using a Set Value of Variable action.
5. Move file to destination
Use a Find Finder items action to search the destination folder of your Audio Hijack session for files with all of the following attributes:
- Kind is music
- Date created is today
Then drag a Run AppleScript with the following contents into your workflow to get the first item (which will be the latest).
After that, rename the file using Rename Finder Items.
Name Single Item and set
Basename only to
Then move the renamed file to
/path/to/podcast/folder/dist/episodes/ with a
Move Finder Items action.
6. Metadata and deployment
Now that we have our recording, we have to generate the RSS feed with the metadata so podcast clients can display the episodes in a nice list. After that we upload both the feed and the episode.
Use Get Value of Variable to get the
Metadata variable again.
To generate the
feed.xml, we append the metadata of an episode to a simple
I wrote a small tool just for this, which you can find here: toml-podcast.
After generating the
feed.xml, we use the AWS CLI
deploy it and the newly recorded episode to an AWS S3 bucket.
Add a Run Shell Script action with the following contents:
I use a
Cache-Control header because I serve the podcast via a CloudFront, the
AWS CDN and I want the
feed.xml to be at most 10 minutes old.
Now recording the latest episode of your favourite Spotify podcast takes just one click. If you have a spare Mac you could even start it automatically matching the release cycle of the podcast.