gdown
gdown copied to clipboard
Add support to an user defined progress bar inside download function.
This commit just introduces a new argument to the download function: bar
. The argument let the person who is developing code define his own progress bar using whatever he wants to. It also requires the pattern of passing the current size of the file and the total size.
An external function should be defined like
class MyBar:
def __init__(self, total):
self._total = total
self.n = 0.0
def update(self, cur_chunk_size):
self.n += cur_chunk_size / self._total
print(f"{self.n} %")
And then used as:
mybar = MyBar(total=total)
gdown.download(id=id, bar=mybar.update)
Signed-off-by: Julio Faracco [email protected]