A Pythonista Script to Add a Link to Wallabag


posted on March 31, 2015

Wallabag is an open-source alternative to Read It Later services like Instapaper and Pocket. I installed this on my server yesterday, and dragged the bookmarklet to my toolbar. However, I was thinking of how to easily add a link on my iOS device. I could just add the javascript bookmarklet in mobile Safari, but I don't always come by links while using the browser.

Upon inspecting the bookmarklet code, I saw that the URL one wants to import has to be converted to base64. Even TextTool does not handle this conversion. Fortunately, HyShai on Twitter reminded me that Pythonista supports base64 conversion.

Although I do not code in Python, I was able to look at other people's scripts and cobble together the following:

This script takes whatever is on the clipboard, converts it to base64, and appends it as the value of an URL parameter for importing a link into Wallabag. To send the URL to Pythonista, I use the following Launch Center Pro URL action: