from scryfall_image_crop_downloader import *

# Scan every card in a set
page = 1
cardnames = []
cardnumbers = []
totalcards = 0
more = True
expansion = input("Type the three-character set code for the set you want to scan: ")

# ensure we get every card from the set (multiple search result pages)
while more:
	time.sleep(0.1)
	cardset = scrython.cards.Search(q="set:" + expansion, page=page)
	more = cardset.has_more()
	totalcards = cardset.total_cards()
	cardnames = cardnames + [cardset.data()[x]["name"] for x in range(len(cardset.data()))]
	cardnumbers = cardnumbers + [cardset.data()[x]["collector_number"] for x in range(len(cardset.data()))]
	page += 1

print("Collected search results for set: " + expansion)
print("Total number of cards:")
print(totalcards)

for cardname in sorted(set(cardnames)):
	process_card(cardname, expansion=expansion)