del.icio.us and Movable Type
del.icio.us is quite a nice service. Once you've created an account you can use bookmarklets to tag pages, adding a description and a comment if you like. Given that it's nice to store things there, it seemed that it would also be nice to share them here. Hence a small chunk of Python. This was really much easier than I expected.
#!/usr/bin/python
deli_user = “dme”
mt_url = “http://www.dme.org/cgi-bin/mt/mt-xmlrpc.cgi" mt_id = “1” mt_user = “David Edmondson” mt_pass = “SecretSquirrel”
how often this script is run, in seconds: 24 hours
freq = 24 * 60 * 60
import feedparser import xmlrpclib import time import calendar
post all new items since starttime
starttime = time.time() - freq
result = feedparser.parse(“http://del.icio.us/rss/" + deli_user)
postworthy = 0 post = "” post += “<p><ul>\n”
for i in result[‘items’]: thistime = calendar.timegm(i[‘date_parsed’]) if thistime > starttime: postworthy += 1 post += “<li><a href="+ i[’link’] + “>” +
i[’title’] + “</a>: “+ i[‘description’] + “</li>\n”post += “</ul></p>\n” post += “<p align=“right”><a href=“http://del.icio.us/" +
deli_user + “">del.icio.us</a></p>\n”if postworthy > 0: server = xmlrpclib.Server(mt_url)
result = server.metaWeblog.newPost(mt_id, mt_user, mt_pass, { "title": "Quicklinks", "description": post }, True)
Save the code (I call it deli2mt), update the variables at the top of the script then run it from cron once each day. The only non-standard Python module is Mark Pilgrim's Feed Parser.