From da958cce55a417c4284a6c61922f67989f0cd2dc Mon Sep 17 00:00:00 2001 From: Clayton Wilson Date: Mon, 6 Nov 2017 08:19:52 -0500 Subject: [PATCH] Fixed some imports --- actions.py | 11 +++++++---- launcher.py | 4 ---- search.py | 20 +++++++++----------- 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/actions.py b/actions.py index 9c54458..54fee0a 100644 --- a/actions.py +++ b/actions.py @@ -8,6 +8,9 @@ import subprocess from checks import checkTimestamp from checks import getToken +def wait(): + input("Press enter to continue.") + def clear_screen(): IS_WINDOWS = os.name == "nt" if IS_WINDOWS: @@ -21,7 +24,7 @@ def refreshToken(): with open("login.json") as json_data: login = json.load(json_data) 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? json_data.close() LOGIN_DATA = { @@ -69,7 +72,7 @@ def clearFolders(): # TODO implement this if os.path.exists(folder): imageList = os.listdir(folder) if len(imageList) != 0: - for x in imageList: # TODO check if folder is empty + for x in imageList: # TODO check if folder is empty print("Deleting " + x) delPath = os.path.join(folder + "\\" + x) os.remove(delPath) @@ -108,7 +111,7 @@ def download(imageType, parsed_respObj): counter = 0 saveNameList = [] for imageObj in parsed_respObj["data"]: - fileName = parsed_respObj["data"][counter]["fileName"]#TODO the download method should start here, move everything else up to downloadImages + fileName = parsed_respObj["data"][counter]["fileName"] # TODO the download method should start here, move everything else up to downloadImages counter = counter + 1 slashIndex = fileName.rfind("/") @@ -118,7 +121,7 @@ def download(imageType, parsed_respObj): print("Downloading... " + fileName) dlUrl = "https://www.thetvdb.com/banners/" + fileName - response = requests.get(dlUrl)# TODO getting errors when checking 'new game'. Check to see if those images actually exist + response = requests.get(dlUrl) # TODO getting errors when checking 'new game'. Check to see if those images actually exist if (checkStatus(response, True)): path = os.path.join(imageType + "\\", saveName) diff --git a/launcher.py b/launcher.py index aac7eb4..d95dec2 100644 --- a/launcher.py +++ b/launcher.py @@ -6,10 +6,6 @@ from search import search def user_choice(): return input("> ").lower().strip() -def wait(): - input("Press enter to continue.") - - while True: clear_screen() print("=============================\n" diff --git a/search.py b/search.py index 0f27ad3..8582ff0 100644 --- a/search.py +++ b/search.py @@ -2,9 +2,9 @@ import requests import json import urllib.parse import os.path -from launcher import wait +from actions import wait + -# import login def searchRemainder(imageType, saveNameList, idNum):#Finds any images missing from the api call in getImages numbers = [] @@ -73,7 +73,7 @@ def search(): if checkTimestamp(saveTime, curTime) == False: print("Your token has expired. Get a new one by choosing Refresh Token.") return None - else: # All login checks pass and search starts + else: # All login checks pass and search starts # TODO move everything below out of the try except FAN_KEY_TYPE = "?keyType=fanart" # These are used in the search strings POS_KEY_TYPE = "?keyType=poster" BAN_KEY_TYPE = "?keyType=series" @@ -131,13 +131,11 @@ def search(): fanart = searchImages(idNum, FAN_KEY_TYPE, authHeaders) # for banners, fanart, and posters poster = searchImages(idNum, POS_KEY_TYPE, authHeaders) banner = searchImages(idNum, BAN_KEY_TYPE, authHeaders) + + downloadImages("fanart", fanart, idNum) # TODO find a better way to pass these variables. Constructor? + downloadImages("poster", poster, idNum) + downloadImages("banner", banner, idNum) + return None except: print("There was an error checking your login. Try logging in again with 'Login/Change login'.") - break - - -downloadImages("fanart", fanart, idNum) # TODO find a better way to pass this variable - -downloadImages("poster", poster, idNum) - -downloadImages("banner", banner, idNum) + return None