web: manual update debug
Local Docker Build (Dev) / build-dev (push) Successful in 5s

This commit is contained in:
2025-10-26 11:32:59 -04:00
parent cb46b56243
commit 1d837102e9
2 changed files with 97 additions and 4 deletions
+57
View File
@@ -2083,6 +2083,59 @@ def stop_scan_tracking():
# Route Registration
# ---------------------------
async def update_episode_nfo(imdb_id: str, season: int, episode: int, request: Request, dependencies: dict):
"""Update NFO file for a specific episode with new dateadded"""
try:
# Get request data
payload = await request.json()
dateadded = payload.get('dateadded')
source = payload.get('source', 'manual')
aired = payload.get('aired')
# Get dependencies
config = dependencies["config"]
nfo_manager = dependencies["nfo_manager"]
if not config.manage_nfo:
return {"success": False, "message": "NFO management is disabled"}
# Find the series directory based on IMDb ID
series_path = None
for tv_path in config.tv_paths:
for series_dir in Path(tv_path).iterdir():
if series_dir.is_dir() and imdb_id.lower() in series_dir.name.lower():
series_path = series_dir
break
if series_path:
break
if not series_path:
return {"success": False, "message": f"Series directory not found for {imdb_id}"}
# Get season directory
season_dir = series_path / config.tv_season_dir_format.format(season=season)
if not season_dir.exists():
return {"success": False, "message": f"Season directory not found: {season_dir}"}
# Update NFO file
nfo_manager.create_episode_nfo(
season_dir=season_dir,
season_num=season,
episode_num=episode,
aired=aired,
dateadded=dateadded,
source=source,
lock_metadata=config.lock_metadata
)
print(f"✅ Updated NFO file for {imdb_id} S{season:02d}E{episode:02d}")
return {"success": True, "message": f"NFO file updated for {imdb_id} S{season:02d}E{episode:02d}"}
except Exception as e:
print(f"❌ Error updating NFO file for {imdb_id} S{season:02d}E{episode:02d}: {e}")
return {"success": False, "message": f"Failed to update NFO file: {str(e)}"}
def register_routes(app, dependencies: dict):
"""
Register all routes with the FastAPI app
@@ -2136,6 +2189,10 @@ def register_routes(app, dependencies: dict):
@app.delete("/database/episode/{imdb_id}/{season}/{episode}")
async def _delete_episode(imdb_id: str, season: int, episode: int):
return await delete_episode(imdb_id, season, episode, dependencies)
@app.post("/api/episodes/{imdb_id}/{season}/{episode}/update-nfo")
async def _update_episode_nfo(imdb_id: str, season: int, episode: int, request: Request):
return await update_episode_nfo(imdb_id, season, episode, request, dependencies)
@app.delete("/database/series/{imdb_id}/episodes")
async def _delete_series_episodes(imdb_id: str):