-
-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathao3downloader.py
executable file
·114 lines (82 loc) · 2.95 KB
/
ao3downloader.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/usr/bin/env python3
import ao3downloader.strings as strings
from ao3downloader.actions import ao3download
from ao3downloader.actions import pinboarddownload
from ao3downloader.actions import updatefics
from ao3downloader.actions import redownload
from ao3downloader.actions import logvisualization
from ao3downloader.actions import updateseries
from ao3downloader.actions import getlinks
from ao3downloader.actions import markedforlater
from ao3downloader.actions import enterlinks
from ao3downloader.actions import ignorelist
def ao3_download_action():
ao3download.action()
def links_only_action():
getlinks.action()
def file_input_action():
enterlinks.action()
def update_epubs_action():
updatefics.action()
def update_series_action():
updateseries.action()
def re_download_action():
redownload.action()
def marked_for_later_action():
markedforlater.action()
def pinboard_download_action():
pinboarddownload.action()
def log_visualization_action():
logvisualization.action()
def ignorelist_action():
ignorelist.action()
def display_menu():
print(strings.PROMPT_OPTIONS)
for key, value in actions.items():
try:
desc = value.description
except AttributeError:
desc = value.__name__
print(' {}: {}'.format(key, desc))
def choose(choice):
try:
function = actions[choice]
try:
function()
except Exception as e:
print(str(e))
except KeyError as e:
print(strings.PROMPT_INVALID_ACTION)
display_menu.description = strings.ACTION_DESCRIPTION_DISPLAY_MENU
ao3_download_action.description = strings.ACTION_DESCRIPTION_AO3
update_epubs_action.description = strings.ACTION_DESCRIPTION_UPDATE
pinboard_download_action.description = strings.ACTION_DESCRIPTION_PINBOARD
log_visualization_action.description = strings.ACTION_DESCRIPTION_VISUALIZATION
re_download_action.description = strings.ACTION_DESCRIPTION_REDOWNLOAD
update_series_action.description = strings.ACTION_DESCRIPTION_UPDATE_SERIES
links_only_action.description = strings.ACTION_DESCRIPTION_LINKS_ONLY
marked_for_later_action.description = strings.ACTION_DESCRIPTION_MARKED_FOR_LATER
file_input_action.description = strings.ACTION_DESCRIPTION_FILE_INPUT
ignorelist_action.description = strings.ACTION_DESCRIPTION_CONFIGURE_IGNORELIST
QUIT_ACTION = 'q'
MENU_ACTION = 'd'
actions = {
MENU_ACTION: display_menu,
'a': ao3_download_action,
'l': links_only_action,
'f': file_input_action,
'u': update_epubs_action,
's': update_series_action,
'r': re_download_action,
'm': marked_for_later_action,
'p': pinboard_download_action,
'v': log_visualization_action,
'i': ignorelist_action
}
display_menu()
while True:
print('\'{}\' to display the menu again'.format(MENU_ACTION))
print('please enter your choice, or \'{}\' to quit:'.format(QUIT_ACTION))
choice = input()
if choice == QUIT_ACTION: break
choose(choice)