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
.
#!/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())
Good catch
. No it didn't (wasn't necessary in my case though, as all my scuttle bookmarks were public as well). I've updated the script and now it does post all bookmarks to del.icio.us as not shared (just like their import funtion on their website).
Ah okay. The scuttle API does not export the privacy state by default. adding status=\"".$row['bStatus']."\" in the echo line at the end of the loop in api/posts_all.php fixes that.
The python script above then could use the following to set the shared option only when needed:
if bookmark.getAttribute('status') > 0: post['shared'] = 'no'
(untested)
2008/07/30 23:53There's a small typo in your script: post['ds'] should be post['dt'], otherwise the date will be ignored and all imported bookmarks will be added as current.
2008/08/06 23:06Oh and you are missing the following line to also import the bookmark descriptions:
post['extended'] = bookmark.getAttribute('extended').encode('utf-8')
2008/08/06 23:16Hat mir geholfen den Umzug schnell fertig zu bekommen, danke. Das einzig schwere war, es wieder zu finden, da es irgendwie nicht in der Tag-Cloud unter scuttle, delicious und bookmark auftaucht.
2008/12/27 09:23
Does your code take care of the privacy status of the scuttle links? From looking at it, it doesn't seem so?