|
|
|
import os,requests
|
|
|
|
import tcgcore,thetypes
|
|
|
|
|
|
|
|
def getimg():
|
|
|
|
for card in tcgcore.ownedcards():
|
|
|
|
if card[0:4] == "sig_":
|
|
|
|
if not os.path.exists("build/decks/sigs/" + card[4:] + ".gif"):
|
|
|
|
r = requests.get("https://colors-tcg.eu/cards/" + card + ".gif")
|
|
|
|
open("build/decks/sigs/" + card[4:] + ".gif","wb").write(r.content)
|
|
|
|
else:
|
|
|
|
thepath = "build/decks/" + card[:-2]
|
|
|
|
if not os.path.isdir(thepath):
|
|
|
|
os.mkdir(thepath)
|
|
|
|
if card[:-2] in thetypes.typedict:
|
|
|
|
decktype = thetypes.typedict[card[:-2]]
|
|
|
|
else:
|
|
|
|
index = 0 # adapted from https://stackoverflow.com/a/64536882
|
|
|
|
indexValidList = []
|
|
|
|
print("Deck type for " + card[:-2] + ":")
|
|
|
|
options = tcgcore.typelist
|
|
|
|
for optionName in options:
|
|
|
|
index = index + 1
|
|
|
|
indexValidList.extend([options.index(optionName)])
|
|
|
|
print(str(index) + ") " + optionName)
|
|
|
|
inputValid = False
|
|
|
|
while not inputValid:
|
|
|
|
inputRaw = input("Type: ")
|
|
|
|
inputNo = int(inputRaw) - 1
|
|
|
|
if inputNo > -1 and inputNo < len(indexValidList):
|
|
|
|
selected = indexValidList[inputNo]
|
|
|
|
inputValid = True
|
|
|
|
break
|
|
|
|
else:
|
|
|
|
print("Select a number from the list")
|
|
|
|
decktype = options[selected]
|
|
|
|
typefile = open(thepath + "/type","w")
|
|
|
|
typefile.write(decktype)
|
|
|
|
typefile.close()
|
|
|
|
print("Downloading " + card[:-2])
|
|
|
|
number = 0
|
|
|
|
while number < 21:
|
|
|
|
if number < 10:
|
|
|
|
r = requests.get("https://colors-tcg.eu/cards/" + card[:-2] + "0" + str(number) + ".gif")
|
|
|
|
open(thepath + "/0" + str(number) + ".gif","wb").write(r.content)
|
|
|
|
else:
|
|
|
|
r = requests.get("https://colors-tcg.eu/cards/" + card[:-2] + str(number) + ".gif")
|
|
|
|
open(thepath + "/" + str(number) + ".gif","wb").write(r.content)
|
|
|
|
number += 1
|
|
|
|
master = requests.get("https://colors-tcg.eu/cards/" + card[:-2] + "master.gif")
|
|
|
|
open(thepath + "/master.gif","wb").write(master.content)
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
getimg()
|