This commit is contained in:
+56
-2
@@ -1627,6 +1627,55 @@ async def get_episodes_missing_nfo_dateadded(dependencies: dict):
|
||||
}
|
||||
|
||||
|
||||
async def fix_nfo_missing_dateadded(dependencies: dict):
|
||||
"""Fix NFO files missing dateadded elements via core container"""
|
||||
config = dependencies["config"]
|
||||
|
||||
try:
|
||||
print("🔧 Calling core container for NFO repair fix...")
|
||||
|
||||
# Call the core container's NFO repair fix endpoint
|
||||
import aiohttp
|
||||
import asyncio
|
||||
|
||||
core_url = f"http://nfoguard:{config.core_api_port}/admin/nfo-repair-fix"
|
||||
print(f"🔍 DEBUG: Calling core container at: {core_url}")
|
||||
|
||||
timeout = aiohttp.ClientTimeout(total=600.0) # 10 minute timeout for fix operation
|
||||
async with aiohttp.ClientSession(timeout=timeout) as session:
|
||||
async with session.post(core_url) as response:
|
||||
if response.status == 200:
|
||||
result = await response.json()
|
||||
print(f"✅ Core container fix complete: {result.get('fixed_count', 0)} fixed, {result.get('failed_count', 0)} failed")
|
||||
|
||||
return {
|
||||
"success": True,
|
||||
"fixed_count": result.get("fixed_count", 0),
|
||||
"failed_count": result.get("failed_count", 0),
|
||||
"total_processed": result.get("total_processed", 0),
|
||||
"results": result.get("results", []),
|
||||
"message": f"Successfully fixed {result.get('fixed_count', 0)} NFO files"
|
||||
}
|
||||
else:
|
||||
error_text = await response.text()
|
||||
print(f"❌ Core container fix failed: {response.status} - {error_text}")
|
||||
return {
|
||||
"success": False,
|
||||
"error": f"Core container fix failed: {response.status}",
|
||||
"message": f"Failed to fix NFO files: {error_text}"
|
||||
}
|
||||
|
||||
except Exception as e:
|
||||
print(f"❌ Error calling core container for NFO repair fix: {str(e)}")
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
return {
|
||||
"success": False,
|
||||
"error": f"Core container communication failed: {str(e)}",
|
||||
"message": f"Failed to fix NFO files: {str(e)}"
|
||||
}
|
||||
|
||||
|
||||
async def bulk_update_nfo_files(dependencies: dict, imdb_ids: list = None, fix_all: bool = False):
|
||||
"""Update NFO files with missing dateadded elements from database"""
|
||||
db = dependencies["db"]
|
||||
@@ -1747,8 +1796,13 @@ def register_database_admin_routes(app, dependencies):
|
||||
|
||||
@app.post("/api/admin/nfo/bulk-update")
|
||||
async def api_bulk_update_nfo_files(imdb_ids: list = None, fix_all: bool = False):
|
||||
"""Bulk update NFO files with missing dateadded"""
|
||||
return await bulk_update_nfo_files(dependencies, imdb_ids, fix_all)
|
||||
"""Bulk update NFO files with missing dateadded via core container"""
|
||||
# For now, we only support fix_all mode using the new core container approach
|
||||
if fix_all or not imdb_ids:
|
||||
return await fix_nfo_missing_dateadded(dependencies)
|
||||
else:
|
||||
# Legacy mode for specific IMDb IDs - fallback to old method
|
||||
return await bulk_update_nfo_files(dependencies, imdb_ids, fix_all)
|
||||
|
||||
@app.get("/api/admin/database/quick-queries")
|
||||
async def api_database_quick_queries():
|
||||
|
||||
Reference in New Issue
Block a user