From f38ca539d6ae70e08798f26fa43817c05c067094 Mon Sep 17 00:00:00 2001 From: SBCrumb Date: Sun, 26 Oct 2025 12:32:57 -0400 Subject: [PATCH] web: switch to aiohttp --- api/web_routes.py | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/api/web_routes.py b/api/web_routes.py index f9e57e2..df119ea 100644 --- a/api/web_routes.py +++ b/api/web_routes.py @@ -1545,16 +1545,17 @@ async def get_episodes_missing_nfo_dateadded(dependencies: dict): print("🔧 Calling core container for NFO repair scan...") # Call the core container's NFO repair scan endpoint - import httpx + import aiohttp + import asyncio core_url = f"http://nfoguard-core:{config.core_api_port}/admin/nfo-repair-scan" print(f"🔍 DEBUG: Calling core container at: {core_url}") - async with httpx.AsyncClient(timeout=300.0) as client: # 5 minute timeout for filesystem scan - response = await client.get(core_url) - - if response.status_code == 200: - result = response.json() + timeout = aiohttp.ClientTimeout(total=300.0) # 5 minute timeout for filesystem scan + async with aiohttp.ClientSession(timeout=timeout) as session: + async with session.get(core_url) as response: + if response.status == 200: + result = await response.json() print(f"✅ Core container scan complete: {result['total_missing']} items missing dateadded") # Transform the data to match the expected legacy format @@ -1604,13 +1605,14 @@ async def get_episodes_missing_nfo_dateadded(dependencies: dict): "movies_missing": result['movies_missing'] } } - else: - print(f"❌ Core container scan failed: {response.status_code} - {response.text}") - return { - "success": False, - "error": f"Core container scan failed: {response.status_code}", - "message": f"Failed to check NFO files via core container: {response.status_code}" - } + else: + error_text = await response.text() + print(f"❌ Core container scan failed: {response.status} - {error_text}") + return { + "success": False, + "error": f"Core container scan failed: {response.status}", + "message": f"Failed to check NFO files via core container: {response.status}" + } except Exception as e: print(f"❌ Error calling core container for NFO repair scan: {str(e)}")