mirror of
https://github.com/ldericher/fftcgtool
synced 2025-01-15 15:02:59 +00:00
requests unification
This commit is contained in:
parent
52651edca8
commit
a14eb56c33
2 changed files with 5 additions and 5 deletions
|
@ -31,7 +31,7 @@ class ImageLoader:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# if rejected, substitute the english version
|
# 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}")
|
logger.warning(f"falling back to english version of {url}")
|
||||||
return cls._load_inner((base_url, code, FALLBACK_LANGUAGE.image_suffix))
|
return cls._load_inner((base_url, code, FALLBACK_LANGUAGE.image_suffix))
|
||||||
|
|
||||||
|
|
|
@ -66,9 +66,9 @@ class TTSDeck(Cards):
|
||||||
deck_id = match.groups()[3]
|
deck_id = match.groups()[3]
|
||||||
|
|
||||||
# api request
|
# 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!")
|
logger.error("Invalid Deck ID for FFDecks API!")
|
||||||
return cls([], "", "", True)
|
return cls([], "", "", True)
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ class TTSDeck(Cards):
|
||||||
"type": card["card"]["type"],
|
"type": card["card"]["type"],
|
||||||
"cost": int(card["card"]["cost"]),
|
"cost": int(card["card"]["cost"]),
|
||||||
"count": int(card["quantity"]),
|
"count": int(card["quantity"]),
|
||||||
} for card in req.json()["cards"]]
|
} for card in res.json()["cards"]]
|
||||||
|
|
||||||
# sort cards by type, then by cost
|
# sort cards by type, then by cost
|
||||||
def by_type(data: dict[str, str | int]) -> int:
|
def by_type(data: dict[str, str | int]) -> int:
|
||||||
|
@ -125,7 +125,7 @@ class TTSDeck(Cards):
|
||||||
]
|
]
|
||||||
|
|
||||||
# general metadata
|
# general metadata
|
||||||
name = f"{req.json()['name']}"
|
name = f"{res.json()['name']}"
|
||||||
description = deck_id
|
description = deck_id
|
||||||
|
|
||||||
# create deck object
|
# create deck object
|
||||||
|
|
Loading…
Reference in a new issue