Export your Delicious.com Stacks Before they Get Removed!

Posted on Sun 29 July 2012 in tools

Delicious.com is getting rid of their "Stacks" feature, which allowed users to organize, group, comment and share their links. Now AVOS has new plans for Delicious and there is no room for Stacks anymore. I liked my Stacks, so I wrote a little Python3 script to retrieve them from my Delicious and put them in Chrome or Firefox as folders. Here's the script, so you can save your precious Stacks too.

Background

Delicious.com has been going through some changes lately, since it was acquired by AVOS and they migrated to the new platform. Back then I gave them a chance, and they came up with some good features. They implemented Stacks, a way of having folders, and lost a lot of users in the meantime who escaped to other online bookmarking alternatives.

Now they've announced Stacks will be removed in early August, and they will be replaced with tags. According to their Feature Update email they sent to their users:

All stacks will be converted automatically into tags. Stack titles will transition into new tag names, and will be applied to all links currently in a stack. Stack-specific descriptions, categories, comments, link order, and stack followers will not be included as part of the migration.

I was really disappointed to hear that, and without knowing what the new features are gonna be this time, I fear for my Stacks, which brought order to my mess of links as any folder hierarchy would do. Well, I am now ready to leave Delicious, after being a faithful user for 4 years and I don't plan on leaving without my Stacks.

The Solution

The Delicious API does not allow managing of stacks, they never released that, so this short Python3 extracts all the stacks and their links performing some traditional web scraping and then does 3 things with them:

  1. Exports them to a JSON file.
  2. ~~Modifies an existing bookmarks file in Netscape Bookmarks File Format to add stack info to known links~~. Doesn't work at the moment.
  3. Generates a new bookmarks file with stacks as folders, compatible with Chrome 20 & Firefox 14.

One interesting security related issue I stumbled upon is that you can find any stack's contents by guessing a 6 digit number, whether the stack is public or private. Not very safe, huh?

Here it is the direct link to the Python3 script to extract Stacks from Delicious. You can find the project on GitHub.

Usage

You need Python3 to run the script. It requires Beautiful Soup 4. It also expects the 3rd parameter, a previously exported bookmarks file, that you can get from delicious.com.

extract_stacks.py [delicious_username] [deliā€­cious_password] [bookmarks file]

If you have an environment with wget, Python3 and bs4 you can do:

wget https://github.com/antonioherraizs/ExportDeliciousStacks/raw/master/extract_stacks.py 
chmod u+x extract_stacks.py  
./extract_stacks.py username password bookmarks.html

Running the script will produce 3 files (if everything goes well):

  • [bookmarks file].json: a JSON formatted file with all the stacks and their links, for you do process it however you like.
  • [bookmarks file]-only-stacks.html: the stacks extracted as folders, ready to be imported into Chrome and Firefox.
  • [bookmarks file]-with-stack-info.html: this one is not parsed by Chrome at the moment and Firefox removes the stack info from the links.

Notes

  • You need to be logged in to see any private stacks/links, that's why the script asks for your username/password.
  • I couldn't find a python library that read/wrote NBFF. Disappointing, I guess no one cared enough to write one. Maybe you?
  • This isn't thoroughly tested, expect problems with validation/encodings and complex stack setups.