diff --git a/backend/app/importer/strategies/profile.py b/backend/app/importer/strategies/profile.py index f6414a8..6a2dbc8 100644 --- a/backend/app/importer/strategies/profile.py +++ b/backend/app/importer/strategies/profile.py @@ -38,8 +38,8 @@ class ProfileStrategy(ImportStrategy): # Load profile YAML profile_yaml = load_yaml(f"profile/{filename}.yml") - # Extract referenced custom formats - format_names = extract_format_names(profile_yaml) + # Extract referenced custom formats (only for the target arr type) + format_names = extract_format_names(profile_yaml, self.arr_type) for format_name in format_names: # Skip if already processed diff --git a/backend/app/importer/utils.py b/backend/app/importer/utils.py index e9ab8f1..f902e79 100644 --- a/backend/app/importer/utils.py +++ b/backend/app/importer/utils.py @@ -46,12 +46,14 @@ def load_yaml(file_path: str) -> Dict[str, Any]: return yaml.safe_load(f) -def extract_format_names(profile_data: Dict[str, Any]) -> Set[str]: +def extract_format_names(profile_data: Dict[str, Any], arr_type: str = None) -> Set[str]: """ Extract all custom format names referenced in a profile. Args: profile_data: Profile YAML data + arr_type: Target arr type ('radarr' or 'sonarr'). If provided, only extracts + formats for that specific arr type. Returns: Set of unique format names @@ -64,10 +66,18 @@ def extract_format_names(profile_data: Dict[str, Any]) -> Set[str]: format_names.add(cf['name']) # Extract from app-specific custom_formats - for key in ['custom_formats_radarr', 'custom_formats_sonarr']: - for cf in profile_data.get(key, []): + if arr_type: + # Only extract formats for the specific arr type + app_key = f'custom_formats_{arr_type.lower()}' + for cf in profile_data.get(app_key, []): if isinstance(cf, dict) and 'name' in cf: format_names.add(cf['name']) + else: + # Extract from all app-specific sections (backwards compatibility) + for key in ['custom_formats_radarr', 'custom_formats_sonarr']: + for cf in profile_data.get(key, []): + if isinstance(cf, dict) and 'name' in cf: + format_names.add(cf['name']) return format_names