If you're browsing the Tumblr or Instagram apps on your iOS device and want to get the share URL, they are formatted as follows:

http://NAME.tumblr.com/post/POST_ID/SLUG

http://instagram.com/p/POST_ID

Unfortunately, these are web links. What if you want a link that will bring you right to that post ID in the app? I have written a couple of Launch Center Pro actions to automate these processes.

Tumblr

The URL scheme for a Tumblr post (as per GitHub) is as follows:

tumblr://x-callback-url/blog?blogName=NAME&postID=POST_ID

All the information you need is in the web link, but you need to rearrange it all to make it work.

Import the Tumblr action or enter the following into LCP:

texttool://x-callback-url/transform?text=[clipboard]&method=split&delimiter=%2F&lc-icon=tumblr&x-success={{texttool://x-callback-url/transform?text=[[output]]&method=split&delimiter=.&x-success={{drafts:///create?text=[[output]]&action=tumblr-id}}}}

To make this action work, you will also need TextTool and Drafts. And you will need to import this URL action into Drafts.

Let's work with a random Tumblr post to see how this works:

http://yahoo.tumblr.com/post/90564142294/furthering-our-focus

Copy this URL to your iOS clipboard, and then tap on the Tumblr action in LCP. LCP sends this string to TextTool, which splits the string at the /:

http:



yahoo.tumblr.com

post

90564142294

furthering-our-focus

It then takes that output and sends it back to TextTool to split at the .:

http:



yahoo

tumblr

com

post

90564142294

furthering-our-focus

It then sends that output to Drafts and triggers the tumblr-id URL action:

drafts:///create?text={{tumblr://x-callback-url/blog?blogName=[[line|3]]&postID=[[line|7]]}}

This action inputs lines 3 and 7 of the draft into the relevant points of the url scheme, and creates a new draft with the final result:

tumblr://x-callback-url/blog?blogName=yahoo&postID=90564142294

And just to make the action icon look nice, I added lc-icon=tumblr.

Instagram

The Instagram action is more complicated. It requires TextTool, Drafts, and Textastic. Import the LCP action or enter this into a new action:

textastic://api.instagram.com/oembed?url=[clipboard]&lc-icon=instagram&lc-callback=[list|url=texttool://x-callback-url/transform?text=[clipboard]&method=split&delimiter=%22&x-success={{drafts:///create?text=[[output]]&action=insta-api}}|image=texttool://x-callback-url/transform?text=[clipboard]&method=split&delimiter=%22&x-success={{drafts:///create?text=[[output]]&action=insta-api-url}}]

Instagram's url scheme for a post is as follows (as per its iPhone Hooks page):

instagram://media?id=MEDIA_ID

The media ID is not part of the web URL. But we can get that info from Instagrams's Embed API. Let's use an example post (http://instagram.com/p/qJu0a-OHMC) and add it after the url=:

http://api.instagram.com/oembed?url=http://instagram.com/p/qJu0a-OHMC

This API returns JSON:

 {"provider_url":"http:\/\/instagram.com\/","media_id":"759343924702114562_1483611","title":"Another beautiful day in the city! \ud83d\ude0d","url":"http:\/\/photos-d.ak.instagram.com\/hphotos-ak-xfp1\/10537269_595401073912091_331298792_n.jpg","author_name":"newyorkcity","height":640,"width":640,"version":"1.0","author_url":"http:\/\/instagram.com\/newyorkcity","author_id":1483611,"type":"photo","provider_name":"Instagram"} 

We can see that the media_id is 759343924702114562_1483611. instagram://media?id=759343924702114562_1483611 would bring us right to that post in the app, but we need the LCP action to automate the process.

We first need an easy way to grab the HTML of the API results. Textastic has an url scheme that lets you download a file and open the HTML in the editor by replacing http:// with textastic://. The first part of the LCP action does just that. However, even though Textastic supports x-callback-url, it doesn't for this particular action. So we need to tap on the share button at top right of the screen after the HTML has downloaded, and choose "Copy All." Then we take advantage of a new feature introduced in LCP: lc-callback. For apps that do not support x-callback-url, this is the next best thing. We define the callback action, but instead of it triggering automatically after the first action, we double-tap on the home button (to get the app launcher) and choose LCP. Once we tap on LCP, the next action gets triggered.

Because the embed API also provides the raw image URL for the Instagram post, the lc-callback starts with a list. We can get the iOS url scheme ("url") or the raw image URL ("image"). Let's see what happens when you choose "url":

The entire HTML is sent to TextTool, which splits the string at ":

{

provider_url

:

http:\/\/instagram.com\/

,

media_id

:

759343924702114562_1483611

,

title

:

Another beautiful day in the city! \ud83d\ude0d

,

url

:

http:\/\/photos-d.ak.instagram.com\/hphotos-ak-xfp1\/10537269_595401073912091_331298792_n.jpg

,

author_name

:

newyorkcity

,

height

:640,

width

:640,

version

:

1.0

,

author_url

:

http:\/\/instagram.com\/newyorkcity

,

author_id

:1483611,

type

:

photo

,

provider_name

:

Instagram

}

This entire string is then sent to Drafts, and the insta-api action is triggered. Import it into Drafts or enter the following as an URL action:

drafts:///create?text={{instagram://media?id=[[line|8]]}}

It simply takes line 8 -- which contains the media_ID -- and inserts into into the URL scheme.

Now, if we would rather get the raw image URL, we choose "image" after the lc-callback. It also performs a " split and sends that output to Drafts, but it instead triggers the insta-api-url action. Import it into Drafts or enter the following URL action:

texttool://x-callback-url/transform?text=[[line|16]]&method=unescape

Line 16 -- the raw image URL -- is sent to TextTool. Why? All the forward slashes in the URL are "escaped"

   http:\/\/photos-d.ak.instagram.com\/hphotos-ak-xfp1\/10537269_595401073912091_331298792_n.jpg

so we have to unescape them:

   http://photos-d.ak.instagram.com/hphotos-ak-xfp1/10537269_595401073912091_331298792_n.jpg

This action stops at TextTool. It has sharing features, so you can do what you like with URL: e.g., download the image.

To make the action icon look nice, I added lc-icon=instagram.

Granted, this LCP action is not fluid. I think it would possible to perform the conversion without the "Copy All" and lc-callback using the JSON parser in Pythonista, but I'm not proficient enough to accomplish that as of this writing. If you write an action that accomplishes the conversion with fewer steps, I would love to hear from you in the comments section or on Twitter.

Thanks to @epramono and @youens on Twitter for helping me to understand LCP 2.3.x at a deeper level.

07/07/14; 01:38:49 PM

I use Paperless for the majority of my list-making on my iOS devices. I've already written how to mark an item as complete without using the app and how to view your lists on the web. Today, I am going to share a unix command line bash script to "print" incomplete items from a list.

I created a text file called "prl" and put it in /usr/local/bin/:

#! /bin/bash

list=$1

grep -A 1 \<dateCompleted\>\<\/dateCompleted\> ~/Dropbox/Paperless/$list.xml | sed -n 's:.*<itemName>\(.*\)</itemName>.*:\1:p'

I made it executable while in that directory: chmod +x prl

Now, to view the incomplete items in any list, I just type prl followed by the list name. If I have a list named Bills, I just type prl Bills and the script will output all bills that are due. (This script does not output the notes field.)

How It Works

All your Paperless lists are stored as XML files. I use grep to look for all items for which there is no completion date: <dateCompleted></dateCompleted> with -A 1 to also print out the lines immediately after each match (which are the list items themselves). Those results are piped into a sed which extracts any string sandwiched between <itemName> and </itemName>.

If I need to see a note, I can do a quick grep: grep -A 1 verizon ~/Dropbox/Paperless/Bills.xml. This will output all lines matching verizon plus the lines immediately following, including the XML tags. It's not pretty but it will get me the info I need (e.g., the due date).

<itemName>Verizon $100.00</itemName>

<itemNote>7/7</itemNote>
07/07/14; 11:30:32 AM

Last built: Tue, Mar 31, 2015 at 2:05 PM

By Jeffrey Kishner, Monday, July 7, 2014 at 11:30 AM.