Add initial card info structs and dataframe library

This commit is contained in:
2024-04-24 00:07:36 -04:00
parent 0f9ac3627f
commit 8007aca7ff
10 changed files with 151 additions and 5 deletions

View File

@@ -22,6 +22,7 @@ if not os.path.exists("cards"):
# Download all cards that don't have art
FULL_DL_ENDPOINT = "https://images.ygoprodeck.com/images/cards/{}.jpg"
SMALL_DL_ENDPOINT = "https://images.ygoprodeck.com/images/cards_small/{}.jpg"
INNER_ART_ENDPOINT = "https://images.ygoprodeck.com/images/cards_cropped/{}.jpg"
for card_json in card_data["data"]:
print(f"Downloading {card_json['name']}")
@@ -38,10 +39,13 @@ for card_json in card_data["data"]:
try:
full_img = requests.get(FULL_DL_ENDPOINT.format(image_to_download)).content
smol_img = requests.get(SMALL_DL_ENDPOINT.format(image_to_download)).content
inner_img = requests.get(INNER_ART_ENDPOINT.format(image_to_download)).content
with open(f"cards/{image_to_download}/full.jpg", "wb") as file:
file.write(full_img)
with open(f"cards/{image_to_download}/small.jpg", "wb") as file:
file.write(smol_img)
with open(f"cards/{image_to_download}/inner.jpg", "wb") as file:
file.write(inner_img)
except Exception as e:
shutil.rmtree('cards/{image_to_download}', ignore_errors=True)
print(f"ERROR: Failed to download {image_to_download}. {str(e)}")