|
|
@@ -4,7 +4,7 @@ import sys
|
|
|
import tomllib
|
|
|
import typing
|
|
|
|
|
|
-import httpx
|
|
|
+import cache
|
|
|
|
|
|
def main() -> None:
|
|
|
planet = sys.argv[1].casefold()
|
|
|
@@ -66,11 +66,9 @@ def main() -> None:
|
|
|
def fio_data(planet: str) -> tuple[PlanetData, typing.Sequence[Material]]:
|
|
|
with open('config.toml', 'rb') as f:
|
|
|
config = tomllib.load(f)
|
|
|
- client = httpx.Client(headers={'Authorization': config['fio_api_key']})
|
|
|
|
|
|
- r = client.get('https://rest.fnar.net/fioweb/burn/user/' + config['username'])
|
|
|
- r.raise_for_status()
|
|
|
- planets: list[PlanetData] = r.json()
|
|
|
+ planets: list[PlanetData] = cache.get('https://rest.fnar.net/fioweb/burn/user/' + config['username'],
|
|
|
+ headers={'Authorization': config['fio_api_key']})
|
|
|
for planet_data in planets:
|
|
|
name = planet_data['PlanetName']
|
|
|
if name.casefold() == planet:
|
|
|
@@ -79,10 +77,7 @@ def fio_data(planet: str) -> tuple[PlanetData, typing.Sequence[Material]]:
|
|
|
else:
|
|
|
raise ValueError(planet + ' not found')
|
|
|
|
|
|
- r = client.get('https://rest.fnar.net/material/allmaterials')
|
|
|
- materials: list[Material] = r.json()
|
|
|
- r.raise_for_status()
|
|
|
-
|
|
|
+ materials: list[Material] = cache.get('https://rest.fnar.net/material/allmaterials')
|
|
|
return planet_data, materials
|
|
|
|
|
|
class PlanetData(typing.TypedDict):
|