mirror of
https://github.com/ClaytonWWilson/Scraper-for-theTVDB.com.git
synced 2025-12-15 17:28:46 +00:00
Refactored imports
This commit is contained in:
parent
ec12a6da1e
commit
c129cbd417
20
actions.py
20
actions.py
@ -1,10 +1,12 @@
|
||||
import requests
|
||||
import os
|
||||
import subprocess
|
||||
import shutil
|
||||
import json
|
||||
import datetime
|
||||
|
||||
import requests
|
||||
import dateutil
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
from checks import checkTimestamp
|
||||
from checks import getToken
|
||||
|
||||
@ -78,7 +80,7 @@ def clearFolders(): # TODO implement this
|
||||
os.remove(delPath)
|
||||
print(folder + " cleared\n")
|
||||
else:
|
||||
print(folder + " is already empty")
|
||||
print("'" + folder + "'" + " is already empty")
|
||||
else:
|
||||
createFolder(folder)
|
||||
print("")
|
||||
@ -96,10 +98,7 @@ def searchImages(idNum, keyType, authHeaders): # This is getting a list of file
|
||||
quit()
|
||||
|
||||
def downloadImages(imageType, respObj, idNum): # TODO some images arent grabbed through the api. save the image number and make a try catch to get any missing images
|
||||
if (os.path.exists(imageType)): # TODO add try catch here
|
||||
print("\nClearing /%s/" % imageType)
|
||||
shutil.rmtree(imageType)
|
||||
os.makedirs(imageType)
|
||||
clearFolders()
|
||||
|
||||
parsed_respObj = json.loads(respObj.content)
|
||||
|
||||
@ -114,9 +113,8 @@ def download(imageType, parsed_respObj):
|
||||
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("/")
|
||||
saveName = fileName[slashIndex + 1:]
|
||||
|
||||
slashIndex = fileName.rfind("/") # This is used to slice the url at the beginning of the filename
|
||||
saveName = fileName[slashIndex + 1:] # For example 'https://thetvdb.com/banners/fanart/original/32451-3.jpg' --> '32451.jpg'
|
||||
saveNameList.append(saveName)
|
||||
|
||||
print("Downloading... " + fileName)
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
import os # TODO: change the order of all import statements to 1. standard library
|
||||
from login import login # TODO: 2. related 3rd party
|
||||
from actions import wait # TODO: 3. local application. with blank lines between and remove wilcard symbols
|
||||
import os
|
||||
|
||||
from login import login
|
||||
from actions import wait
|
||||
from actions import clear_screen
|
||||
from actions import clearFolders
|
||||
from actions import clearLogin
|
||||
from actions import refreshToken
|
||||
from actions import update
|
||||
|
||||
9
login.py
9
login.py
@ -1,10 +1,13 @@
|
||||
import json
|
||||
import os.path
|
||||
from checks import *
|
||||
from actions import *
|
||||
import datetime
|
||||
|
||||
import dateutil.parser
|
||||
|
||||
from actions import refreshToken
|
||||
from checks import getToken
|
||||
|
||||
|
||||
def login():
|
||||
if os.path.exists("login.json") == False:
|
||||
obj = open("login.json", "w")
|
||||
@ -24,7 +27,7 @@ def login():
|
||||
tmp_user_key = ""
|
||||
tmp_user_name = ""
|
||||
|
||||
print("You can find your user key & request an API key while logged in at:\nhttps://www.thetvdb.com/?tab=userinfo")
|
||||
print("You can find your user key & request an API key while logged in at:\nhttps://www.thetvdb.com/?tab=userinfo\n")
|
||||
|
||||
while tmp_api_key is "":
|
||||
tmp_api_key = input("Enter your api key: ")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user