This commit is contained in:
+11
-20
@@ -2283,22 +2283,13 @@ def register_routes(app, dependencies: dict):
|
||||
import os
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
# Debug: Check what dependencies are available
|
||||
print(f"🔍 DEBUG: dependencies keys: {list(dependencies.keys()) if dependencies else 'None'}")
|
||||
print(f"🔍 DEBUG: dependencies type: {type(dependencies)}")
|
||||
|
||||
logger = dependencies.get("logger")
|
||||
config = dependencies.get("config")
|
||||
db = dependencies.get("db")
|
||||
|
||||
print(f"🔍 DEBUG: logger: {logger is not None}")
|
||||
print(f"🔍 DEBUG: config: {config is not None}")
|
||||
print(f"🔍 DEBUG: db: {db is not None}")
|
||||
if not config or not db:
|
||||
raise HTTPException(status_code=500, detail=f"Dependencies not available - config:{config is not None}, db:{db is not None}")
|
||||
|
||||
if not logger or not config or not db:
|
||||
raise HTTPException(status_code=500, detail=f"Dependencies not available - logger:{logger is not None}, config:{config is not None}, db:{db is not None}")
|
||||
|
||||
logger.info("🔧 Starting NFO repair scan from core container")
|
||||
print("🔧 Starting NFO repair scan from core container")
|
||||
|
||||
missing_items = {
|
||||
"episodes": [],
|
||||
@@ -2307,7 +2298,7 @@ def register_routes(app, dependencies: dict):
|
||||
|
||||
try:
|
||||
# Scan episodes
|
||||
logger.info("📺 Scanning episodes for missing dateadded elements")
|
||||
print("📺 Scanning episodes for missing dateadded elements")
|
||||
episode_query = """
|
||||
SELECT DISTINCT imdb_id, season, episode, series_name, episode_name, dateadded
|
||||
FROM episodes
|
||||
@@ -2320,7 +2311,7 @@ def register_routes(app, dependencies: dict):
|
||||
cursor.execute(episode_query)
|
||||
episodes = [dict(row) for row in cursor.fetchall()]
|
||||
|
||||
logger.info(f"📊 Found {len(episodes)} episodes in database")
|
||||
print(f"📊 Found {len(episodes)} episodes in database")
|
||||
|
||||
for episode in episodes:
|
||||
# Build NFO path
|
||||
@@ -2349,7 +2340,7 @@ def register_routes(app, dependencies: dict):
|
||||
"nfo_path": nfo_path
|
||||
})
|
||||
except ET.ParseError as e:
|
||||
logger.warning(f"⚠️ Could not parse NFO file {nfo_path}: {e}")
|
||||
print(f"⚠️ Could not parse NFO file {nfo_path}: {e}")
|
||||
missing_items["episodes"].append({
|
||||
"imdb_id": episode["imdb_id"],
|
||||
"season": episode["season"],
|
||||
@@ -2362,7 +2353,7 @@ def register_routes(app, dependencies: dict):
|
||||
})
|
||||
|
||||
# Scan movies
|
||||
logger.info("🎬 Scanning movies for missing dateadded elements")
|
||||
print("🎬 Scanning movies for missing dateadded elements")
|
||||
movie_query = """
|
||||
SELECT DISTINCT imdb_id, title, dateadded
|
||||
FROM movies
|
||||
@@ -2375,7 +2366,7 @@ def register_routes(app, dependencies: dict):
|
||||
cursor.execute(movie_query)
|
||||
movies = [dict(row) for row in cursor.fetchall()]
|
||||
|
||||
logger.info(f"📊 Found {len(movies)} movies in database")
|
||||
print(f"📊 Found {len(movies)} movies in database")
|
||||
|
||||
for movie in movies:
|
||||
# Build NFO path
|
||||
@@ -2400,7 +2391,7 @@ def register_routes(app, dependencies: dict):
|
||||
"nfo_path": nfo_path
|
||||
})
|
||||
except ET.ParseError as e:
|
||||
logger.warning(f"⚠️ Could not parse NFO file {nfo_path}: {e}")
|
||||
print(f"⚠️ Could not parse NFO file {nfo_path}: {e}")
|
||||
missing_items["movies"].append({
|
||||
"imdb_id": movie["imdb_id"],
|
||||
"title": movie["title"],
|
||||
@@ -2410,7 +2401,7 @@ def register_routes(app, dependencies: dict):
|
||||
})
|
||||
|
||||
total_missing = len(missing_items["episodes"]) + len(missing_items["movies"])
|
||||
logger.info(f"✅ NFO repair scan complete: {total_missing} items missing dateadded elements")
|
||||
print(f"✅ NFO repair scan complete: {total_missing} items missing dateadded elements")
|
||||
|
||||
return {
|
||||
"status": "success",
|
||||
@@ -2421,7 +2412,7 @@ def register_routes(app, dependencies: dict):
|
||||
}
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"❌ Error during NFO repair scan: {str(e)}")
|
||||
print(f"❌ Error during NFO repair scan: {str(e)}")
|
||||
raise HTTPException(status_code=500, detail=f"NFO repair scan failed: {str(e)}")
|
||||
|
||||
@app.get("/admin/nfo-repair-scan")
|
||||
|
||||
Reference in New Issue
Block a user