From a492f49b1f01a4de50eb3fb3c6afa6e24b7a5bca Mon Sep 17 00:00:00 2001 From: stoneage7 Date: Tue, 13 May 2014 21:02:43 +0200 Subject: [PATCH] "sizes" and "uploaded" lists get generated for every page user extend() instead to avoid exception --- pirate-get.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pirate-get.py b/pirate-get.py index 8028090..635e0cd 100755 --- a/pirate-get.py +++ b/pirate-get.py @@ -85,6 +85,8 @@ def main(): # Catch the Ctrl-C exception and exit cleanly try: + sizes = [] + uploaded = [] for page in xrange(pages): request = urllib2.Request(mirror + '/search/' + args.q.replace(" ", "+") + '/' + str(page) + '/7/0') request.add_header('Accept-encoding', 'gzip') @@ -104,8 +106,8 @@ def main(): # get sizes as well and substitute the   character # print res - sizes = [ match.replace(" ", " ") for match in re.findall("(?<=Size )[0-9.]+\ \;[KMGT]*[i ]*B",res) ] - uploaded = [ match.replace(" ", " ") for match in re.findall("(?<=Uploaded ).+(?=\, Size)",res) ] + sizes.extend([match.replace(" ", " ") for match in re.findall("(?<=Size )[0-9.]+\ \;[KMGT]*[i ]*B",res)]) + uploaded.extend([match.replace(" ", " ") for match in re.findall("(?<=Uploaded ).+(?=\, Size)",res)]) # pprint(sizes); print len(sizes) # pprint(uploaded); print len(uploaded) state = "seeds"