splitbrain.org

electronic brain surgery since 2001

From Scuttle To del.icio.us - The Quick And Dirty Way

Michael Klier recently decided to shut down his blog. Luckily he provides a tarball of all his posts and used a liberal license for his contents. With his permission I will repost a few of his old blog posts that I think should remain online for their valuable information.

This post was originally posted July, 30th 2008 at chimeric.de and is licensed under the Creative Commons BY-NC-SA License.

Today I decided to finally get rid of my scuttle installation (an Open Source del.icio.us clone) that I've used until today to manage my bookmarks. The reason is simple: I am lazy, and I don't want to worry about updates anymore. Looking for alternatives, and based on the recommendations of a few people, I decided to switch to del.icio.us. It features a superb Firefox integration, which I can confirm. The FF addon is really great! Of course I somehow had to move my scuttle bookmarks to my new del.icio.us account, so I wrote a little Python script to do the job (I am again impressed how little it takes to get stuff done in Python!). It's very quick and dirty and has no exception handling or stuff that could make your life easier ;-), but I thought I share it here. Maybe it's useful to someone else out there.

The only things you have to change are the two URLs at the top of the script, make it executable and last not least run it ;-).

scuttle2delicious.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
 
scuttle_url = 'http://username:password@domain.org/scuttle/api/posts_all.php'
delicious_url = 'https://username:password@api.del.icio.us/v1/posts/add'
 
import sys 
import time
import urllib
from xml.dom import minidom
 
def main():
    scuttle_raw = urllib.urlopen(scuttle_url).read()
    scuttle_xml = minidom.parseString(scuttle_raw);
    bookmarks = scuttle_xml.getElementsByTagName('post')
    count = bookmarks.length
 
    for bookmark in bookmarks:
        post = {}
        post['url'] = bookmark.getAttribute('href').encode('utf-8')
        post['description'] = bookmark.getAttribute('description').encode('utf-8')
        post['tags'] = bookmark.getAttribute('tag').encode('utf-8')
        post['dt'] = bookmark.getAttribute('time').encode('utf-8')
        post['shared'] = 'no'
        post['extended'] = bookmark.getAttribute('extended').encode('utf-8') 
        result = urllib.urlopen(delicious_url, urllib.urlencode(post)).read()
        print count
        count = count - 1 
        time.sleep(1.5)
 
    return 0
 
if __name__ == '__main__':
    sys.exit(main())
Tags:
guestpost, chimeric.de, scuttle, delicious, python
Similar posts: