Adds the ability to toggle whether to use `upload_date` or `release_date` in the date_range plugin, which is used to cull older videos. ``` date_range: type: "upload_date" ``` If using the Only Recent preset, it will be automatically applied based on whether your season/episode ordering uses release date or upload date. Closes https://github.com/jmbannon/ytdl-sub/issues/1182
34 lines
1.1 KiB
Python
34 lines
1.1 KiB
Python
from typing import Set
|
|
|
|
from ytdl_sub.validators.string_formatter_validators import OverridesStringFormatterValidator
|
|
from ytdl_sub.validators.validators import StringValidator
|
|
|
|
|
|
class StringSelectValidator(StringValidator):
|
|
"""
|
|
Ensures strings have selected one of the discrete allowed values.
|
|
"""
|
|
|
|
_select_values: Set[str] = set()
|
|
|
|
def __init__(self, name, value: str):
|
|
super().__init__(name=name, value=value)
|
|
|
|
if self.value not in self._select_values:
|
|
raise self._validation_exception(
|
|
f"Must be one of the following values: {', '.join(self._select_values)}"
|
|
)
|
|
|
|
|
|
class OverridesStringSelectValidator(OverridesStringFormatterValidator):
|
|
_expected_value_type_name = "overrides select"
|
|
|
|
_select_values: Set[str] = set()
|
|
|
|
def post_process(self, resolved: str) -> str:
|
|
if resolved not in self._select_values:
|
|
raise self._validation_exception(
|
|
f"Must be one of the following values: {', '.join(sorted(self._select_values))}"
|
|
)
|
|
|
|
return resolved
|