From 7cc0d7c7a588e7559d207504dd80597a21a618dc Mon Sep 17 00:00:00 2001 From: Lukas Pupka-Lipinski Date: Mon, 29 Sep 2025 10:34:09 +0200 Subject: [PATCH] fixed search and add --- src/server/app.py | 52 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/src/server/app.py b/src/server/app.py index 98f6248..6086b0b 100644 --- a/src/server/app.py +++ b/src/server/app.py @@ -732,6 +732,58 @@ def search_series(): 'message': f'Search failed: {str(e)}' }), 500 +@app.route('/api/add_series', methods=['POST']) +@optional_auth +@handle_api_errors +def add_series(): + """Add a new series to the collection.""" + try: + # Get the request data + data = request.get_json() + if not data: + return jsonify({ + 'status': 'error', + 'message': 'Request data is required' + }), 400 + + # Validate required fields + if 'link' not in data or 'name' not in data: + return jsonify({ + 'status': 'error', + 'message': 'Both link and name are required' + }), 400 + + link = data['link'].strip() + name = data['name'].strip() + + if not link or not name: + return jsonify({ + 'status': 'error', + 'message': 'Link and name cannot be empty' + }), 400 + + # Check if series_app is available + if series_app is None: + return jsonify({ + 'status': 'error', + 'message': 'Series application not initialized' + }), 500 + + # Create and add the series + new_serie = Serie(link, name, "aniworld.to", link, {}) + series_app.List.add(new_serie) + + return jsonify({ + 'status': 'success', + 'message': f'Series "{name}" added successfully' + }) + + except Exception as e: + return jsonify({ + 'status': 'error', + 'message': f'Failed to add series: {str(e)}' + }), 500 + @app.route('/api/rescan', methods=['POST']) @optional_auth def rescan_series():