From 2c858ffadb017997d686c981f9c7227c8b4581dc Mon Sep 17 00:00:00 2001 From: Jesse Bannon Date: Tue, 25 Jul 2023 14:09:15 -0700 Subject: [PATCH] update --- src/ytdl_sub/downloaders/url/multi_url.py | 26 +--------------------- src/ytdl_sub/downloaders/url/validators.py | 18 +++++++-------- 2 files changed, 10 insertions(+), 34 deletions(-) diff --git a/src/ytdl_sub/downloaders/url/multi_url.py b/src/ytdl_sub/downloaders/url/multi_url.py index 80d0cf20..01acdbb8 100644 --- a/src/ytdl_sub/downloaders/url/multi_url.py +++ b/src/ytdl_sub/downloaders/url/multi_url.py @@ -1,9 +1,7 @@ -from typing import Dict -from typing import List - from ytdl_sub.downloaders.url.validators import MultiUrlValidator +# TODO: Remove later - keep for docstring class MultiUrlDownloadOptions(MultiUrlValidator): """ Downloads from multiple URLs. If an entry is returned from more than one URL, it will @@ -38,25 +36,3 @@ class MultiUrlDownloadOptions(MultiUrlValidator): - name: "season{season_index}-poster.jpg" uid: "latest_entry" """ - - @property - def collection_validator(self) -> MultiUrlValidator: - """Returns itself!""" - return self - - def validate_with_variables( - self, source_variables: List[str], override_variables: Dict[str, str] - ) -> None: - """ - Validates any source variables added by the collection - """ - super().validate_with_variables( - source_variables=source_variables, override_variables=override_variables - ) - - has_non_empty_url = False - for url_validator in self.urls.list: - has_non_empty_url |= bool(url_validator.url.apply_formatter(override_variables)) - - if not has_non_empty_url: - raise self._validation_exception("Must contain at least one url that is non-empty") diff --git a/src/ytdl_sub/downloaders/url/validators.py b/src/ytdl_sub/downloaders/url/validators.py index 55f48863..cd558e04 100644 --- a/src/ytdl_sub/downloaders/url/validators.py +++ b/src/ytdl_sub/downloaders/url/validators.py @@ -179,6 +179,15 @@ class MultiUrlValidator(OptionsValidator): resolve to the bottom-most URL settings. """ + @classmethod + def partial_validate(cls, name: str, value: Any) -> None: + """ + Partially validate a collection + """ + if isinstance(value, dict): + value["urls"] = value.get("urls", [{"url": "placeholder"}]) + _ = cls(name, value) + def __init__(self, name, value): super().__init__(name, value) @@ -198,15 +207,6 @@ class MultiUrlValidator(OptionsValidator): name=name, value=UrlValidator(name=name, value=value_copy) ) - @classmethod - def partial_validate(cls, name: str, value: Any) -> None: - """ - Partially validate a collection - """ - if isinstance(value, dict): - value["urls"] = value.get("urls", [{"url": "placeholder"}]) - _ = cls(name, value) - @property def urls(self) -> UrlListValidator: """