mirror of
https://github.com/ClaytonWWilson/Scraper-for-theTVDB.com.git
synced 2026-03-10 22:35:04 +00:00
Added some if statements
This commit is contained in:
7
login.py
7
login.py
@@ -4,11 +4,12 @@ from checks import *
|
|||||||
import time
|
import time
|
||||||
|
|
||||||
def login():
|
def login():
|
||||||
if (os.path.exists("login.json") == False):
|
if os.path.exists("login.json") == False:
|
||||||
obj = open("login.json")
|
obj = open("login.json")
|
||||||
# obj.write()
|
# obj.write()
|
||||||
obj.close()
|
obj.close()
|
||||||
|
|
||||||
|
if os.stat("login.json").st_size == 0:# Will only ask for credentials if the login file is empty
|
||||||
login = {
|
login = {
|
||||||
"API_KEY": "",
|
"API_KEY": "",
|
||||||
"USER_KEY": "",
|
"USER_KEY": "",
|
||||||
@@ -37,6 +38,7 @@ def login():
|
|||||||
tmp_token = getToken(LOGIN_DATA)
|
tmp_token = getToken(LOGIN_DATA)
|
||||||
if tmp_token is "":
|
if tmp_token is "":
|
||||||
print("Authentication failed. Please try again.")
|
print("Authentication failed. Please try again.")
|
||||||
|
else:
|
||||||
|
|
||||||
with open("login.json") as json_data:
|
with open("login.json") as json_data:
|
||||||
login["API_KEY"] = tmp_api_key
|
login["API_KEY"] = tmp_api_key
|
||||||
@@ -45,8 +47,5 @@ def login():
|
|||||||
obj = open("login.json", "w")
|
obj = open("login.json", "w")
|
||||||
obj.write(json.dumps(login))
|
obj.write(json.dumps(login))
|
||||||
obj.close()
|
obj.close()
|
||||||
|
|
||||||
def getCredentials():
|
|
||||||
print()
|
|
||||||
# TODO try to get token, if token fails, ask for login info again, if it passes save login details to login.py and save token with timestamp.
|
# TODO try to get token, if token fails, ask for login info again, if it passes save login details to login.py and save token with timestamp.
|
||||||
# TODO at startup, check token for validity and remove it if it is expired
|
# TODO at startup, check token for validity and remove it if it is expired
|
||||||
|
|||||||
Reference in New Issue
Block a user