mirror of
https://github.com/ldericher/fftcgtool
synced 2025-01-15 15:02:59 +00:00
Some v2 work
This commit is contained in:
parent
f14dc6c21d
commit
e44892878f
5 changed files with 81 additions and 25 deletions
1
Pipfile
1
Pipfile
|
@ -7,6 +7,7 @@ verify_ssl = true
|
|||
|
||||
[packages]
|
||||
requests = "*"
|
||||
pillow = "*"
|
||||
|
||||
[requires]
|
||||
python_version = "3.6"
|
||||
|
|
47
Pipfile.lock
generated
47
Pipfile.lock
generated
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"_meta": {
|
||||
"hash": {
|
||||
"sha256": "8739d581819011fea34feca8cc077062d6bdfee39c7b37a8ed48c5e0a8b14837"
|
||||
"sha256": "f0fedb7b3061de81b354fc95cf267f1b59bce83abd94a44f259ebf7f1e500930"
|
||||
},
|
||||
"pipfile-spec": 6,
|
||||
"requires": {
|
||||
|
@ -39,6 +39,51 @@
|
|||
"markers": "python_version >= '3'",
|
||||
"version": "==3.2"
|
||||
},
|
||||
"pillow": {
|
||||
"hashes": [
|
||||
"sha256:0b2efa07f69dc395d95bb9ef3299f4ca29bcb2157dc615bae0b42c3c20668ffc",
|
||||
"sha256:114f816e4f73f9ec06997b2fde81a92cbf0777c9e8f462005550eed6bae57e63",
|
||||
"sha256:147bd9e71fb9dcf08357b4d530b5167941e222a6fd21f869c7911bac40b9994d",
|
||||
"sha256:15a2808e269a1cf2131930183dcc0419bc77bb73eb54285dde2706ac9939fa8e",
|
||||
"sha256:196560dba4da7a72c5e7085fccc5938ab4075fd37fe8b5468869724109812edd",
|
||||
"sha256:1c03e24be975e2afe70dfc5da6f187eea0b49a68bb2b69db0f30a61b7031cee4",
|
||||
"sha256:1fd5066cd343b5db88c048d971994e56b296868766e461b82fa4e22498f34d77",
|
||||
"sha256:29c9569049d04aaacd690573a0398dbd8e0bf0255684fee512b413c2142ab723",
|
||||
"sha256:2b6dfa068a8b6137da34a4936f5a816aba0ecc967af2feeb32c4393ddd671cba",
|
||||
"sha256:2cac53839bfc5cece8fdbe7f084d5e3ee61e1303cccc86511d351adcb9e2c792",
|
||||
"sha256:2ee77c14a0299d0541d26f3d8500bb57e081233e3fa915fa35abd02c51fa7fae",
|
||||
"sha256:37730f6e68bdc6a3f02d2079c34c532330d206429f3cee651aab6b66839a9f0e",
|
||||
"sha256:3f08bd8d785204149b5b33e3b5f0ebbfe2190ea58d1a051c578e29e39bfd2367",
|
||||
"sha256:479ab11cbd69612acefa8286481f65c5dece2002ffaa4f9db62682379ca3bb77",
|
||||
"sha256:4bc3c7ef940eeb200ca65bd83005eb3aae8083d47e8fcbf5f0943baa50726856",
|
||||
"sha256:660a87085925c61a0dcc80efb967512ac34dbb256ff7dd2b9b4ee8dbdab58cf4",
|
||||
"sha256:67b3666b544b953a2777cb3f5a922e991be73ab32635666ee72e05876b8a92de",
|
||||
"sha256:70af7d222df0ff81a2da601fab42decb009dc721545ed78549cb96e3a1c5f0c8",
|
||||
"sha256:75e09042a3b39e0ea61ce37e941221313d51a9c26b8e54e12b3ececccb71718a",
|
||||
"sha256:8960a8a9f4598974e4c2aeb1bff9bdd5db03ee65fd1fce8adf3223721aa2a636",
|
||||
"sha256:9364c81b252d8348e9cc0cb63e856b8f7c1b340caba6ee7a7a65c968312f7dab",
|
||||
"sha256:969cc558cca859cadf24f890fc009e1bce7d7d0386ba7c0478641a60199adf79",
|
||||
"sha256:9a211b663cf2314edbdb4cf897beeb5c9ee3810d1d53f0e423f06d6ebbf9cd5d",
|
||||
"sha256:a17ca41f45cf78c2216ebfab03add7cc350c305c38ff34ef4eef66b7d76c5229",
|
||||
"sha256:a2f381932dca2cf775811a008aa3027671ace723b7a38838045b1aee8669fdcf",
|
||||
"sha256:a4eef1ff2d62676deabf076f963eda4da34b51bc0517c70239fafed1d5b51500",
|
||||
"sha256:c088a000dfdd88c184cc7271bfac8c5b82d9efa8637cd2b68183771e3cf56f04",
|
||||
"sha256:c0e0550a404c69aab1e04ae89cca3e2a042b56ab043f7f729d984bf73ed2a093",
|
||||
"sha256:c11003197f908878164f0e6da15fce22373ac3fc320cda8c9d16e6bba105b844",
|
||||
"sha256:c2a5ff58751670292b406b9f06e07ed1446a4b13ffced6b6cab75b857485cbc8",
|
||||
"sha256:c35d09db702f4185ba22bb33ef1751ad49c266534339a5cebeb5159d364f6f82",
|
||||
"sha256:c379425c2707078dfb6bfad2430728831d399dc95a7deeb92015eb4c92345eaf",
|
||||
"sha256:cc866706d56bd3a7dbf8bac8660c6f6462f2f2b8a49add2ba617bc0c54473d83",
|
||||
"sha256:d0da39795049a9afcaadec532e7b669b5ebbb2a9134576ebcc15dd5bdae33cc0",
|
||||
"sha256:f156d6ecfc747ee111c167f8faf5f4953761b5e66e91a4e6767e548d0f80129c",
|
||||
"sha256:f4ebde71785f8bceb39dcd1e7f06bcc5d5c3cf48b9f69ab52636309387b097c8",
|
||||
"sha256:fc214a6b75d2e0ea7745488da7da3c381f41790812988c7a92345978414fad37",
|
||||
"sha256:fd7eef578f5b2200d066db1b50c4aa66410786201669fb76d5238b007918fb24",
|
||||
"sha256:ff04c373477723430dce2e9d024c708a047d44cf17166bf16e604b379bf0ca14"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==8.3.1"
|
||||
},
|
||||
"requests": {
|
||||
"hashes": [
|
||||
"sha256:6c1246513ecd5ecd4528a0906f910e8f0f9c6b8ec72030dc9fd154dc1a6efd24",
|
||||
|
|
|
@ -3,26 +3,35 @@ import re
|
|||
|
||||
class Card:
|
||||
def __init__(self, data):
|
||||
code_match = re.match(r'([0-9]+)-([0-9]+)([CRHLSB])', data["Code"])
|
||||
if code_match:
|
||||
self.__opus, self.__serial, self.__rarity = code_match.groups()
|
||||
if not data:
|
||||
self.__opus = "0"
|
||||
self.__serial = "000"
|
||||
self.__rarity = "X"
|
||||
self.__element = None
|
||||
self.__description = None
|
||||
|
||||
else:
|
||||
code_match = re.match(r'PR-([0-9]+)', data["Code"])
|
||||
if code_match:
|
||||
self.__opus = "PR"
|
||||
self.__serial = code_match.group(1)
|
||||
self.__rarity = "P"
|
||||
if str(data["Code"])[0].isnumeric():
|
||||
self.__opus, self.__serial, self.__rarity = \
|
||||
re.match(r'([0-9]+)-([0-9]+)([CRHLS])', data["Code"]).groups()
|
||||
|
||||
elif str(data["Code"]).startswith("PR"):
|
||||
self.__opus, self.__serial = \
|
||||
re.match(r'(PR)-([0-9]+)', data["Code"]).groups()
|
||||
self.__rarity = ""
|
||||
|
||||
elif str(data["Code"]).startswith("B"):
|
||||
self.__opus, self.__serial = \
|
||||
re.match(r'(B)-([0-9]+)', data["Code"]).groups()
|
||||
self.__rarity = ""
|
||||
|
||||
else:
|
||||
code_match = re.match(r'B-([0-9]+)', data["Code"])
|
||||
if code_match:
|
||||
self.__opus = "B"
|
||||
self.__serial = code_match.group(1)
|
||||
self.__rarity = "B"
|
||||
self.__opus, self.__serial, self.__rarity = \
|
||||
"?", "???", "?"
|
||||
|
||||
self.__name = data["Name_EN"]
|
||||
self.__element = data["Element"]
|
||||
self.__name = data["Name_EN"]
|
||||
self.__element = data["Element"].split("/")
|
||||
self.__description = data["Text_EN"]
|
||||
|
||||
def __str__(self):
|
||||
return f"'{self.__name}' ({self.__element}, {self.get_id()})"
|
||||
|
|
|
@ -1,9 +1,15 @@
|
|||
import requests
|
||||
|
||||
from .card import Card
|
||||
|
||||
APIURL = "https://fftcg.square-enix-games.com/de/get-cards"
|
||||
|
||||
|
||||
class Opus:
|
||||
def __init__(self, data):
|
||||
self.__cards = [Card(card_data) for card_data in data]
|
||||
def __init__(self, params):
|
||||
# self.__cards = [Card(card_data) for card_data in data]
|
||||
req = requests.post(APIURL, json=params)
|
||||
self.__cards = [Card(card_data) for card_data in req.json()["cards"]]
|
||||
|
||||
def __str__(self):
|
||||
return "\n".join(str(card) for card in self.__cards)
|
||||
|
|
9
main.py
9
main.py
|
@ -1,7 +1,5 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import requests
|
||||
|
||||
from fftcg.opus import Opus
|
||||
|
||||
|
||||
|
@ -12,15 +10,12 @@ def print_hi(name):
|
|||
# [str] multicard="○"|"", ex_burst="○"|"", code, special="《S》"|""
|
||||
# [int] exactmatch=0|1
|
||||
params = {
|
||||
"language": "de",
|
||||
"text": "",
|
||||
"element": ["fire"],
|
||||
# "set": ["Opus XIV"],
|
||||
"set": ["Opus XIV"],
|
||||
}
|
||||
|
||||
opus_json = requests.post(url="https://fftcg.square-enix-games.com/de/get-cards", json=params).json()
|
||||
|
||||
opus = Opus(opus_json["cards"])
|
||||
opus = Opus(params)
|
||||
print(opus)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue