diff --git a/api/web_routes.py b/api/web_routes.py index ba5d3cf..01061e6 100644 --- a/api/web_routes.py +++ b/api/web_routes.py @@ -1247,6 +1247,31 @@ def register_web_routes(app, dependencies): async def api_movie_date_options(imdb_id: str): return {"options": [], "message": "Date options not available in web container. Use core container on port 8085."} + @app.delete("/api/movies/{imdb_id}") + async def api_delete_movie(imdb_id: str): + """Delete a movie from the database""" + db = dependencies["db"] + + try: + # Use the existing database method + deleted = db.delete_movie(imdb_id) + + if deleted: + return { + "success": True, + "status": "success", + "message": f"Deleted movie {imdb_id}", + "imdb_id": imdb_id + } + else: + raise HTTPException(status_code=404, detail="Movie not found") + + except HTTPException: + raise # Re-raise HTTP exceptions + except Exception as e: + print(f"❌ Error deleting movie: {e}") + raise HTTPException(status_code=500, detail=f"Failed to delete movie: {str(e)}") + # TV series endpoints @app.get("/api/series") async def api_series_list(skip: int = 0, limit: int = 50, search: str = None, diff --git a/nfoguard-web/static/index.html b/nfoguard-web/static/index.html index 2d871c6..957aeea 100644 --- a/nfoguard-web/static/index.html +++ b/nfoguard-web/static/index.html @@ -457,6 +457,6 @@
- + \ No newline at end of file diff --git a/nfoguard-web/static/js/app.js b/nfoguard-web/static/js/app.js index 1bb327c..ff0b565 100644 --- a/nfoguard-web/static/js/app.js +++ b/nfoguard-web/static/js/app.js @@ -1322,24 +1322,15 @@ async function deleteMovie(imdbId) { } try { - const response = await fetch(`/api/movies/${imdbId}`, { - method: 'DELETE', - headers: { - 'Content-Type': 'application/json' - } + const result = await apiCall(`/api/movies/${imdbId}`, { + method: 'DELETE' }); - const result = await response.json(); - - if (response.ok && result.success) { + if (result.success) { showToast(`✅ Movie deleted successfully`, 'success'); // Refresh the movies table loadMovies(currentMoviesPage); - - } else { - const errorMsg = result.message || result.error || 'Unknown error'; - showToast(`❌ Failed to delete movie: ${errorMsg}`, 'error'); } } catch (error) {