For some reason that escape me I started using bitly to store short-lived bookmarks that seem out of place with "read later" services like Readability or Instapaper. This is surprising considering that in the past I completely abandoned Delicous after Yahoo! sold it off in 2011. I even wrote a Mac tool to import all your delicious bookmarks into Evernote. (The tool doesn't work anymore as the Delicous API changed since then).
Why am I using bitly then? Well, the bookmarklet works well, even in mobile browsers, and it's very simple to use. The service doesn't feel hopelessly bloated, so it doesn't attempt to be a "bookmark sync" service, even though it still remains the most popular URL shortening service out there. It is even integrated to my web site with s.benad.me being an alias to bit.ly. It's made by Betaworks which now also own Instapaper, so it's a reliable URL shortening service that's in good hands.
So, searching for "bitly bookmark backup" in any search engine proved futile, because somehow using "bitly" as a search term tends to return a bunch of unrelated bitly URL shortcuts. Luckily, they made a pretty good API that covers far beyond the basic URL shortening service, including fetching all bookmarks of your own account. So, I picked up their official bitly Python library, and started writing my own script. Here's the result.
The greatest challenges were not bitly's API or library, but my own inexperience with Python 2, which has to be used for the bitly module (I learned almost exclusively Python 3). That means that each string is either "normal" or "unicode", the latter being the default output of the bitly library (for good reason), so outputting everything as UTF-8 on the console is unintuitive. Also, there are basic issues I had, like the fact that the built-in HTTP library lacks HTTP authentication, a problem resolved by manually building the HTTP headers, which is kind of clumsy.
At any rate, I needed an excuse to practice my Python skills, and now I have nice automated backups of my bitly bookmarks.
Published on June 24, 2013 at 18:04 EDT
Older post: Learning the D Programming Language
Newer post: My Web Site, Now With HTML5