def print_status(progress, file_size, start):
"""
This function - when passed as `on_progress` to `Video.download` - prints
out the current download progress.
:params progress:
The lenght of the currently downloaded bytes.
:params file_size:
The total size of the video.
:params start:
The time when started
"""
percent_done = int(progress) * 100. / file_size
done = int(50 * progress / int(file_size))
dt = (clock() - start)
if dt > 0:
stdout.write("\r [%s%s][%3.2f%%] %s at %s/s " %
('=' * done, ' ' * (50 - done), percent_done,
sizeof(file_size), sizeof(progress // dt)))
stdout.flush()
评论列表
文章目录