- if node.can_download:
- if not download_list.has_seen(node):
- print "Downloading:", node.title
- if node.download():
- download_list.mark_seen(node)
- else:
- print >>sys.stderr, "Failed to download!", node.title
- return
-
- if count >= len(pattern):
- print "No match found for pattern:", "/".join(pattern)
- return
- p = pattern[count]
- for child in node.children:
- if fnmatch.fnmatch(child.title, p):
- match(download_list, child, pattern, count+1)
-
-
-def main():
- node = load_root_node()
- download_list = DownloadList("downloaded_auto.txt")
-
- for search in sys.argv[1:]:
- search = search.split("/")
- match(download_list, node, search)
+ if node.can_download:
+ if not download_list.has_seen(node):
+ if node.download():
+ download_list.mark_seen(node)
+ else:
+ print >>sys.stderr, "Failed to download!", node.title
+ return
+
+ if count >= len(pattern):
+ print "No match found for pattern:", "/".join(pattern)
+ return
+ p = pattern[count]
+ for child in node.get_children():
+ if fnmatch.fnmatch(child.title, p):
+ match(download_list, child, pattern, count+1)
+
+
+def main(destdir, patternfile):
+ os.chdir(destdir)
+ node = load_root_node()
+ download_list = DownloadList()
+
+ for line in open(patternfile):
+ search = line.strip().split("/")
+ match(download_list, node, search)