-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmenu_module.py
More file actions
164 lines (154 loc) · 5.23 KB
/
Copy pathmenu_module.py
File metadata and controls
164 lines (154 loc) · 5.23 KB
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
import config
def run_menu():
print("--------------------------------------------------")
print("Welcome to Reddit image extractor version 1.2.4")
print("--------------------------------------------------" + "\n")
prompt_subreddits()
prompt_sort_type()
prompt_down_limit()
def prompt_subreddits():
while True:
if not config.subreddit:
edit_subreddits()
break
subreddits = get_subreddits()
print("You have set: " + subreddits + "As your default, do you wish to change it? [y/N]" + "\n")
change_subreddit_input = input().lower()
print("")
if change_subreddit_input == "" or change_subreddit_input == "n":
break
elif change_subreddit_input == "y":
edit_subreddits()
break
def get_subreddits():
subreddits = ""
for subreddit in config.subreddit:
subreddits = subreddits + subreddit + " "
return subreddits
def edit_subreddits():
while True:
if config.subreddit:
print("You have set: " + get_subreddits() + "what do you wish to do?:" + "\n")
else:
print("You have not set any subreddits")
print("1 Add subreddit")
print("2 Clear")
print("3 Done" + "\n")
change_subreddit_choice = input()
print("")
if change_subreddit_choice == "1":
new_subreddit_input = input("Enter subreddit: ")
print("")
config.subreddit.append(new_subreddit_input)
elif change_subreddit_choice == "2":
config.subreddit = []
elif change_subreddit_choice == "3":
if config.subreddit:
break
def prompt_sort_type():
while True:
sort_type = config.sort_type
if sort_type == "":
sort_type = "Hot"
print("You have set: " + sort_type + " as your default, do you wish to change it? [y/N]" + "\n")
change_subreddit_input = input().lower()
print("")
if change_subreddit_input == "" or change_subreddit_input == "n":
break
elif change_subreddit_input == "y":
edit_sort_type()
break
def edit_sort_type():
while True:
print("What do you wish to choose?" + "\n")
print("1 Hot")
print("2 New")
print("3 Rising")
print("4 Controversial")
print("5 Top")
print("6 Gilded" + "\n")
type_choice = input()
print("")
if type_choice == "1":
break
elif type_choice == "2":
config.sort_type = "new"
break
elif type_choice == "3":
config.sort_type = "rising"
break
elif type_choice == "4":
config.sort_type = "controversial"
prompt_sort_arg("controversial")
break
elif type_choice == "5":
config.sort_type = "top"
prompt_sort_arg("top")
break
elif type_choice == "6":
config.sort_type = "gilded"
break
def prompt_sort_arg(arg_type):
while True:
sort_arg = config.sort_arg
if sort_arg == "":
sort_arg = "Past 24 hours"
print("You have set: " + sort_arg + " as your default, do you wish to change it? [y/N]" + "\n")
change_subreddit_input = input().lower()
print("")
if change_subreddit_input == "" or change_subreddit_input == "n":
break
elif change_subreddit_input == "y":
edit_sort_arg(arg_type)
break
def edit_sort_arg(arg_type):
while True:
print("What time frame do you wish to choose?" + "\n")
print("1 Past hour")
print("2 Past 24 hours")
print("3 Past week")
print("4 Past month")
print("5 Past year")
print("6 All time" + "\n")
type_choice = input()
print("")
if type_choice == "1":
config.sort_arg = "?sort=" + arg_type + "&t=hour"
break
elif type_choice == "2":
break
elif type_choice == "3":
config.sort_arg = "?sort=" + arg_type + "&t=week"
break
elif type_choice == "4":
config.sort_arg = "?sort=" + arg_type + "&t=month"
break
elif type_choice == "5":
config.sort_arg = "?sort=" + arg_type + "&t=year"
break
elif type_choice == "6":
config.sort_arg = "?sort=" + arg_type + "&t=all"
break
def prompt_down_limit():
while True:
if config.down_limit <= 0:
edit_down_limit()
break
print("You have set: " + str(config.down_limit) + " As your default, do you wish to change it? [y/N]" + "\n")
change_down_limit_input = input().lower()
print("")
if change_down_limit_input == "" or change_down_limit_input == "n":
break
elif change_down_limit_input == "y":
edit_down_limit()
break
def edit_down_limit():
while True:
user_input = input("Enter number of pictures you wish to download: ")
print("")
try:
val = int(user_input)
config.down_limit = val
break
except ValueError:
print("That's not an int!" + "\n")