]>
code.delx.au - webdl/blob - autograbber.py
1c6ef0f0b44c42783c259f99d9c071bd3dadfbd2
2 # vim:ts=4:sts=4:sw=4:noet
4 from common
import load_root_node
8 class DownloadList(object):
9 def __init__(self
, filename
):
10 self
.f
= open(filename
, "a+")
11 self
.seen_list
= set()
13 self
.seen_list
.add(line
.strip())
15 def has_seen(self
, node
):
16 return node
.title
in self
.seen_list
18 def mark_seen(self
, node
):
19 self
.seen_list
.add(node
.title
)
20 self
.f
.write(node
.title
+ "\n")
23 def match(download_list
, node
, pattern
):
25 if not download_list
.has_seen(node
):
27 download_list
.mark_seen(node
)
29 print >>sys
.stderr
, "Failed to download!", node
.title
33 for child
in node
.children
:
34 if fnmatch
.fnmatch(child
.title
, p
):
35 match(download_list
, child
, pattern
[1:])
39 print "Loading episode data...",
41 node
= load_root_node()
44 download_list
= DownloadList("downloaded_auto.txt")
46 for search
in sys
.argv
[1:]:
47 search
= search
.split("/")
48 match(download_list
, node
, search
)
50 if __name__
== "__main__":
53 except (KeyboardInterrupt, EOFError):