Stopped saying Failed and Skipped things

Now it summarizes at the end
This commit is contained in:
ryuslash 2010-02-12 00:04:34 +01:00
parent c85a69a893
commit 5516dbbcae
2 changed files with 24 additions and 5 deletions

View file

@ -54,7 +54,11 @@ def walk_with_wizard(baseurl):
t = download.get_thread_links(baseurl)
t = download.get_image_links(baseurl, t)
download.get_images(t)
(skipped, failed, downloaded, total) = download.get_images(t)
print "Downloaded: ", downloaded
print "Skipped: ", skipped
print "Failed: ", failed
print "Total: ", total
parser.set_usage(
"""%prog [options]
@ -97,7 +101,11 @@ elif options.thread:
else:
print "if THREAD is not an absolute URL, CATEGORY must also be specified"
exit(1)
download.get_images(t)
(skipped, failed, downloaded, total) = download.get_images(t)
print "Downloaded: ", downloaded
print "Skipped: ", skipped
print "Failed: ", failed
print "Total: ", total
exit(0)
elif options.tempcat:
config.Configuration().set_category(options.tempcat)
@ -106,4 +114,8 @@ 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)
download.get_images(t)
(skipped, failed, downloaded, total) = download.get_images(t)
print "Downloaded: ", downloaded
print "Skipped: ", skipped
print "Failed: ", failed
print "Total: ", total

View file

@ -93,6 +93,9 @@ def get_image_links(baseurl, t = []):
return mysubparser.get_hyperlinks()
def get_images(t = []):
skipped = 0
failed = 0
downloaded = 0
total = len(t)
progress = progressbar.Progress(total)
i = 1
@ -107,12 +110,16 @@ def get_images(t = []):
break
except IOError:
tries -= 1
print "\rDownloading of", link, "failed,", tries, "left"
if tries == 0:
failed += 1
else:
downloaded += 1
else:
print "\rNot downloading", link, "already downloaded"
skipped += 1
i += 1
progress.complete()
return (skipped, failed, downloaded, total)
if __name__ == "__main__":
# Get a file-like object for the 4chan.org w/imgboard