From 841d567c783fd293b9a073b56a1f08f54ff9e3b8 Mon Sep 17 00:00:00 2001 From: ClaytonWWilson Date: Thu, 12 Jul 2018 09:04:41 -0400 Subject: [PATCH] Adding TODOs and tweaking a few lines --- actions.py | 8 ++++---- launcher.py | 10 ++++++---- search.py | 6 ++++-- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/actions.py b/actions.py index 9a15ddd..51409f5 100644 --- a/actions.py +++ b/actions.py @@ -87,12 +87,12 @@ def clearFolders(): # TODO implement this createFolder(folder) print("") -def createFolder(folder): +def createFolder(folder): # TODO remove this os.makedirs(folder) def searchImages(idNum, keyType, authHeaders): # This is getting a list of file info for images in json format - queryUrl = "https://api.thetvdb.com/series/" + str(idNum) + "/images/query" + keyType + queryUrl = "https://api.thetvdb.com/series/" + str(idNum) + "/images/query" + keyType # TODO change this to string formatting response = requests.get(queryUrl, headers=authHeaders) if (checkStatus(response, True)): return response @@ -128,7 +128,7 @@ def searchRemainder(imageType, saveNameList, idNum):#Finds any images missing fr tryMissing(missingList, minNum, maxNum, idNum, imageType) -def findMissing(numbers): # TODO test this +def findMissing(numbers): start, end = numbers[0], numbers[-1] return sorted(set(range(start, end + 1)).difference(numbers)) @@ -148,7 +148,7 @@ def tryMissing(missingNums, minNum, maxNum, idNum, imageType): response = requests.get(dlUrl) # print(response.status_code) if (checkStatus(response, True) == True): # TODO there is an error occurring here when checking fanart - path = os.path.join(imageType + "\\" + str(idNum) + "-" + str(num) + ".jpg") + path = os.path.join(imageType + "\\" + str(idNum) + "-" + str(num) + ".jpg") # TODO string formatting obj = open(path, "wb") obj.write(response.content) obj.close() diff --git a/launcher.py b/launcher.py index 441d2e4..faf2150 100644 --- a/launcher.py +++ b/launcher.py @@ -9,6 +9,8 @@ from actions import refreshToken from actions import update from search import search +# TODO fix naming convention for all variables and functions + def user_choice(): return input("> ").lower().strip() @@ -36,17 +38,17 @@ while True: clearFolders() wait() elif choice == "3": # TODO if already logged in, ask 'are you sure?' - clear_screen() + clear_screen() # TODO wait to clear login and add a ctrl+c option to cancel clearLogin() login() wait() - elif choice == "4": + elif choice == "4": # TODO need to perform this option automatically clear_screen() refreshToken() wait() elif choice == "5": - print("install requirements") - break + print("install requirements not implemented yet") + wait() elif choice == "6": update() wait() diff --git a/search.py b/search.py index 48e6ab7..25c8bc8 100644 --- a/search.py +++ b/search.py @@ -9,6 +9,7 @@ import dateutil from actions import clearFolders from actions import clear_screen from actions import downloadImages +from actions import refreshToken from actions import searchImages from checks import checkTimestamp from checks import checkStatus @@ -26,8 +27,9 @@ def search(): saveTime = dateutil.parser.parse(login["TIMESTAMP"]) curTime = datetime.datetime.now().replace(tzinfo=None) # TODO use UTC time? if checkTimestamp(saveTime, curTime) == False: - print("Your token has expired. Get a new one by choosing Refresh Token.") - return None + # print("Your token has expired. Get a new one by choosing Refresh Token.") + # return None + refreshToken() except Exception as ex: print(ex) print("There was an error checking your login. Try logging in again with 'Login/Change login'.")