pass preset instead of each options
This commit is contained in:
parent
5bfb5d20ba
commit
288e5cb892
2 changed files with 10 additions and 34 deletions
|
|
@ -13,24 +13,13 @@ from ytdl_subscribe.entries.entry import Entry
|
||||||
from ytdl_subscribe.validators.config.config_options.config_options_validator import (
|
from ytdl_subscribe.validators.config.config_options.config_options_validator import (
|
||||||
ConfigOptionsValidator,
|
ConfigOptionsValidator,
|
||||||
)
|
)
|
||||||
from ytdl_subscribe.validators.config.metadata_options.metadata_options_validator import (
|
from ytdl_subscribe.validators.config.preset_validator import PresetValidator
|
||||||
MetadataOptionsValidator,
|
|
||||||
)
|
|
||||||
from ytdl_subscribe.validators.config.output_options.output_options_validator import (
|
|
||||||
OutputOptionsValidator,
|
|
||||||
)
|
|
||||||
from ytdl_subscribe.validators.config.overrides.overrides_validator import (
|
|
||||||
OverridesValidator,
|
|
||||||
)
|
|
||||||
from ytdl_subscribe.validators.config.source_options.source_validator import (
|
from ytdl_subscribe.validators.config.source_options.source_validator import (
|
||||||
DownloadStrategyValidator,
|
DownloadStrategyValidator,
|
||||||
)
|
)
|
||||||
from ytdl_subscribe.validators.config.source_options.source_validator import (
|
from ytdl_subscribe.validators.config.source_options.source_validator import (
|
||||||
SourceValidator,
|
SourceValidator,
|
||||||
)
|
)
|
||||||
from ytdl_subscribe.validators.config.ytdl_options.ytdl_options_validator import (
|
|
||||||
YTDLOptionsValidator,
|
|
||||||
)
|
|
||||||
|
|
||||||
SOURCE_T = TypeVar("SOURCE_T", bound=SourceValidator)
|
SOURCE_T = TypeVar("SOURCE_T", bound=SourceValidator)
|
||||||
DOWNLOAD_STRATEGY_T = TypeVar("DOWNLOAD_STRATEGY_T", bound=DownloadStrategyValidator)
|
DOWNLOAD_STRATEGY_T = TypeVar("DOWNLOAD_STRATEGY_T", bound=DownloadStrategyValidator)
|
||||||
|
|
@ -46,11 +35,7 @@ class Subscription(object):
|
||||||
self,
|
self,
|
||||||
name: str,
|
name: str,
|
||||||
config_options: ConfigOptionsValidator,
|
config_options: ConfigOptionsValidator,
|
||||||
source_options: SourceValidator,
|
preset_options: PresetValidator,
|
||||||
output_options: OutputOptionsValidator,
|
|
||||||
metadata_options: MetadataOptionsValidator,
|
|
||||||
ytdl_options: YTDLOptionsValidator,
|
|
||||||
overrides: OverridesValidator,
|
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
Parameters
|
Parameters
|
||||||
|
|
@ -58,16 +43,16 @@ class Subscription(object):
|
||||||
name: str
|
name: str
|
||||||
Name of the subscription
|
Name of the subscription
|
||||||
config_options: ConfigOptionsValidator
|
config_options: ConfigOptionsValidator
|
||||||
source_options: SourceValidator
|
preset_options: PresetValidator
|
||||||
output_options: OutputOptionsValidator
|
|
||||||
metadata_options: MetadataOptionsValidator
|
|
||||||
ytdl_options: YTDLOptionsValidator
|
|
||||||
overrides: OverridesValidator
|
|
||||||
"""
|
"""
|
||||||
self.name = name
|
self.name = name
|
||||||
|
self.output_options = preset_options.output_options
|
||||||
|
self.metadata_options = preset_options.metadata_options
|
||||||
|
self.ytdl_options = preset_options.ytdl_options
|
||||||
|
self.overrides = preset_options.overrides
|
||||||
self._config_options = config_options
|
self._config_options = config_options
|
||||||
self._source_options = source_options
|
self._source_options = preset_options.subscription_source
|
||||||
self._download_strategy_options = source_options.download_strategy
|
self._download_strategy_options = self._source_options.download_strategy
|
||||||
|
|
||||||
if not isinstance(self._source_options, self.source_validator_type):
|
if not isinstance(self._source_options, self.source_validator_type):
|
||||||
raise ValueError("Source options does not match the expected type")
|
raise ValueError("Source options does not match the expected type")
|
||||||
|
|
@ -75,11 +60,6 @@ class Subscription(object):
|
||||||
if not isinstance(self._download_strategy_options, self.download_strategy_type):
|
if not isinstance(self._download_strategy_options, self.download_strategy_type):
|
||||||
raise ValueError("Download strategy does not match the expected type")
|
raise ValueError("Download strategy does not match the expected type")
|
||||||
|
|
||||||
self.output_options = output_options
|
|
||||||
self.metadata_options = metadata_options
|
|
||||||
self.ytdl_options = ytdl_options
|
|
||||||
self.overrides = overrides
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def source_options(self) -> SOURCE_T:
|
def source_options(self) -> SOURCE_T:
|
||||||
return self._source_options
|
return self._source_options
|
||||||
|
|
|
||||||
|
|
@ -87,11 +87,7 @@ class SubscriptionValidator(StrictDictValidator):
|
||||||
return subscription_class(
|
return subscription_class(
|
||||||
name=self._name,
|
name=self._name,
|
||||||
config_options=self.config.config_options,
|
config_options=self.config.config_options,
|
||||||
source_options=self.preset.subscription_source,
|
preset_options=self.preset,
|
||||||
output_options=self.preset.output_options,
|
|
||||||
metadata_options=self.preset.metadata_options,
|
|
||||||
ytdl_options=self.preset.ytdl_options,
|
|
||||||
overrides=self.preset.overrides,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue