From 2813fc6c7746dbd1f9f423f491634cdf406adf9c Mon Sep 17 00:00:00 2001 From: Sam Chau Date: Tue, 14 Jan 2025 05:59:50 +1030 Subject: [PATCH] feat: add support for 'edition' and 'quality_modifier' condition types in FormatConverter --- backend/app/compile/format_compiler.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/backend/app/compile/format_compiler.py b/backend/app/compile/format_compiler.py index 54ed014..427d3cb 100644 --- a/backend/app/compile/format_compiler.py +++ b/backend/app/compile/format_compiler.py @@ -51,14 +51,15 @@ class FormatConverter: target_app: TargetApp) -> Optional[Specification]: condition_type = condition['type'] - if condition_type in ['release_title', 'release_group']: + if condition_type in ['release_title', 'release_group', 'edition']: pattern_name = condition['pattern'] pattern = self.patterns.get(pattern_name) if not pattern: return None implementation = ('ReleaseTitleSpecification' if condition_type == 'release_title' else - 'ReleaseGroupSpecification') + 'ReleaseGroupSpecification' if condition_type + == 'release_group' else 'EditionSpecification') fields = [{'name': 'value', 'value': pattern}] elif condition_type == 'source': @@ -77,6 +78,14 @@ class FormatConverter: target_app) fields = [{'name': 'value', 'value': value}] + elif condition_type == 'quality_modifier': + if target_app == TargetApp.SONARR: + return None + implementation = 'QualityModifierSpecification' + value = ValueResolver.get_quality_modifier( + condition['qualityModifier']) + fields = [{'name': 'value', 'value': value}] + elif condition_type == 'language': implementation = 'LanguageSpecification' language_name = condition['language'].lower() @@ -94,6 +103,7 @@ class FormatConverter: except Exception: return None + # still need to do size, year, release type else: return None