How to import fever saved links into instapaper

Wednesday, March 3rd, 2010

After months of hearing about instapaper from a number of different sources I finally decided to try it out.  For those of you who don’t know, instapaper focuses on one thing: “A simple tool to save web pages for reading later.”

This is something that I’ve never found a good solution for.  I’m not yet completely convinced that instapaper is the solution either, but it looks promising.  In order to really give it a good try though I needed to find a way to get my read later list added.  Adding my Pinboard read later list was easy enough, there weren’t many of them, and when you click on links there it opens the page allowing the use of the read later bookmarklet supplied by instapaper.  My big list of items to read later though, comes from fever.  When I find an item that I definitely want to read, but can’t read at the moment, I click to save the item, and I had amassed a list of 193 read later links in fever.

Beside the fact that I didn’t want to go through and manually add 193 links using the bookmarklet, fever makes it more difficult even than that.  When you click to view an item in fever on the iphone where I was doing my list creation, it opens the item inside a frame so that it can still display the fever navigation.  This meant that I ended up bookmarking the same url a number of times before I realized what was happening.  You can click to view in Safari, which opens the actual url so you can them add it to instapaper, but then you lose your place in the fever navigation and have to scroll through and find the next item to mark.  In a desktop browser fever opens items in a new window without the fever nav, so it would be easier to do, but it was still too much work for 193 items.

I looked up the Instapaper api which turns out to be very simple, I ran a few tests to be sure I knew how to use it, and then moved on to figuring out how to get the links out of fever.  I logged into the mysql server for my fever install and did the following (stripping out all the stumbling around figuring out how the db is set up)

use fever_db;
select link from fever_items where is_saved=1 into outfile "/tmp/fever.txt";
exit

This dumped a list of links, one per line, into a text file in my /tmp directory.  I had to put the file in the /tmp directory because that was one of the few places the mysql user had permissions to write to, I moved the file into my home directory and fired up emacs to write the following shell script in my home directory:

#!/bin/sh                                                                                               
# Set the field seperator to a newline                                                                  
IFS="                                                                                                   
"
# Loop through the file
for line in `cat fever.txt`;do
#encode the link and then send it through to instapaper
 url=`urlencode $line`
curl "https://www.instapaper.com/api/add?username=ultrabob&auto-title=1&url="$url
done

Note: This shell script won’t work for you directly.  Where it says ?username=ultrabob you’ll need to replace ultrabob with your own username or e-mail address and if your account is password protected you’ll need to add &password=your_password_here.  When I wrote this script my account wasn’t password protected.  Now it is.

I had named the script heatinstapaper.sh so I just needed to set it to be executable, and then run it since it was in the same directory as fever.txt.

chmod +x heatinstapaper.sh
~/heatinstapaper.sh

Soon I started to see a series of 201’s show up in my terminal, which is the code for success so I was happy.  After the script finished a quick count of the 201’s showed that it had imported all 193 links.  This is a one time script.  From now on I just need to add my fever items directly to instapaper instead of the more convenient step of saving them in fever, but that is a minor issue when dealing with links one at a time.  I’m now happy that my saved for later links from fever are in my instapaper and I can start whittling down the list.  I hope this helps someone else.

By UltraBob at 01:58 AM Link to this post here!