diff options
author | 2010-02-11 22:05:37 +0100 | |
---|---|---|
committer | 2010-02-11 22:05:37 +0100 | |
commit | f09ea95c848a29492b682f954610a23daf753e15 (patch) | |
tree | b4a7a801cbac341f51eea45cf604bc0f18aaf76f /4grab.py | |
parent | 420bc469a486d99f62084841428c325ae769b76a (diff) | |
download | 4grab-f09ea95c848a29492b682f954610a23daf753e15.tar.gz 4grab-f09ea95c848a29492b682f954610a23daf753e15.zip |
Added --thread
With --thread a signle thread ID or thread URL can be entered.
If thread is a URL, it will download it.
If thread is an ID, a category must also be set.
Diffstat (limited to '4grab.py')
-rwxr-xr-x | 4grab.py | 15 |
1 files changed, 14 insertions, 1 deletions
@@ -25,6 +25,7 @@ import sys import config import download +base_url = "http://boards.4chan.org/" parser = optparse.OptionParser() parser.set_usage( @@ -36,6 +37,7 @@ 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 :-)""") (options, args) = parser.parse_args() @@ -51,10 +53,21 @@ if options.confval: config.Configuration().set_option(options.confval[0], options.confval[1]) config.Configuration().save() exit(0) +elif options.thread: + if options.thread[:7] == "http://": + t = download.get_image_links("", [options.thread]) + elif options.tempcat: + url = "%s%s/res/" % (base_url, options.tempcat) + t = download.get_image_links(url, [options.thread]) + else: + print "if THREAD is not an absolute URL, CATEGORY must also be specified" + exit(1) + download.get_images(t) + exit(0) elif options.tempcat: config.Configuration().set_category(options.tempcat) -base_url = "http://boards.4chan.org/%s/" % (config.Configuration().get_category()) +base_url = "%s%s/" % (base_url, config.Configuration().get_category()) t = download.get_thread_links(base_url) t = download.get_image_links(base_url, t) |