Added a wizard

The wizard uses his robe and wizard hat to help you download images
This commit is contained in:
ryuslash 2010-02-11 23:46:23 +01:00
parent f09ea95c84
commit c85a69a893

View file

@ -28,6 +28,34 @@ import download
base_url = "http://boards.4chan.org/"
parser = optparse.OptionParser()
def walk_with_wizard(baseurl):
print "Alright, let me put on my robe and wizard hat."
# Single or all
inp = None
prompt = "Would you like to download a single thread, or all? "
inp = raw_input(prompt)
while (inp != "single" and inp != "all"):
print "Please type single or all"
inp = raw_input(prompt)
if inp == "single":
inp = raw_input("Which thread would you like to download? ")
if inp[:7] == "http://":
t = download.get_image_links("", [inp])
else:
thread = inp
inp = raw_input("Which category is this thread in? ")
t = download.get_image_links("%s%s/res/" % (baseurl, inp), [thread])
else:
inp = raw_input("Which category would you like to download? ")
config.Configuration().set_category(inp)
baseurl = "%s%s/" % (baseurl, config.Configuration().get_category())
t = download.get_thread_links(baseurl)
t = download.get_image_links(baseurl, t)
download.get_images(t)
parser.set_usage(
"""%prog [options]
@ -37,12 +65,16 @@ This is free software, and you are welcome to redistribute it
under certain conditions.""")
parser.add_option("-e", nargs=2, dest="confval", metavar="CONF VALUE", help="Set configuration option CONF to be VALUE")
parser.add_option("-c", "--category", dest="tempcat", metavar="CATEGORY", help="Set the category to CATEGORY only for this run")
parser.add_option("-t", "--thread", dest="thread", metavar="THREAD", help="""Download only THREAD. If THREAD is only an ID, CATEGORY must also be set. Otherwise, no problem :-)""")
parser.add_option("-t", "--thread", dest="thread", metavar="THREAD", help="Download only THREAD. If THREAD is only an ID, CATEGORY must also be set. Otherwise, no problem :-)")
parser.add_option("-w", "--wizard", action="store_true", dest="wizard", help="I'll put on my robe and wizard hat and help you get some of those pictures you like")
(options, args) = parser.parse_args()
if options.confval and options.tempcat:
print "Cannot set a value and download"
if options.confval and (options.tempcat or options.thread or options.wizard):
print "Can't configure something and do something else too."
exit(1)
if options.wizard and (options.tempcat or options.thread or options.confval):
print "Can't take a walk with the wizard and do something else too."
exit(1)
if options.confval:
@ -53,6 +85,9 @@ if options.confval:
config.Configuration().set_option(options.confval[0], options.confval[1])
config.Configuration().save()
exit(0)
elif options.wizard:
walk_with_wizard(base_url)
exit(0)
elif options.thread:
if options.thread[:7] == "http://":
t = download.get_image_links("", [options.thread])