diff --git a/api/web_routes.py b/api/web_routes.py index ce7bf9b..6a199b5 100644 --- a/api/web_routes.py +++ b/api/web_routes.py @@ -1280,6 +1280,44 @@ def register_web_routes(app, dependencies): async def api_episode_date_options(imdb_id: str, season: int, episode: int): return {"options": [], "message": "Date options not available in web container. Use core container on port 8085."} + @app.delete("/api/episodes/{imdb_id}/{season}/{episode}") + async def api_delete_episode(imdb_id: str, season: int, episode: int): + """Delete an episode from the database""" + db = dependencies["db"] + + try: + # Check if episode exists + with db.get_connection() as conn: + cursor = conn.cursor() + cursor.execute( + "SELECT season, episode, dateadded, source FROM episodes WHERE imdb_id = %s AND season = %s AND episode = %s", + (imdb_id, season, episode) + ) + episode_data = cursor.fetchone() + + if not episode_data: + raise HTTPException(status_code=404, detail="Episode not found") + + # Delete the episode + cursor.execute( + "DELETE FROM episodes WHERE imdb_id = %s AND season = %s AND episode = %s", + (imdb_id, season, episode) + ) + conn.commit() + + return { + "success": True, + "status": "success", + "message": f"Deleted episode {imdb_id} S{season:02d}E{episode:02d}", + "imdb_id": imdb_id, + "season": season, + "episode": episode + } + + except Exception as e: + print(f"❌ Error deleting episode: {e}") + raise HTTPException(status_code=500, detail=f"Failed to delete episode: {str(e)}") + # Bulk operations @app.post("/api/bulk/update-source") async def api_bulk_update_source(media_type: str, old_source: str, new_source: str): diff --git a/nfoguard-web/static/index.html b/nfoguard-web/static/index.html index fde3fcb..bebdb29 100644 --- a/nfoguard-web/static/index.html +++ b/nfoguard-web/static/index.html @@ -457,6 +457,6 @@
- +