fixed search and add
This commit is contained in:
parent
7286b9b3e8
commit
7cc0d7c7a5
@ -732,6 +732,58 @@ def search_series():
|
|||||||
'message': f'Search failed: {str(e)}'
|
'message': f'Search failed: {str(e)}'
|
||||||
}), 500
|
}), 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'])
|
@app.route('/api/rescan', methods=['POST'])
|
||||||
@optional_auth
|
@optional_auth
|
||||||
def rescan_series():
|
def rescan_series():
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user