dev #62
@@ -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):
|
||||
|
||||
@@ -457,6 +457,6 @@
|
||||
<!-- Toast Notifications -->
|
||||
<div class="toast-container" id="toast-container"></div>
|
||||
|
||||
<script src="/static/js/app.js?v=2.8.2-20241025-final"></script>
|
||||
<script src="/static/js/app.js?v=2.8.2-20241025-delete-fix"></script>
|
||||
</body>
|
||||
</html>
|
||||
+5
-22
@@ -17,21 +17,8 @@ from config.settings import config
|
||||
# Import existing database and components
|
||||
from core.database import NFOGuardDatabase
|
||||
|
||||
# Add web interface path for routes only
|
||||
web_path = os.path.join(os.path.dirname(__file__), "nfoguard-web")
|
||||
if web_path not in sys.path:
|
||||
sys.path.append(web_path)
|
||||
|
||||
# Import web routes from separated system
|
||||
try:
|
||||
from api.web_routes import register_web_routes as register_separated_web_routes
|
||||
use_separated_routes = True
|
||||
print("✅ Using separated web routes with DELETE /api/episodes/ support")
|
||||
except ImportError:
|
||||
# Fallback to old routes if separated routes not available
|
||||
from api.web_routes import register_web_routes
|
||||
use_separated_routes = False
|
||||
print("⚠️ Using legacy web routes - DELETE functionality may be limited")
|
||||
# Import web routes from existing system (now includes DELETE route)
|
||||
from api.web_routes import register_web_routes
|
||||
|
||||
# Import authentication system
|
||||
from api.auth import SimpleAuthMiddleware, AuthSession
|
||||
@@ -165,13 +152,9 @@ def main():
|
||||
# Setup static files and routes
|
||||
setup_static_files(app)
|
||||
|
||||
# Register web routes (prefer separated routes if available)
|
||||
if use_separated_routes:
|
||||
register_separated_web_routes(app, dependencies)
|
||||
print("✅ Registered separated web routes with full /api/episodes/ support")
|
||||
else:
|
||||
register_web_routes(app, dependencies)
|
||||
print("⚠️ Using legacy web routes")
|
||||
# Register web routes (now includes DELETE /api/episodes/ route)
|
||||
register_web_routes(app, dependencies)
|
||||
print("✅ Registered web routes with DELETE /api/episodes/ support")
|
||||
|
||||
print(f"🚀 Starting web server on {web_host}:{web_port}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user