Automate a YouTube Embed Code on Your iOS Device With Drafts, TextTool, and Launch Center Pro

Tweet This Post

Over the weekend I wanted to embed a video on my blog while on my iPad. The mobile YouTube site did not appear to offer an embed code, so I created a few actions to automate the process.

As an example, here is the starting URL https://m.youtube.com/watch?v=38lY-3g6mn8.

This browser bookmarklet -- I call it "TextTool Split" -- imports the URL into Drafts and triggers the "split" action:

javascript:window.location='drafts://x-callback-url/create?action=split&text='+encodeURIComponent(location.href)

The "split" URL action sends the URL to TextTool and splits the URL at the =.

texttool://x-callback-url/transform?method=split&delimiter=%3D&text=[[draft]]&x-success={{drafts://x-callback-url/create?text=[[output]]&action=line2-youtube}}

Import it here into Drafts.

The above action takes the original URL and creates a new draft:

https://m.youtube.com/watch?v

38lY-3g6mn8

It then triggers the line2-youtube action, which takes line 2, sticks it in the YouTube embed code, and saves all of that to the clipboard with the help of Launch Center Pro:

launch://clipboard?text={{<iframe width="560" height="315" src="//www.youtube.com/embed/[[line|2]]" frameborder="0" allowfullscreen></iframe>}}

Import it here into Drafts.

The result will be that the following is added to your clipboard, and you can paste it into your blog CMS:

<iframe width="560" height="315" src="//www.youtube.com/embed/38lY-3g6mn8" frameborder="0" allowfullscreen></iframe>

This action presumes that there are no additional paramaters in the URL. If your URL has something like &list= after the video ID, you will either have to manually remove that string or create an extra Drafts/TextTool action to split the results of line 2 at the & and to take line 1 of that output.


Last built: Thu, Oct 16, 2014 at 2:47 PM

By Jeffrey Kishner, Monday, June 30, 2014 at 9:03 AM.