Fix TV endpoints to use proper JSON request models
🐛 API Fix: • Add TVSeasonRequest and TVEpisodeRequest Pydantic models • Update /tv/scan-season and /tv/scan-episode to accept JSON body • Fix query parameter validation errors ✅ Now Works: • curl -X POST "/tv/scan-season" -H "Content-Type: application/json" -d '{...}' • curl -X POST "/tv/scan-episode" -H "Content-Type: application/json" -d '{...}'
This commit is contained in:
+20
-11
@@ -192,6 +192,15 @@ class HealthResponse(BaseModel):
|
||||
database_status: str
|
||||
radarr_database: Optional[Dict[str, Any]] = None
|
||||
|
||||
class TVSeasonRequest(BaseModel):
|
||||
series_path: str
|
||||
season_name: str
|
||||
|
||||
class TVEpisodeRequest(BaseModel):
|
||||
series_path: str
|
||||
season_name: str
|
||||
episode_name: str
|
||||
|
||||
# ---------------------------
|
||||
# Core Processing
|
||||
# ---------------------------
|
||||
@@ -1557,14 +1566,14 @@ async def manual_scan(background_tasks: BackgroundTasks, path: Optional[str] = N
|
||||
return {"status": "started", "message": f"Manual {scan_type} scan started"}
|
||||
|
||||
@app.post("/tv/scan-season")
|
||||
async def scan_tv_season(background_tasks: BackgroundTasks, series_path: str, season_name: str):
|
||||
async def scan_tv_season(background_tasks: BackgroundTasks, request: TVSeasonRequest):
|
||||
"""Scan a specific TV season - URL-safe endpoint"""
|
||||
try:
|
||||
series_dir = Path(series_path)
|
||||
season_dir = series_dir / season_name
|
||||
series_dir = Path(request.series_path)
|
||||
season_dir = series_dir / request.season_name
|
||||
|
||||
if not series_dir.exists():
|
||||
raise HTTPException(status_code=404, detail=f"Series path not found: {series_path}")
|
||||
raise HTTPException(status_code=404, detail=f"Series path not found: {request.series_path}")
|
||||
if not season_dir.exists():
|
||||
raise HTTPException(status_code=404, detail=f"Season path not found: {season_dir}")
|
||||
|
||||
@@ -1580,21 +1589,21 @@ async def scan_tv_season(background_tasks: BackgroundTasks, series_path: str, se
|
||||
_log("ERROR", f"Failed processing season {season_dir}: {e}")
|
||||
|
||||
background_tasks.add_task(process_season)
|
||||
return {"status": "started", "message": f"Season scan started for {season_name}"}
|
||||
return {"status": "started", "message": f"Season scan started for {request.season_name}"}
|
||||
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=500, detail=str(e))
|
||||
|
||||
@app.post("/tv/scan-episode")
|
||||
async def scan_tv_episode(background_tasks: BackgroundTasks, series_path: str, season_name: str, episode_name: str):
|
||||
async def scan_tv_episode(background_tasks: BackgroundTasks, request: TVEpisodeRequest):
|
||||
"""Scan a specific TV episode - URL-safe endpoint"""
|
||||
try:
|
||||
series_dir = Path(series_path)
|
||||
season_dir = series_dir / season_name
|
||||
episode_file = season_dir / episode_name
|
||||
series_dir = Path(request.series_path)
|
||||
season_dir = series_dir / request.season_name
|
||||
episode_file = season_dir / request.episode_name
|
||||
|
||||
if not series_dir.exists():
|
||||
raise HTTPException(status_code=404, detail=f"Series path not found: {series_path}")
|
||||
raise HTTPException(status_code=404, detail=f"Series path not found: {request.series_path}")
|
||||
if not episode_file.exists():
|
||||
raise HTTPException(status_code=404, detail=f"Episode file not found: {episode_file}")
|
||||
|
||||
@@ -1610,7 +1619,7 @@ async def scan_tv_episode(background_tasks: BackgroundTasks, series_path: str, s
|
||||
_log("ERROR", f"Failed processing episode {episode_file}: {e}")
|
||||
|
||||
background_tasks.add_task(process_episode)
|
||||
return {"status": "started", "message": f"Episode scan started for {episode_name}"}
|
||||
return {"status": "started", "message": f"Episode scan started for {request.episode_name}"}
|
||||
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=500, detail=str(e))
|
||||
|
||||
Reference in New Issue
Block a user