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
|
database_status: str
|
||||||
radarr_database: Optional[Dict[str, Any]] = None
|
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
|
# 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"}
|
return {"status": "started", "message": f"Manual {scan_type} scan started"}
|
||||||
|
|
||||||
@app.post("/tv/scan-season")
|
@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"""
|
"""Scan a specific TV season - URL-safe endpoint"""
|
||||||
try:
|
try:
|
||||||
series_dir = Path(series_path)
|
series_dir = Path(request.series_path)
|
||||||
season_dir = series_dir / season_name
|
season_dir = series_dir / request.season_name
|
||||||
|
|
||||||
if not series_dir.exists():
|
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():
|
if not season_dir.exists():
|
||||||
raise HTTPException(status_code=404, detail=f"Season path not found: {season_dir}")
|
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}")
|
_log("ERROR", f"Failed processing season {season_dir}: {e}")
|
||||||
|
|
||||||
background_tasks.add_task(process_season)
|
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:
|
except Exception as e:
|
||||||
raise HTTPException(status_code=500, detail=str(e))
|
raise HTTPException(status_code=500, detail=str(e))
|
||||||
|
|
||||||
@app.post("/tv/scan-episode")
|
@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"""
|
"""Scan a specific TV episode - URL-safe endpoint"""
|
||||||
try:
|
try:
|
||||||
series_dir = Path(series_path)
|
series_dir = Path(request.series_path)
|
||||||
season_dir = series_dir / season_name
|
season_dir = series_dir / request.season_name
|
||||||
episode_file = season_dir / episode_name
|
episode_file = season_dir / request.episode_name
|
||||||
|
|
||||||
if not series_dir.exists():
|
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():
|
if not episode_file.exists():
|
||||||
raise HTTPException(status_code=404, detail=f"Episode file not found: {episode_file}")
|
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}")
|
_log("ERROR", f"Failed processing episode {episode_file}: {e}")
|
||||||
|
|
||||||
background_tasks.add_task(process_episode)
|
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:
|
except Exception as e:
|
||||||
raise HTTPException(status_code=500, detail=str(e))
|
raise HTTPException(status_code=500, detail=str(e))
|
||||||
|
|||||||
Reference in New Issue
Block a user