Enable automatic download of card images

master
trémeur 2 months ago
parent 457cf368b7
commit 18422d8b4f

@ -0,0 +1,52 @@
import os,requests
import tcgcore
def getimg():
for card in tcgcore.ownedcards():
if card[0:4] == "sig_":
if os.path.exists("build/decks/sigs/" + card[4:] + ".gif"):
pass
else:
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()

@ -1,26 +0,0 @@
#!/usr/bin/env bash
here=$(basename "$PWD")
wget https://colors-tcg.eu/cards/"$here"00.gif -O 00.gif
wget https://colors-tcg.eu/cards/"$here"01.gif -O 01.gif
wget https://colors-tcg.eu/cards/"$here"02.gif -O 02.gif
wget https://colors-tcg.eu/cards/"$here"03.gif -O 03.gif
wget https://colors-tcg.eu/cards/"$here"04.gif -O 04.gif
wget https://colors-tcg.eu/cards/"$here"05.gif -O 05.gif
wget https://colors-tcg.eu/cards/"$here"06.gif -O 06.gif
wget https://colors-tcg.eu/cards/"$here"07.gif -O 07.gif
wget https://colors-tcg.eu/cards/"$here"08.gif -O 08.gif
wget https://colors-tcg.eu/cards/"$here"09.gif -O 09.gif
wget https://colors-tcg.eu/cards/"$here"10.gif -O 10.gif
wget https://colors-tcg.eu/cards/"$here"11.gif -O 11.gif
wget https://colors-tcg.eu/cards/"$here"11.gif -O 11.gif
wget https://colors-tcg.eu/cards/"$here"12.gif -O 12.gif
wget https://colors-tcg.eu/cards/"$here"13.gif -O 13.gif
wget https://colors-tcg.eu/cards/"$here"14.gif -O 14.gif
wget https://colors-tcg.eu/cards/"$here"15.gif -O 15.gif
wget https://colors-tcg.eu/cards/"$here"16.gif -O 16.gif
wget https://colors-tcg.eu/cards/"$here"17.gif -O 17.gif
wget https://colors-tcg.eu/cards/"$here"18.gif -O 18.gif
wget https://colors-tcg.eu/cards/"$here"19.gif -O 19.gif
wget https://colors-tcg.eu/cards/"$here"20.gif -O 20.gif

@ -1,5 +1,6 @@
import indexgen,collectinggen,ownedgen,wantedgen,loggen,levelsgen
import download,indexgen,collectinggen,ownedgen,wantedgen,loggen,levelsgen
download.getimg()
indexgen.indexgen()
collectinggen.collectinggen()
ownedgen.ownedgen()

Loading…
Cancel
Save