diff --git a/src/ytdl_sub/config/preset_options.py b/src/ytdl_sub/config/preset_options.py index 2d907b29..f1ba8534 100644 --- a/src/ytdl_sub/config/preset_options.py +++ b/src/ytdl_sub/config/preset_options.py @@ -1,7 +1,9 @@ from typing import Any +from typing import Dict from typing import Optional from ytdl_sub.config.defaults import DEFAULT_DOWNLOAD_ARCHIVE_NAME +from ytdl_sub.config.overrides import Overrides from ytdl_sub.validators.file_path_validators import OverridesStringFormatterFilePathValidator from ytdl_sub.validators.file_path_validators import StringFormatterFileNameValidator from ytdl_sub.validators.strict_dict_validator import StrictDictValidator @@ -48,6 +50,16 @@ class YTDLOptions(UnstructuredOverridesDictFormatterValidator): where each key is a ytdl argument. Include in the example are some popular ytdl_options. """ + def to_native_dict(self, overrides: Overrides) -> Dict: + """ + Materializes the entire ytdl-options dict from OverrideStringFormatters into + native python + """ + return { + key: overrides.apply_overrides_formatter_to_native(val) + for key, val in self.dict.items() + } + # Disable for proper docstring formatting # pylint: disable=line-too-long diff --git a/src/ytdl_sub/downloaders/url/downloader.py b/src/ytdl_sub/downloaders/url/downloader.py index 81f310a7..f47cedee 100644 --- a/src/ytdl_sub/downloaders/url/downloader.py +++ b/src/ytdl_sub/downloaders/url/downloader.py @@ -457,7 +457,7 @@ class MultiUrlDownloader(SourcePlugin[MultiUrlValidator]): def _download_metadata(self, url: str, validator: UrlValidator) -> Iterable[Entry]: metadata_ytdl_options = self.metadata_ytdl_options( - ytdl_option_overrides=validator.ytdl_options.dict + ytdl_option_overrides=validator.ytdl_options.to_native_dict(self.overrides) ) download_reversed = ScriptUtils.bool_formatter_output( self.overrides.apply_formatter(validator.download_reverse) diff --git a/src/ytdl_sub/subscriptions/subscription_ytdl_options.py b/src/ytdl_sub/subscriptions/subscription_ytdl_options.py index d1f288ee..12efb951 100644 --- a/src/ytdl_sub/subscriptions/subscription_ytdl_options.py +++ b/src/ytdl_sub/subscriptions/subscription_ytdl_options.py @@ -110,11 +110,7 @@ class SubscriptionYTDLOptions: @property def _user_ytdl_options(self) -> Dict: - native_ytdl_options = { - key: self._overrides.apply_overrides_formatter_to_native(val) - for key, val in self._preset.ytdl_options.dict.items() - } - return native_ytdl_options + return self._preset.ytdl_options.to_native_dict(self._overrides) @property def _plugin_match_filters(self) -> Dict: