打 The Madness of Shortcuts

There’s something I need to get off my chest about Shortcuts.

I was planning out how to bring my Shortcuts collection up to date for iOS 15. I’d not touched it in a few years, and I also had a few ideas for new Shortcuts I wanted to write and share.

One idea I had was a novel Shortcut which would let a user tune into an ATC (Air Traffic Control) live feed of their choice. I already had a prototype working, but it wasn’t especially user friendly.

My requirements were pretty simple really:

  1. Allow the user to choose an iCloud directory containing their curated selection of feed files
  2. Let the user pick a feed file and extract the feed’s URL
  3. Start streaming the feed using VLC media player

Step 1 is easy, step 3 I already had nailed via the prototype and even working on both i(Pad)OS and macOS.

Step 2 flummoxed me. Basically, the user would download a PLS file, and the Shortcut would parse it to extract the feed URL and then launch it in VLC. The file is basically plain text structured as an INI configuration file, and therefore simple to parse. Here’s how the contents look:

[playlist]
File1=http://d.liveatc.net/cyul_app
Title1=CYUL Approach/Departure
Length1=-1
NumberOfEntries=1

Sound simple, right? Something that would take a few minutes to code up in Python or a Bash script. You’d have thought Shortcuts could handle something as simple as parsing a file, right?

Wrong.

Shortcuts has several actions which can grab a file from pretty much anywhere in a user’s iCloud, or even multiple files at once. But when you want to read the contents, it will only do it if the file extension is .txt. If the file extension isn’t something commonly recognised as a text file, there’s no option for looking inside at what it contains, even if the file’s content is plain text.

I spent over an hour going through all the other Shortcut actions which I thought could be re-purposed to get the file’s contents, but I couldn’t find any which worked unless the file had a .txt extension.

I didn’t want to make the user rename all their downloaded .pls files to .txt because (a) That’s a dreadful user experience, and (b) Have you ever tried to change a file extension in the iOS Files app anyway? Spoiler you can’t.

Eventually I decided to really try and think out of the box, and hit on a solution.

Given a file, it does the following:

  1. Grabs the filename of the file as a text object.
  2. Renames the file from .pls to .txt.
  3. As the file is now has a .txt extension, the rename action actually returns the file contents
  4. Stores the file contents in another text object You need to make sure you’re capturing the contents with something immutable; Simply using a variable won’t work.
  5. Using the text object with the filename, it renames the file back to .pls.

(That final action is just there to demonstrate I successfully captured the file contents)

Awful isn’t it? I can’t think of a single reason why Apple wouldn’t let a user parse a plain text file, regardless of extension. That such a dreadful workaround is required to do so simple a thing is well it’s classic Apple really.

And herein lies the problem with Shortcuts. It’s too simplistic for power users, too complex for casual users, and it serves neither audience particularly well. And I’ve not even talked about the perpetually broken UI of the Shortcuts app.

There are third party applications which help with the kinds of tasks Shortcuts doesn’t do well, but then you end up with a Shortcut which requires the user to own a specific app, and that immediately cuts down the accessibility of your output to a small audience. And so Shortcuts designers go to incredible lengths to implement weird workarounds, like this one.

I’m not sure where I’m going with this, I think I should probably go to sleep and bask in the minor satisfaction of a small victory against the Shortcuts bureaucracy.