-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathconfig_example.py
74 lines (65 loc) · 2.18 KB
/
config_example.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
import json
import os
CONFIG_PATH = "config.json"
example_config = {
"HEADERS": {
"authority": "app.onewheel.com",
"accept": "*/*",
"accept-language": "en-US,en;q=0.9",
"referer": "https://app.onewheel.com/rides.html",
"sec-ch-ua": '"Google Chrome";v="95", " Not A Brand";v="99", "Chromium";v="95"',
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": "Windows",
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-origin",
"sec-gpc": "1",
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36",
},
"COOKIES": {
"_orig_referrer": "",
"_landing_page": "%2F",
},
"ONEMAP_LOCATION": "Your_Location_Here",
"ONEMAP_MAX_DISTANCE": 10.0,
"ONEMAP_NICKNAME": "Your_Nickname_Here",
}
def load_config():
if os.path.exists(CONFIG_PATH):
with open(CONFIG_PATH, "r") as f:
config = json.load(f)
else:
config = example_config
save_config(config)
return config
def save_config(config):
with open(CONFIG_PATH, "w") as f:
json.dump(config, f, indent=4)
def update_config_if_missing():
config = load_config()
updated = False
if "Your_Location_Here" in config["ONEMAP_LOCATION"]:
config["ONEMAP_LOCATION"] = input(
"Please enter your location (e.g., 'Buffalo, NY'): "
)
updated = True
if config["ONEMAP_MAX_DISTANCE"] == 10.0:
config["ONEMAP_MAX_DISTANCE"] = float(
input(
"Please enter the maximum distance in miles you'd like to search for rides: "
)
)
updated = True
if "Your_Nickname_Here" in config["ONEMAP_NICKNAME"]:
config["ONEMAP_NICKNAME"] = input(
"Please enter your OneWheel app Nickname (display name on leaderboards): "
)
updated = True
if updated:
save_config(config)
return config
if __name__ == "__main__":
config = update_config_if_missing()
print(
"Configuration has been updated. Please ensure the values are correct."
)