-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.py
30 lines (26 loc) · 1.34 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import argparse
import utils as downloader
def get_args():
parser = argparse.ArgumentParser(description='fastDownloader v0.0.1')
parser.add_argument('--src', type=str, default=None,
help='This parameter specifies the file path where the links to be '
'downloaded are stored.')
parser.add_argument('--save', type=str, default='.',
help='This parameter specifies the path for storing the downloaded files. No / at the end.')
parser.add_argument('--max', type=int, default=10, help='This parameter specifies the concurrency level.')
parser.add_argument('--interval', type=float, default=0.5,
help='This parameter specifies the interval of requests.')
parser.add_argument('--chunk', type=int, default=1024,
help='This parameter specifies the number of bytes to be read per '
'download.')
return parser.parse_args()
if __name__ == '__main__':
args = get_args()
tasks = downloader.preprocessing(args.src)
task_counts = len(tasks)
if task_counts != 0:
downloader.counts = task_counts
progress_bar = downloader.generate_progress_bar()
downloader.run(tasks, args, progress_bar)
else:
print('> There are no resources that need to be downloaded!')