file and folder organization, removal of monoliths
This commit is contained in:
BIN
services/__pycache__/ffscouter.cpython-313.pyc
Normal file
BIN
services/__pycache__/ffscouter.cpython-313.pyc
Normal file
Binary file not shown.
BIN
services/__pycache__/torn_api.cpython-313.pyc
Normal file
BIN
services/__pycache__/torn_api.cpython-313.pyc
Normal file
Binary file not shown.
22
services/ffscouter.py
Normal file
22
services/ffscouter.py
Normal file
@@ -0,0 +1,22 @@
|
||||
import aiohttp
|
||||
from config import FFSCOUTER_KEY
|
||||
|
||||
async def fetch_batch_stats(ids: list[int]):
|
||||
"""
|
||||
Fetches predicted stats for a list of Torn IDs in a single FFScouter request.
|
||||
Returns dict keyed by player_id.
|
||||
"""
|
||||
if not ids:
|
||||
return {}
|
||||
|
||||
ids_str = ",".join(map(str, ids))
|
||||
url = f"https://ffscouter.com/api/v1/get-stats?key={FFSCOUTER_KEY}&targets={ids_str}"
|
||||
|
||||
async with aiohttp.ClientSession() as session:
|
||||
async with session.get(url) as resp:
|
||||
if resp.status != 200:
|
||||
print("FFScouter batch error:", resp.status)
|
||||
return {}
|
||||
data = await resp.json()
|
||||
|
||||
return {str(d["player_id"]): d for d in data}
|
||||
12
services/torn_api.py
Normal file
12
services/torn_api.py
Normal file
@@ -0,0 +1,12 @@
|
||||
import aiohttp
|
||||
from config import TORN_API_KEY, ENEMY_FACTION_ID
|
||||
|
||||
async def fetch_enemy_members():
|
||||
url = f"https://api.torn.com/v2/faction/{ENEMY_FACTION_ID}?selections=members&key={TORN_API_KEY}"
|
||||
async with aiohttp.ClientSession() as session:
|
||||
async with session.get(url) as resp:
|
||||
if resp.status != 200:
|
||||
print("Torn faction fetch error:", resp.status)
|
||||
return []
|
||||
data = await resp.json()
|
||||
return data.get("members", [])
|
||||
Reference in New Issue
Block a user