File size: 869 Bytes
6e31acb 0664351 6e31acb 1612c96 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | import httpx
from utils.logger import log
async def fetch_txt_file(url) -> list[str]:
try:
async with httpx.AsyncClient() as client:
r = await client.get(url, timeout=15.0)
r.raise_for_status()
lines = r.text.strip().splitlines()
return [
line.strip().lstrip("@").lower()
for line in lines
if line.strip() and not line.strip().startswith("#")
]
except Exception as e:
log(f"Failed to fetch txt from {url}: {e}")
return []
async def fetch_json_file(url) -> dict:
try:
async with httpx.AsyncClient() as client:
r = await client.get(url, timeout=15.0)
r.raise_for_status()
return r.json()
except Exception as e:
log(f"Failed to fetch JSON from {url}: {e}")
raise |