From 56ff25e6b6a5dc98c180e508d23f4ac53d344ca8 Mon Sep 17 00:00:00 2001 From: Ayo Date: Mon, 9 Mar 2026 16:46:09 +0100 Subject: [PATCH] feat: only decode 200 OK response; filter None from statuses --- threads.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/threads.py b/threads.py index 1d1fa99..562458a 100755 --- a/threads.py +++ b/threads.py @@ -100,11 +100,13 @@ def middleware(): async def get(url, session): try: async with session.get(url, ssl=False) as response: - res = await response.json() - return utils.clean_status(res) + if response.status == 200: + res = await response.json() + return utils.clean_status(res) + else: + print(f"No status: {url}") except Exception as e: - print(f"Unable to get url {url} due to {e.__class__}") - return {} + return None def get_status_url(ser, id): return f'{ser}/api/v1/statuses/{id}' @@ -115,7 +117,8 @@ async def fetch_statuses(): try: async with aiohttp.ClientSession() as session: statuses = await asyncio.gather(*(get(url, session) for url in urls)) - return statuses + filtered = [x for x in statuses if x is not None] + return filtered except: return None