Stopped saying Failed and Skipped things
Now it summarizes at the end
This commit is contained in:
parent
c85a69a893
commit
5516dbbcae
2 changed files with 24 additions and 5 deletions
18
4grab.py
18
4grab.py
|
@ -54,7 +54,11 @@ def walk_with_wizard(baseurl):
|
||||||
|
|
||||||
t = download.get_thread_links(baseurl)
|
t = download.get_thread_links(baseurl)
|
||||||
t = download.get_image_links(baseurl, t)
|
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(
|
parser.set_usage(
|
||||||
"""%prog [options]
|
"""%prog [options]
|
||||||
|
@ -97,7 +101,11 @@ elif options.thread:
|
||||||
else:
|
else:
|
||||||
print "if THREAD is not an absolute URL, CATEGORY must also be specified"
|
print "if THREAD is not an absolute URL, CATEGORY must also be specified"
|
||||||
exit(1)
|
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)
|
exit(0)
|
||||||
elif options.tempcat:
|
elif options.tempcat:
|
||||||
config.Configuration().set_category(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_thread_links(base_url)
|
||||||
t = download.get_image_links(base_url, t)
|
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
|
||||||
|
|
11
download.py
11
download.py
|
@ -93,6 +93,9 @@ def get_image_links(baseurl, t = []):
|
||||||
return mysubparser.get_hyperlinks()
|
return mysubparser.get_hyperlinks()
|
||||||
|
|
||||||
def get_images(t = []):
|
def get_images(t = []):
|
||||||
|
skipped = 0
|
||||||
|
failed = 0
|
||||||
|
downloaded = 0
|
||||||
total = len(t)
|
total = len(t)
|
||||||
progress = progressbar.Progress(total)
|
progress = progressbar.Progress(total)
|
||||||
i = 1
|
i = 1
|
||||||
|
@ -107,12 +110,16 @@ def get_images(t = []):
|
||||||
break
|
break
|
||||||
except IOError:
|
except IOError:
|
||||||
tries -= 1
|
tries -= 1
|
||||||
print "\rDownloading of", link, "failed,", tries, "left"
|
if tries == 0:
|
||||||
|
failed += 1
|
||||||
|
else:
|
||||||
|
downloaded += 1
|
||||||
else:
|
else:
|
||||||
print "\rNot downloading", link, "already downloaded"
|
skipped += 1
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
progress.complete()
|
progress.complete()
|
||||||
|
return (skipped, failed, downloaded, total)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
# Get a file-like object for the 4chan.org w/imgboard
|
# Get a file-like object for the 4chan.org w/imgboard
|
||||||
|
|
Loading…
Reference in a new issue