Six Colors
Six Colors

by Jason Snell & Dan Moren

This Week's Sponsor

Magic Lasso Adblock: 2.0x faster web browsing in Safari

By Jason Snell

Macros to make dumb typing smarter

I made a mistake today. I posted today’s episode of Downstream with the feed pointed at the previous episode of Downstream. There are various workflow reasons why this happened, but the bottom line is: I pasted last week’s download URL in and then didn’t change it, resulting in everyone getting the wrong episode. Oops.

So, in the aftermath of fixing that error, I tried to figure out a way to prevent it from ever happening again. I took inspiration from a different system I use to post a different podcast to do it. Both approaches have one utility in common: Keyboard Maestro. (You could easily use another macro utility such as TextExpander if you wanted.)

I use the original macro to post The Incomparable. In that case, I am provided a unique ID string from my host, ART19. ART19 generally prefers to host podcast RSS itself, but I didn’t want to do that, and the ART19 download URL can be derived from the unique ID that displays on the webpage used to post a new episode.

I could type that URL by hand and then paste in the unique ID, but the chances for error in doing that are extremely high. If I mistype a character, or copy a previous episode’s ID and forget to change it, I’m in trouble!

So I created a Keyboard Maestro that fires when I type the string ;art19 and replaces that text with `https://rss.art19.com/episodes/%SystemClipboard%.mp3`. Now all I have to do is copy the unique ID and type that special string in The Incomparable’s CMS, and there’s no chance I will mistype something and mess it up.

For Downstream it’s a little more complicated. Every file is named the same, with only the episode number changed. Rather than copy and paste it from the previous episode and increment by one, I decided to steal some code from my Template Gun AppleScript app and check Downstream’s RSS feed to determine what the current episode number is:

set theFeed to (do shell script "curl https://www.relay.fm/downstream/feed")
set theFeed to (characters 1 thru 2500 of theFeed) as string
set theEpisode to characters ((offset of "<itunes:episode>" in theFeed) + 16) thru ((offset of "</itunes:episode>" in theFeed) - 1) of theFeed as string
return (theEpisode + 1)

Keyboard Maestro places the result of that script in a variable I called epnum, and then when I type ;downstreammp3 it replaces what I typed with https://traffic.libsyn.com/secure/relaydownstream/downstream%Variable%epnum%.mp3.

(Update: Sure, you can do this in Shortcuts. Here’s a link to the same process as a six-action Shortcut.)

That’s it. Now I’ve transformed two instances of perilous typing in my life that require me to know a specific URL pattern to simple auto-expanding macros.

If you appreciate articles like this one, support us by becoming a Six Colors subscriber. Subscribers get access to an exclusive podcast, members-only stories, and a special community.


Search Six Colors