forked from Orcuslc/BingBest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCLI.py
executable file
·47 lines (40 loc) · 1.16 KB
/
CLI.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
from download import *
import os, sys
import json
if not os.path.exists("config.json"):
default_data = {
"CLI": True,
"date": 0,
"country": "cn",
"save_path": "pic",
"log_path": "bingbest.log"
}
with open("config.json", "w") as f:
json.dump(default_data, f)
with open("config.json", "r") as f:
config = json.load(f)
is_CLI = config["CLI"]
default_date = config["date"]
default_country = config["country"]
save_path = config["save_path"]
log_path = config["log_path"]
if is_CLI:
while 1:
date = input("Enter date: -1, 0, 1, 2, 3, 4, 5, 6. \n i means i days before today. \n Default: {date}\n".format(date = default_date)) or default_date
date = int(date)
if date in [-1, 0, 1, 2, 3, 4, 5, 6]:
break
while 1:
country = input("Enter country: ca, cn, fr, jp, nz, de, uk, us.\n Default: {country}\n".format(country = default_country)) or default_country
if country in ["ca", "cn", "fr", "jp", "nz", "de", "uk", "us"]:
break
config["date"] = date
config["country"] = country
else:
date = default_date
country = default_country
with open("config.json", "w") as f:
json.dump(config, f)
client = Downloader(date, country.lower())
client.get()
client.set()