1
0
Fork 0
mirror of https://github.com/ldericher/fftcgtool synced 2025-01-15 06:53:00 +00:00

requests unification

This commit is contained in:
Jörn-Michael Miehe 2021-09-06 04:41:49 +02:00
parent 52651edca8
commit a14eb56c33
2 changed files with 5 additions and 5 deletions

View file

@ -31,7 +31,7 @@ class ImageLoader:
pass
# if rejected, substitute the english version
if not res.status_code == 200:
if not res.ok:
logger.warning(f"falling back to english version of {url}")
return cls._load_inner((base_url, code, FALLBACK_LANGUAGE.image_suffix))

View file

@ -66,9 +66,9 @@ class TTSDeck(Cards):
deck_id = match.groups()[3]
# api request
req = requests.get(TTSDeck.__FFDECKS_API_URL, params={"deck_id": deck_id})
res = requests.get(TTSDeck.__FFDECKS_API_URL, params={"deck_id": deck_id})
if req.status_code != 200:
if not res.ok:
logger.error("Invalid Deck ID for FFDecks API!")
return cls([], "", "", True)
@ -80,7 +80,7 @@ class TTSDeck(Cards):
"type": card["card"]["type"],
"cost": int(card["card"]["cost"]),
"count": int(card["quantity"]),
} for card in req.json()["cards"]]
} for card in res.json()["cards"]]
# sort cards by type, then by cost
def by_type(data: dict[str, str | int]) -> int:
@ -125,7 +125,7 @@ class TTSDeck(Cards):
]
# general metadata
name = f"{req.json()['name']}"
name = f"{res.json()['name']}"
description = deck_id
# create deck object