diff --git a/src/ytdl_sub/config/preset.py b/src/ytdl_sub/config/preset.py index 74b37d39..f5ecd3ac 100644 --- a/src/ytdl_sub/config/preset.py +++ b/src/ytdl_sub/config/preset.py @@ -12,7 +12,6 @@ from mergedeep import mergedeep from ytdl_sub.config.config_validator import ConfigValidator from ytdl_sub.config.plugin import Plugin -from ytdl_sub.config.preset_class_mappings import DownloadStrategyMapping from ytdl_sub.config.preset_class_mappings import PluginMapping from ytdl_sub.config.preset_options import OptionsValidator from ytdl_sub.config.preset_options import OutputOptions @@ -39,10 +38,10 @@ from ytdl_sub.validators.validators import validation_exception PRESET_KEYS = { "preset", + "download", "output_options", "ytdl_options", "overrides", - *DownloadStrategyMapping.sources(), *PluginMapping.plugins(), } diff --git a/src/ytdl_sub/config/preset_class_mappings.py b/src/ytdl_sub/config/preset_class_mappings.py index f3745d5c..060d8c89 100644 --- a/src/ytdl_sub/config/preset_class_mappings.py +++ b/src/ytdl_sub/config/preset_class_mappings.py @@ -3,8 +3,6 @@ from typing import List from typing import Type from ytdl_sub.config.plugin import Plugin -from ytdl_sub.downloaders.source_plugin import SourcePlugin -from ytdl_sub.downloaders.url.downloader import MultiUrlDownloader from ytdl_sub.plugins.audio_extract import AudioExtractPlugin from ytdl_sub.plugins.chapters import ChaptersPlugin from ytdl_sub.plugins.date_range import DateRangePlugin @@ -21,83 +19,6 @@ from ytdl_sub.plugins.subtitles import SubtitlesPlugin from ytdl_sub.plugins.video_tags import VideoTagsPlugin -class DownloadStrategyMapping: - """ - Maps downloader strategies defined in the preset to its respective downloader class - """ - - _MAPPING: Dict[str, Dict[str, Type[SourcePlugin]]] = { - "download": { - "multi_url": MultiUrlDownloader, - "url": MultiUrlDownloader, - }, - } - - @classmethod - def sources(cls) -> List[str]: - """ - Returns - ------- - Available download sources - """ - return sorted(list(cls._MAPPING.keys())) - - @classmethod - def _validate_is_source(cls, source: str) -> None: - """ - Ensure the source exists - """ - if source not in cls.sources(): - raise ValueError( - f"Tried to use source '{source}' which does not exist. Available sources: " - f"{', '.join(cls.sources())}" - ) - - @classmethod - def source_download_strategies(cls, source: str) -> List[str]: - """ - Parameters - ---------- - source - Name of the source - - Returns - ------- - Available download strategies for the given source - """ - cls._validate_is_source(source) - return sorted(list(cls._MAPPING[source].keys())) - - @classmethod - def _validate_is_download_strategy(cls, source: str, download_strategy: str) -> None: - """ - Ensure the download strategy for the given source exists - """ - if download_strategy not in cls.source_download_strategies(source): - raise ValueError( - f"Tried to use download strategy '{download_strategy}' with source '{source}', " - f"which does not exist. Available download strategies: " - f"{', '.join(cls.source_download_strategies(source))}" - ) - - @classmethod - def get(cls, source: str, download_strategy: str) -> Type[SourcePlugin]: - """ - Parameters - ---------- - source: - The source (i.e. 'youtube', 'soundcloud') of the downloader - download_strategy: - The download strategy name - - Returns - ------- - The downloader class - """ - cls._validate_is_download_strategy(source, download_strategy) - return cls._MAPPING[source][download_strategy] - - class PluginMapping: """ Maps plugins defined in the preset to its respective plugin class diff --git a/tests/unit/config/test_config_file.py b/tests/unit/config/test_config_file.py index 82163ea3..2966df44 100644 --- a/tests/unit/config/test_config_file.py +++ b/tests/unit/config/test_config_file.py @@ -6,7 +6,6 @@ import pytest from ytdl_sub.config.config_file import ConfigFile from ytdl_sub.config.preset import PRESET_KEYS -from ytdl_sub.config.preset_class_mappings import DownloadStrategyMapping from ytdl_sub.config.preset_class_mappings import PluginMapping from ytdl_sub.utils.exceptions import ValidationException @@ -57,11 +56,6 @@ class TestConfigFilePartiallyValidatesPresets: if plugin not in excluded_plugins: self._partial_validate({plugin: {}}) - @pytest.mark.parametrize("source", DownloadStrategyMapping.sources()) - def test_success__empty_sources(self, source: str): - for download_strategy in DownloadStrategyMapping.source_download_strategies(source): - self._partial_validate({source: {"download_strategy": download_strategy}}) - def test_error__bad_preset_section(self): self._partial_validate( preset_dict={"does_not_exist": "lol"},