mirror of
https://github.com/ClaytonWWilson/Scraper-for-theTVDB.com.git
synced 2025-12-18 10:18:48 +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 shutil
|
||||||
import json
|
import json
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
|
import requests
|
||||||
import dateutil
|
import dateutil
|
||||||
import os
|
|
||||||
import subprocess
|
|
||||||
from checks import checkTimestamp
|
from checks import checkTimestamp
|
||||||
from checks import getToken
|
from checks import getToken
|
||||||
|
|
||||||
@ -78,7 +80,7 @@ def clearFolders(): # TODO implement this
|
|||||||
os.remove(delPath)
|
os.remove(delPath)
|
||||||
print(folder + " cleared\n")
|
print(folder + " cleared\n")
|
||||||
else:
|
else:
|
||||||
print(folder + " is already empty")
|
print("'" + folder + "'" + " is already empty")
|
||||||
else:
|
else:
|
||||||
createFolder(folder)
|
createFolder(folder)
|
||||||
print("")
|
print("")
|
||||||
@ -96,10 +98,7 @@ def searchImages(idNum, keyType, authHeaders): # This is getting a list of file
|
|||||||
quit()
|
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
|
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
|
clearFolders()
|
||||||
print("\nClearing /%s/" % imageType)
|
|
||||||
shutil.rmtree(imageType)
|
|
||||||
os.makedirs(imageType)
|
|
||||||
|
|
||||||
parsed_respObj = json.loads(respObj.content)
|
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
|
fileName = parsed_respObj["data"][counter]["fileName"] # TODO the download method should start here, move everything else up to downloadImages
|
||||||
counter = counter + 1
|
counter = counter + 1
|
||||||
|
|
||||||
slashIndex = fileName.rfind("/")
|
slashIndex = fileName.rfind("/") # This is used to slice the url at the beginning of the filename
|
||||||
saveName = fileName[slashIndex + 1:]
|
saveName = fileName[slashIndex + 1:] # For example 'https://thetvdb.com/banners/fanart/original/32451-3.jpg' --> '32451.jpg'
|
||||||
|
|
||||||
saveNameList.append(saveName)
|
saveNameList.append(saveName)
|
||||||
|
|
||||||
print("Downloading... " + fileName)
|
print("Downloading... " + fileName)
|
||||||
|
|||||||
@ -1,7 +1,9 @@
|
|||||||
import os # TODO: change the order of all import statements to 1. standard library
|
import os
|
||||||
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
|
from login import login
|
||||||
|
from actions import wait
|
||||||
from actions import clear_screen
|
from actions import clear_screen
|
||||||
|
from actions import clearFolders
|
||||||
from actions import clearLogin
|
from actions import clearLogin
|
||||||
from actions import refreshToken
|
from actions import refreshToken
|
||||||
from actions import update
|
from actions import update
|
||||||
|
|||||||
9
login.py
9
login.py
@ -1,10 +1,13 @@
|
|||||||
import json
|
import json
|
||||||
import os.path
|
import os.path
|
||||||
from checks import *
|
|
||||||
from actions import *
|
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
import dateutil.parser
|
import dateutil.parser
|
||||||
|
|
||||||
|
from actions import refreshToken
|
||||||
|
from checks import getToken
|
||||||
|
|
||||||
|
|
||||||
def login():
|
def login():
|
||||||
if os.path.exists("login.json") == False:
|
if os.path.exists("login.json") == False:
|
||||||
obj = open("login.json", "w")
|
obj = open("login.json", "w")
|
||||||
@ -24,7 +27,7 @@ def login():
|
|||||||
tmp_user_key = ""
|
tmp_user_key = ""
|
||||||
tmp_user_name = ""
|
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 "":
|
while tmp_api_key is "":
|
||||||
tmp_api_key = input("Enter your api key: ")
|
tmp_api_key = input("Enter your api key: ")
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user