Adding TODOs and tweaking a few lines

This commit is contained in:
ClaytonWWilson 2018-07-12 09:04:41 -04:00
parent e714ce4e3b
commit 841d567c78
3 changed files with 14 additions and 10 deletions

View File

@ -87,12 +87,12 @@ def clearFolders(): # TODO implement this
createFolder(folder) createFolder(folder)
print("") print("")
def createFolder(folder): def createFolder(folder): # TODO remove this
os.makedirs(folder) os.makedirs(folder)
def searchImages(idNum, keyType, authHeaders): # This is getting a list of file info for images in json format 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) response = requests.get(queryUrl, headers=authHeaders)
if (checkStatus(response, True)): if (checkStatus(response, True)):
return response return response
@ -128,7 +128,7 @@ def searchRemainder(imageType, saveNameList, idNum):#Finds any images missing fr
tryMissing(missingList, minNum, maxNum, idNum, imageType) tryMissing(missingList, minNum, maxNum, idNum, imageType)
def findMissing(numbers): # TODO test this def findMissing(numbers):
start, end = numbers[0], numbers[-1] start, end = numbers[0], numbers[-1]
return sorted(set(range(start, end + 1)).difference(numbers)) return sorted(set(range(start, end + 1)).difference(numbers))
@ -148,7 +148,7 @@ def tryMissing(missingNums, minNum, maxNum, idNum, imageType):
response = requests.get(dlUrl) response = requests.get(dlUrl)
# print(response.status_code) # print(response.status_code)
if (checkStatus(response, True) == True): # TODO there is an error occurring here when checking fanart 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 = open(path, "wb")
obj.write(response.content) obj.write(response.content)
obj.close() obj.close()

View File

@ -9,6 +9,8 @@ from actions import refreshToken
from actions import update from actions import update
from search import search from search import search
# TODO fix naming convention for all variables and functions
def user_choice(): def user_choice():
return input("> ").lower().strip() return input("> ").lower().strip()
@ -36,17 +38,17 @@ while True:
clearFolders() clearFolders()
wait() wait()
elif choice == "3": # TODO if already logged in, ask 'are you sure?' 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() clearLogin()
login() login()
wait() wait()
elif choice == "4": elif choice == "4": # TODO need to perform this option automatically
clear_screen() clear_screen()
refreshToken() refreshToken()
wait() wait()
elif choice == "5": elif choice == "5":
print("install requirements") print("install requirements not implemented yet")
break wait()
elif choice == "6": elif choice == "6":
update() update()
wait() wait()

View File

@ -9,6 +9,7 @@ import dateutil
from actions import clearFolders from actions import clearFolders
from actions import clear_screen from actions import clear_screen
from actions import downloadImages from actions import downloadImages
from actions import refreshToken
from actions import searchImages from actions import searchImages
from checks import checkTimestamp from checks import checkTimestamp
from checks import checkStatus from checks import checkStatus
@ -26,8 +27,9 @@ def search():
saveTime = dateutil.parser.parse(login["TIMESTAMP"]) saveTime = dateutil.parser.parse(login["TIMESTAMP"])
curTime = datetime.datetime.now().replace(tzinfo=None) # TODO use UTC time? curTime = datetime.datetime.now().replace(tzinfo=None) # TODO use UTC time?
if checkTimestamp(saveTime, curTime) == False: if checkTimestamp(saveTime, curTime) == False:
print("Your token has expired. Get a new one by choosing Refresh Token.") # print("Your token has expired. Get a new one by choosing Refresh Token.")
return None # return None
refreshToken()
except Exception as ex: except Exception as ex:
print(ex) print(ex)
print("There was an error checking your login. Try logging in again with 'Login/Change login'.") print("There was an error checking your login. Try logging in again with 'Login/Change login'.")