How to quickly link all your YouTube chapter markers using Shortcuts

If you publish YouTube videos or livestreams with chapter markers, you might want to link back to those moments – here's how to generate the full list using Apple's Shortcuts app.

Earlier this week, I was putting together my “offsite” blog post for the YouTube stream I recorded while editing in Final Cut Pro for iPad and wanted to make a linked list of all the chapter markers that I added to the livestream.

Each chapter on YouTube must be formatted as a timecode, but making YouTube links to specific timestamps requires a “total seconds” value at the end of the URL, like &t=3600 – something I wasn’t about to do manually for all 90 chapters.

In order to convert everything to the right format quickly and generate URLs to each chapter, I built two shortcuts:

Converting timecodes to total seconds

To start, I broke out the timecode functionality into its own shortcut since it is a distinct process, involves some complex calculations, and I wanted to test it while building it without iterating through all my chapters each time.

The shortcut assumes only a timecode value in the 00:00:00 or 00:00 format, checking for either one by splitting at the colon (:) and counting the number of items in the resulting list. If there’s 3 sets of numbers, we’ll need to account for the hour value, and if there’s only 2 values, we only need to multiple the minutes and seconds.

Then, the shortcut gets each item from the list, declares it as a variable (to make the formula easier to understand), and performs a series of calculations to multiple the hour value by 60 to generate the minutes so far, them multiplying that by 60 again and adding the seconds to come to the total value.

As an example, 01:40:32 becomes ((1 x 60) + 40) * 60 + 32 = 6032 total seconds.

If no hour value is given, the “Otherwise” condition is triggered and the shortcut performs the same math, multiplying the total minutes by 60 and adding that to the seconds value as well.

When this shortcut is finished, it outputs the total seconds value – in my next shortcut, this whole shortcut is utilized via the Run Shortcut action, which calls this as a subroutine, taking the timecode as input and passing out the total seconds as a result.

Making a Markdown list of YouTube chapter timestamps

Once my timecode \> seconds generator was finished, I built a second shortcut to take each line from my list of chapter markers and convert it into a link.

This shortcut starts by accepting the YouTube link as input (either from the Share sheet or provided manually), and then in the second step asks you to paste the full list of chapter markers, which the shortcut repeats through one-by-one.

Inside the repeating process, the shortcut splits out the timecode from the title using my custom format—I always separate them using  -  (a space, a dash, and a space)— so that, working with the resulting list, the First Item is the timecode, and the Last Item is the title.

Then the shortcut passes the timecode into my converter, and the resulting total seconds value is added onto the video link and placed inside a Markdown-style link.

Once the shortcut repeats through each chapter, generates the link, and formats it as a link list item, the entire Repeat Results are combined onto new lines and passed as output.

In this instance, I put the text into Ulysses using “Paste as Markdown” before publishing it to my blog, but I also plan to use this to paste my linked list into WordPress directly so I didn’t include a final step sharing to Ulysses directly and instead set Stop & Output to Copy to Clipboard.

Link to your YouTube chapters

If you’re a YouTuber who publishes your own videos or livestreams with chapter markers included, you can use this shortcut yourself to create a linked list of all the moments in your video and publish them elsewhere for people to quickly reference – make it easy on them.

Plus, for any other potential use cases for a timecode \> total seconds converter, you can get my shortcut as a standalone function – I’ll definitely be reusing this soon…

Get the Convert YouTube chapters to Linked List shortcut and the Convert timecode to total seconds shortcut (required) in the YouTube videos folder as part of my Shortcuts Library.

Featured Shortcuts

Convert timecode to total seconds
Function for taking timecodes like 01:45:30 and adding up the hours or minutes or seconds into a single unit (seconds) that can be used for calculations; or, more specifically, YouTube timestamps.
Convert YouTube chapters to linked list
Takes a YouTube video and your provided chapter marker text, splits out the timecodes and converts them to total seconds, then formats individual links for each chapter in Markdown formatting.

Posts You Might Like