diff --git a/src/ytdl_sub/plugins/regex.py b/src/ytdl_sub/plugins/regex.py index 21d2fde1..c4611d6c 100644 --- a/src/ytdl_sub/plugins/regex.py +++ b/src/ytdl_sub/plugins/regex.py @@ -211,10 +211,13 @@ class RegexPlugin(Plugin[RegexOptions]): ) # otherwise, use defaults (apply them using the original entry source dict) + source_variables_and_overrides_dict = dict( + entry_variable_dict, **self.overrides.dict_with_format_strings + ) entry.add_variables( variables_to_add={ _source_var_name(source_var, i): default.apply_formatter( - variable_dict=entry_variable_dict + variable_dict=source_variables_and_overrides_dict ) for i, default in enumerate(regex_options.defaults) }, diff --git a/tests/e2e/plugins/test_regex.py b/tests/e2e/plugins/test_regex.py index f8f059a7..f2f0dcc5 100644 --- a/tests/e2e/plugins/test_regex.py +++ b/tests/e2e/plugins/test_regex.py @@ -33,7 +33,7 @@ def regex_subscription_dict(output_directory): "match": ["([0-9]+)-([0-9]+)-27"], "defaults": [ "First", - "Second", + "Second containing {in_regex_default}", ], }, "artist": {"match": ["Never (.*) capture"], "defaults": ["Always default"]}, @@ -46,8 +46,13 @@ def regex_subscription_dict(output_directory): "desc_cap": "{description_capture_1}", "upload_date_both_caps": "{upload_date_standardized_capture_1} and {upload_date_standardized_capture_2}", "artist_cap_always_default": "{artist_capture_1}", + "override_with_capture_variable": "{contains_regex_default}" } }, + "overrides": { + "in_regex_default": "in regex default", + "contains_regex_default": "contains {title_capture_1}" + } }