feat: add webinterface
Local Docker Build (Dev) / build-dev (pull_request) Successful in 4s

This commit is contained in:
2025-10-14 14:57:17 -04:00
parent 867bd008c5
commit cebed7a6bb
6 changed files with 2377 additions and 2 deletions
+76 -2
View File
@@ -10,7 +10,14 @@ from fastapi import HTTPException, BackgroundTasks, Request
from typing import Optional
# Import models
from api.models import SonarrWebhook, RadarrWebhook, HealthResponse, TVSeasonRequest, TVEpisodeRequest
from api.models import (
SonarrWebhook, RadarrWebhook, HealthResponse, TVSeasonRequest, TVEpisodeRequest,
MovieUpdateRequest, EpisodeUpdateRequest, BulkUpdateRequest
)
from api.web_routes import (
get_movies_list, get_tv_series_list, get_series_episodes, get_missing_dates_report,
get_dashboard_stats, update_movie_date, update_episode_date, bulk_update_source
)
# ---------------------------
@@ -1002,4 +1009,71 @@ def register_routes(app, dependencies: dict):
# Include monitoring routes
from api.monitoring_routes import router as monitoring_router
app.include_router(monitoring_router)
app.include_router(monitoring_router)
# ---------------------------
# Web Interface API Routes
# ---------------------------
@app.get("/api/dashboard")
async def _dashboard_stats():
"""Get dashboard statistics"""
return await get_dashboard_stats(dependencies)
@app.get("/api/movies")
async def _movies_list(skip: int = 0, limit: int = 100, has_date: Optional[bool] = None,
source_filter: Optional[str] = None, search: Optional[str] = None):
"""Get paginated movies list with filtering"""
return await get_movies_list(dependencies, skip, limit, has_date, source_filter, search)
@app.get("/api/series")
async def _series_list(skip: int = 0, limit: int = 50, search: Optional[str] = None):
"""Get paginated TV series list"""
return await get_tv_series_list(dependencies, skip, limit, search)
@app.get("/api/series/{imdb_id}/episodes")
async def _series_episodes(imdb_id: str):
"""Get episodes for a specific series"""
return await get_series_episodes(dependencies, imdb_id)
@app.get("/api/reports/missing-dates")
async def _missing_dates_report():
"""Get report of content missing dateadded"""
return await get_missing_dates_report(dependencies)
@app.put("/api/movies/{imdb_id}")
async def _update_movie(imdb_id: str, request: MovieUpdateRequest):
"""Update movie dateadded"""
return await update_movie_date(dependencies, imdb_id, request.dateadded, request.source)
@app.put("/api/episodes/{imdb_id}/{season}/{episode}")
async def _update_episode(imdb_id: str, season: int, episode: int, request: EpisodeUpdateRequest):
"""Update episode dateadded"""
return await update_episode_date(dependencies, imdb_id, season, episode, request.dateadded, request.source)
@app.post("/api/bulk/update-source")
async def _bulk_update_source(request: BulkUpdateRequest):
"""Bulk update source for movies or episodes"""
return await bulk_update_source(dependencies, request.media_type, request.old_source, request.new_source)
# ---------------------------
# Static Web Interface
# ---------------------------
from fastapi.staticfiles import StaticFiles
from fastapi.responses import FileResponse
import os
# Serve static files for web interface
static_dir = os.path.join(os.path.dirname(__file__), "..", "static")
if os.path.exists(static_dir):
app.mount("/static", StaticFiles(directory=static_dir), name="static")
@app.get("/")
async def _serve_index():
"""Serve web interface index page"""
index_path = os.path.join(static_dir, "index.html")
if os.path.exists(index_path):
return FileResponse(index_path)
else:
return {"message": "NFOGuard Web Interface - API endpoints available at /api/", "api_docs": "/docs"}