-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
55 lines (44 loc) · 1.24 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import argparse
from src import to_csv
from src import get_searcher, AVAILABLE_SEARCHERS
from src.scraper import requester
def get_parser():
"""Parse the input arguments"""
parser = argparse.ArgumentParser(description="Scrap azlyrics page")
parser.add_argument(
"--output", "-o",
type=str,
dest="output_file",
default="output.csv",
required=True,
help="Output file name."
)
parser.add_argument(
"--search_by",
choices=AVAILABLE_SEARCHERS,
type=str,
dest="search_by",
required=True,
help="Set how to search by parameter."
)
parser.add_argument(
"--search", "-s",
type=str,
dest="search",
required=True,
help="Search the following string."
)
parser.add_argument(
"--batch_size",
type=int,
dest="batch_size",
help="Set the request batch size."
)
return parser.parse_args()
if __name__ == "__main__":
args = get_parser()
if args.batch_size:
requester.batch_requests = args.batch_size
searcher = get_searcher(name=args.search_by)
for result in searcher(args.search):
to_csv(output_file=args.output_file, songs=result.run())