-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathargs_parser.py
27 lines (22 loc) · 1.26 KB
/
args_parser.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
import argparse
class ArgsParser:
acc_username, acc_password, output_verbose, __input_urls_file = None, None, None, None
def __init__(self):
arg_parser = argparse.ArgumentParser(description="Download audiobooks from scribd.")
arg_parser.add_argument('-u', '--username', type=str, help='Account email/username')
arg_parser.add_argument('-p', '--password', type=str, help='Account password')
arg_parser.add_argument('-i', '--input', type=str, help='Specify the file that contains'
' book/audiobooks url list', )
arg_parser.add_argument('--headless', help='Don\'t display the browser to user',
action='store_true')
arg_parser.add_argument('-v', '--verbose', help='Increase output verbosity',
action='store_true')
args = arg_parser.parse_args()
self.acc_username = args.username
self.acc_password = args.password
self.output_verbose = args.verbose
self.__input_urls_file = args.input
self.display_browser = not args.headless
def get_books_url(self):
with open(self.__input_urls_file) as input_file:
return input_file.read().splitlines()