-
Notifications
You must be signed in to change notification settings - Fork 0
/
packscraper.py
48 lines (39 loc) · 1.31 KB
/
packscraper.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import cardscraper
import json
import sys
# Creates card json files for everything in the list
# Usage: python packscraper.py [pack file] [outputfolder] [pack name]
def main():
cardlist = sys.argv[1]
outpath = sys.argv[2]
packname = sys.argv[3]
cardfile = open(cardlist, 'r',encoding="UTF-8")
rarity = "NA"
for line in cardfile:
# Check rarity
line = line.rstrip()
if line == "UR CARDS":
rarity = "UR"
elif line == "SR CARDS":
rarity = "SR"
elif line == "R CARDS":
rarity = "R"
elif line == "N CARDS":
rarity = "N"
elif len(line) > 0:
srcs = [packname]
currentCard = None
filename = None
print("Exporting {0} [{1}]".format(line, rarity))
try:
currentCard = cardscraper.getCard(line, srcs, rarity)
except cardscraper.CardNotFoundError:
currentCard = cardscraper.Card()
currentCard.name = line
currentCard.sources = srcs
currentCard.rarity = rarity
filename = "[NOT FOUND ON YGOHUB] " + line + ".json"
finally:
cardscraper.exportCard(currentCard,outpath,filename)
if __name__ == "__main__":
main()