mirror of
https://github.com/SinTan1729/TvTimeToTrakt.git
synced 2025-04-19 09:30:01 -05:00
Prompt config if it doesn't exist
This commit is contained in:
parent
5b31823c27
commit
01c683f78a
1 changed files with 23 additions and 20 deletions
|
@ -58,15 +58,24 @@ def isAuthenticated():
|
|||
|
||||
|
||||
def getConfiguration() -> Config:
|
||||
with open("config.json") as f:
|
||||
data = json.load(f)
|
||||
try:
|
||||
with open("config.json") as f:
|
||||
data = json.load(f)
|
||||
|
||||
return Config(
|
||||
data["TRAKT_USERNAME"],
|
||||
data["CLIENT_ID"],
|
||||
data["CLIENT_SECRET"],
|
||||
data["GDPR_WORKSPACE_PATH"],
|
||||
)
|
||||
return Config(
|
||||
data["TRAKT_USERNAME"],
|
||||
data["CLIENT_ID"],
|
||||
data["CLIENT_SECRET"],
|
||||
data["GDPR_WORKSPACE_PATH"],
|
||||
)
|
||||
except FileNotFoundError:
|
||||
logging.info("config.json not found prompting user for input")
|
||||
return Config(
|
||||
input("Enter your Trakt.tv username: "),
|
||||
input("Enter you Client id: "),
|
||||
input("Enter your Client secret: "),
|
||||
input("Enter your GDPR workspace path: ")
|
||||
)
|
||||
|
||||
|
||||
config = getConfiguration()
|
||||
|
@ -817,18 +826,12 @@ def start():
|
|||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Check that the user has created the config file
|
||||
if os.path.exists("config.json"):
|
||||
# Check that the user has provided the GDPR path
|
||||
if os.path.isdir(config.gdpr_workspace_path):
|
||||
start()
|
||||
else:
|
||||
logging.error(
|
||||
"Oops! The TV Time GDPR folder '"
|
||||
+ config.gdpr_workspace_path
|
||||
+ "' does not exist on the local system. Please check it, and try again."
|
||||
)
|
||||
# Check that the user has provided the GDPR path
|
||||
if os.path.isdir(config.gdpr_workspace_path):
|
||||
start()
|
||||
else:
|
||||
logging.error(
|
||||
"The 'config.json' file cannot be found - have you created it yet?"
|
||||
"Oops! The TV Time GDPR folder '"
|
||||
+ config.gdpr_workspace_path
|
||||
+ "' does not exist on the local system. Please check it, and try again."
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue