rendered paste bodyfrom xml.dom.minidom import parsefrom urllib import urlopen, urlretrievefrom sys import argvfrom re import compile, Ifrom os.path import exists, basenamefrom os import symlink, getcwdfrom time import strftimeLINK_DIR = "/home/johan/Desktop"patterns = [compile(p.strip(), I) for p in open(argv[2]) if p[0] != '#']rss = parse(urlopen(argv[1]))def child(no, na): return no.getElementsByTagName(na)[0].firstChild.datafor i in rss.getElementsByTagName("item"): url = child(i, "link") hashed_file = "%d.torrent" % url.__hash__() fancy_path = "%s/%s" % (LINK_DIR, basename(url)[:basename(url).rfind("?")]) if not exists(hashed_file): for p in patterns: if p.search(child(i, "title")): print "%s: Downloading %s.torrent..." % \ (strftime("%a, %d %b %Y %H:%M:%S"), child(i, "title")), urlretrieve(child(i, "link"), hashed_file) symlink("%s/%s" % (getcwd(), hashed_file), fancy_path) print "done" break