mirror of
https://github.com/ClaytonWWilson/Scraper-for-theTVDB.com.git
synced 2025-12-15 17:28:46 +00:00
Fixed some imports
This commit is contained in:
parent
64239e36ab
commit
da958cce55
11
actions.py
11
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)
|
||||
|
||||
@ -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"
|
||||
|
||||
20
search.py
20
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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user