forked from castdrian/audiosnatch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
38 lines (31 loc) · 934 Bytes
/
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
import questionary
from src.chapters import get_chapters
from src.download import get_input
from src.search import search_book
from os import system, name
import argparse
cls = lambda: system('cls' if name == 'nt' else 'clear')
def main():
parser = argparse.ArgumentParser(description="Audio book downloader")
parser.add_argument("-S", "--source", choices=["toky", "freeaudiobooks"], default="toky", help="Source website")
args = parser.parse_args()
choices = [
'Search book',
'Download from URL',
'Exit'
]
selected_action = questionary.select(
"Choose action:",
choices=choices
).ask()
options = [
lambda: search_book(args.source),
lambda: get_input(args.source),
exit
]
res = options[choices.index(selected_action)]()
if res:
cls()
get_chapters(res, args.source)
if __name__ == "__main__":
main()