mirror of
https://github.com/Dictionarry-Hub/profilarr.git
synced 2026-01-22 19:01:02 +01:00
- added option to set radarr/sonarr specific scores that profilarr's compiler will handle on import - revise design for arr settings container - now styled as a table - completely rewrote import module. Now uses connection pooling to reuse connections. - fixed import progress bug where 1 failed format causes all other formats to be labelled as failed (even if they succeeded) - fixed bug where on pull sync wasn't working - improve styling for link / unlink database modals - fixed issue where 0 score formats were removed in selective mode
60 lines
1.6 KiB
Python
60 lines
1.6 KiB
Python
"""Routes for the new import module."""
|
|
from flask import Blueprint, request, jsonify
|
|
from flask_cors import cross_origin
|
|
import logging
|
|
from . import handle_import_request
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
bp = Blueprint('new_import', __name__)
|
|
|
|
|
|
@bp.route('', methods=['POST', 'OPTIONS'])
|
|
@cross_origin()
|
|
def import_items():
|
|
"""
|
|
Import formats or profiles to an Arr instance.
|
|
|
|
Request body:
|
|
{
|
|
"arrID": int, # ID of arr_config to use
|
|
"strategy": str, # "format" or "profile"
|
|
"filenames": [str], # List of filenames to import
|
|
"dryRun": bool # Optional: simulate import without changes (default: false)
|
|
}
|
|
"""
|
|
if request.method == 'OPTIONS':
|
|
return jsonify({}), 200
|
|
|
|
try:
|
|
data = request.get_json()
|
|
|
|
# Validate request
|
|
if not data:
|
|
return jsonify({
|
|
'success': False,
|
|
'error': 'Request body is required'
|
|
}), 400
|
|
|
|
# Call the import handler
|
|
result = handle_import_request(data)
|
|
|
|
# Return appropriate status code
|
|
status_code = 200
|
|
if result.get('status') == 'partial':
|
|
status_code = 207
|
|
elif not result.get('success'):
|
|
if 'not found' in result.get('error', '').lower():
|
|
status_code = 404
|
|
else:
|
|
status_code = 400
|
|
|
|
return jsonify(result), status_code
|
|
|
|
except Exception as e:
|
|
logger.error(f"Error handling import request: {str(e)}")
|
|
return jsonify({
|
|
'success': False,
|
|
'error': str(e)
|
|
}), 500
|