This commit is contained in:
@@ -1136,8 +1136,8 @@ async def get_populate_status():
|
|||||||
def register_web_routes(app, dependencies):
|
def register_web_routes(app, dependencies):
|
||||||
"""Register all web API routes with FastAPI app"""
|
"""Register all web API routes with FastAPI app"""
|
||||||
from fastapi import Request, Response
|
from fastapi import Request, Response
|
||||||
|
|
||||||
# Dashboard and stats endpoints
|
# Dashboard and stats endpoints
|
||||||
@app.get("/api/dashboard")
|
@app.get("/api/dashboard")
|
||||||
async def api_dashboard():
|
async def api_dashboard():
|
||||||
return await get_dashboard_stats(dependencies)
|
return await get_dashboard_stats(dependencies)
|
||||||
@@ -1259,8 +1259,14 @@ def register_web_routes(app, dependencies):
|
|||||||
|
|
||||||
# Database population endpoints
|
# Database population endpoints
|
||||||
@app.post("/admin/populate-database")
|
@app.post("/admin/populate-database")
|
||||||
async def api_populate_database(background_tasks: BackgroundTasks, media_type: str = "both"):
|
async def api_populate_database(request: Request, background_tasks: BackgroundTasks):
|
||||||
"""Populate database from Radarr/Sonarr"""
|
"""Populate database from Radarr/Sonarr"""
|
||||||
|
try:
|
||||||
|
data = await request.json()
|
||||||
|
media_type = data.get("media_type", "both")
|
||||||
|
except Exception:
|
||||||
|
# Fallback to query parameter if JSON parsing fails
|
||||||
|
media_type = request.query_params.get("media_type", "both")
|
||||||
return await populate_database(background_tasks, media_type, dependencies)
|
return await populate_database(background_tasks, media_type, dependencies)
|
||||||
|
|
||||||
@app.get("/api/populate/status")
|
@app.get("/api/populate/status")
|
||||||
|
|||||||
Reference in New Issue
Block a user