frac = float(existing)/float(total)except:frac = 0sys.stdout.write("\r%s %3i%%" % ("File downloaded - ", frac*100))url = raw_input('Enter URL to download folder/file: ')filename = url.split("/")[-1].strip()def test(debug_type, debug_msg):print "debug(%d): %s" % (debug_type, debug_msg)c = pycurl.Curl()c.setopt(pycurl.URL, url)c.setopt(pycurl.FOLLOWLOCATION, 1)c.setopt(pycurl.MAXREDIRS, 5)# Setup writingif os.path.exists(filename):f = open(filename, "ab")c.setopt(pycurl.RESUME_FROM, os.path.getsize(filename)else:f = open(filename, "wb")c.setopt(pycurl.WRITEDATA, f)#c.setopt(pycurl.VERBOSE, 1)c.setopt(pycurl.DEBUGFUNCTION, test)c.setopt(pycurl.NOPROGRESS, 0)c.setopt(pycurl.PROGRESSFUNCTION, progress)try:c.perform()except:pass
Thursday, 27 June 2013
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment