From 420bc469a486d99f62084841428c325ae769b76a Mon Sep 17 00:00:00 2001 From: ryuslash Date: Thu, 11 Feb 2010 21:20:16 +0100 Subject: [PATCH] Added --category With --category, a category can be specified which will be downloaded, but only that run, next time the configured category will take over again --- .gitignore | 2 +- 4grab.py | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index fa1554f..58ca1a8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ *~ *.pyc -#*# +\#*\# .* \ No newline at end of file diff --git a/4grab.py b/4grab.py index adb47ca..dbefd78 100755 --- a/4grab.py +++ b/4grab.py @@ -35,9 +35,14 @@ This program comes with ABSOLUTELY NO WARRANTY. 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") (options, args) = parser.parse_args() +if options.confval and options.tempcat: + print "Cannot set a value and download" + exit(1) + if options.confval: if not config.Configuration().option_exists(options.confval[0]): print "%s: error: %s is not a valid configuration option" % (sys.argv[0], options.confval[0]) @@ -46,6 +51,8 @@ if options.confval: config.Configuration().set_option(options.confval[0], options.confval[1]) config.Configuration().save() exit(0) +elif options.tempcat: + config.Configuration().set_category(options.tempcat) base_url = "http://boards.4chan.org/%s/" % (config.Configuration().get_category())