You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
2.4 KiB
Python
51 lines
2.4 KiB
Python
import os,requests
|
|
import tcgcore
|
|
|
|
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)
|
|
index = 0 # adapted from https://stackoverflow.com/a/64536882
|
|
indexValidList = []
|
|
print("Deck type for " + card[:-2] + ":")
|
|
options = ["red","orange","yellow","green","blue","purple","brown","gray","special"]
|
|
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()
|