better separation
This commit is contained in:
parent
93fb3c1aa3
commit
25c161bd36
3 changed files with 64 additions and 85 deletions
|
|
@ -4,9 +4,8 @@ from typing import Dict
|
||||||
|
|
||||||
import mergedeep
|
import mergedeep
|
||||||
|
|
||||||
from ytdl_sub.prebuilt_presets.tv_show import PrebuiltJellyfinTVShowPresets
|
from ytdl_sub.prebuilt_presets.tv_show import PrebuiltTvShowCollectionPresets
|
||||||
from ytdl_sub.prebuilt_presets.tv_show import PrebuiltKodiTVShowPresets
|
from ytdl_sub.prebuilt_presets.tv_show import PrebuiltTvShowUrlPresets
|
||||||
from ytdl_sub.prebuilt_presets.tv_show import PrebuiltPlexTVShowPresets
|
|
||||||
from ytdl_sub.utils.yaml import load_yaml
|
from ytdl_sub.utils.yaml import load_yaml
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -21,9 +20,8 @@ def _merge_presets() -> Dict[str, Any]:
|
||||||
# Get all presets from published preset configs
|
# Get all presets from published preset configs
|
||||||
mergedeep.merge(
|
mergedeep.merge(
|
||||||
merged_configs,
|
merged_configs,
|
||||||
*PrebuiltKodiTVShowPresets.get_presets(),
|
*PrebuiltTvShowUrlPresets.get_presets(),
|
||||||
*PrebuiltJellyfinTVShowPresets.get_presets(),
|
*PrebuiltTvShowCollectionPresets.get_presets(),
|
||||||
*PrebuiltPlexTVShowPresets.get_presets()
|
|
||||||
)
|
)
|
||||||
|
|
||||||
return merged_configs["presets"]
|
return merged_configs["presets"]
|
||||||
|
|
|
||||||
|
|
@ -5,26 +5,18 @@ from typing import Optional
|
||||||
|
|
||||||
Preset = Dict[str, Any]
|
Preset = Dict[str, Any]
|
||||||
|
|
||||||
|
KODI_TV_SHOW = "kodi_tv_show"
|
||||||
|
JELLYFIN_TV_SHOW = "jellyfin_tv_show"
|
||||||
|
PLEX_TV_SHOW = "plex_tv_show"
|
||||||
|
|
||||||
|
TV_SHOW_URL = "tv_show_url"
|
||||||
|
TV_SHOW_COLLECTION = "tv_show_collection"
|
||||||
|
|
||||||
|
|
||||||
class PrebuiltPresets:
|
class PrebuiltPresets:
|
||||||
BASE_PRESET: str
|
@classmethod
|
||||||
|
def _build_preset(cls, name: str, parent_presets: List[str]) -> Preset:
|
||||||
def _preset(self, name: str, presets: List[str]) -> Preset:
|
return {"presets": {name: {"preset": parent_presets}}}
|
||||||
return {"presets": {name: {"preset": [self.BASE_PRESET] + presets}}}
|
|
||||||
|
|
||||||
def _tv_show_url(self, name: str) -> Preset:
|
|
||||||
"""
|
|
||||||
Kodi TV Show with seasons as years, episodes ordered by upload date
|
|
||||||
"""
|
|
||||||
return self._preset(
|
|
||||||
name=name, presets=["tv_show_url", "season_by_year__episode_by_month_day"]
|
|
||||||
)
|
|
||||||
|
|
||||||
def _tv_show_collection(self, name: str) -> Preset:
|
|
||||||
return self._preset(
|
|
||||||
name=name,
|
|
||||||
presets=["tv_show_collection", "season_by_collection__episode_by_year_month_day"],
|
|
||||||
)
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_preset_names(cls) -> List[str]:
|
def get_preset_names(cls) -> List[str]:
|
||||||
|
|
@ -32,70 +24,74 @@ class PrebuiltPresets:
|
||||||
return preset_names
|
return preset_names
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_collection_preset_names(cls) -> List[str]:
|
def get_presets(cls) -> List[Preset]:
|
||||||
return [name for name in cls.get_preset_names() if "collection" in name]
|
return [getattr(cls(), preset_name) for preset_name in cls.get_preset_names()]
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def get_non_collection_preset_names(cls) -> List[str]:
|
|
||||||
return [name for name in cls.get_preset_names() if "collection" not in name]
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def get_presets(cls, preset_names: Optional[List[str]] = None) -> List[Preset]:
|
|
||||||
if preset_names is None:
|
|
||||||
preset_names = cls.get_preset_names()
|
|
||||||
|
|
||||||
return [getattr(cls(), preset_name) for preset_name in preset_names]
|
|
||||||
|
|
||||||
|
|
||||||
class PrebuiltKodiTVShowPresets(PrebuiltPresets):
|
class PrebuiltTvShowUrlPresets(PrebuiltPresets):
|
||||||
BASE_PRESET = "kodi_tv_show"
|
"""
|
||||||
|
Docstring for all TV SHOW URL presets
|
||||||
|
"""
|
||||||
|
|
||||||
|
BASE_PRESET = "tv_show_url"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def kodi_tv_show_url(self) -> Preset:
|
def kodi_tv_show_url(self) -> Preset:
|
||||||
"""
|
"""
|
||||||
Kodi TV Show with seasons as years, episodes ordered by upload date
|
Kodi TV Show with seasons as years, episodes ordered by upload date
|
||||||
"""
|
"""
|
||||||
return self._tv_show_url(name="kodi_tv_show_url")
|
return self._build_preset(
|
||||||
|
name="kodi_tv_show_url", parent_presets=[KODI_TV_SHOW, TV_SHOW_URL]
|
||||||
@property
|
)
|
||||||
def kodi_tv_show_collection(self) -> Preset:
|
|
||||||
"""
|
|
||||||
Kodi TV Show from a collection of multiple URLs. TODO: finish docstring
|
|
||||||
"""
|
|
||||||
return self._tv_show_collection(name="kodi_tv_show_collection")
|
|
||||||
|
|
||||||
|
|
||||||
class PrebuiltJellyfinTVShowPresets(PrebuiltPresets):
|
|
||||||
BASE_PRESET = "jellyfin_tv_show"
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def jellyfin_tv_show_url(self) -> Preset:
|
def jellyfin_tv_show_url(self) -> Preset:
|
||||||
"""
|
"""
|
||||||
Kodi TV Show with seasons as years, episodes ordered by upload date
|
Kodi TV Show with seasons as years, episodes ordered by upload date
|
||||||
"""
|
"""
|
||||||
return self._tv_show_url(name="jellyfin_tv_show_url")
|
return self._build_preset(
|
||||||
|
name="jellyfin_tv_show_url", parent_presets=[JELLYFIN_TV_SHOW, TV_SHOW_URL]
|
||||||
@property
|
)
|
||||||
def jellyfin_tv_show_collection(self) -> Preset:
|
|
||||||
"""
|
|
||||||
Kodi TV Show from a collection of multiple URLs. TODO: finish docstring
|
|
||||||
"""
|
|
||||||
return self._tv_show_collection(name="jellyfin_tv_show_collection")
|
|
||||||
|
|
||||||
|
|
||||||
class PrebuiltPlexTVShowPresets(PrebuiltPresets):
|
|
||||||
BASE_PRESET = "plex_tv_show"
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def plex_tv_show_url(self) -> Preset:
|
def plex_tv_show_url(self) -> Preset:
|
||||||
"""
|
"""
|
||||||
Kodi TV Show with seasons as years, episodes ordered by upload date
|
Kodi TV Show with seasons as years, episodes ordered by upload date
|
||||||
"""
|
"""
|
||||||
return self._tv_show_url(name="plex_tv_show_url")
|
return self._build_preset(
|
||||||
|
name="plex_tv_show_url", parent_presets=[PLEX_TV_SHOW, TV_SHOW_URL]
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class PrebuiltTvShowCollectionPresets(PrebuiltPresets):
|
||||||
|
"""
|
||||||
|
Docstring for all TV SHOW URL presets
|
||||||
|
"""
|
||||||
|
|
||||||
|
@property
|
||||||
|
def kodi_tv_show_collection(self) -> Preset:
|
||||||
|
"""
|
||||||
|
Kodi TV Show with seasons as years, episodes ordered by upload date
|
||||||
|
"""
|
||||||
|
return self._build_preset(
|
||||||
|
name="kodi_tv_show_collection", parent_presets=[KODI_TV_SHOW, TV_SHOW_COLLECTION]
|
||||||
|
)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def jellyfin_tv_show_collection(self) -> Preset:
|
||||||
|
"""
|
||||||
|
Kodi TV Show with seasons as years, episodes ordered by upload date
|
||||||
|
"""
|
||||||
|
return self._build_preset(
|
||||||
|
name="jellyfin_tv_show_collection",
|
||||||
|
parent_presets=[JELLYFIN_TV_SHOW, TV_SHOW_COLLECTION],
|
||||||
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def plex_tv_show_collection(self) -> Preset:
|
def plex_tv_show_collection(self) -> Preset:
|
||||||
"""
|
"""
|
||||||
Kodi TV Show from a collection of multiple URLs. TODO: finish docstring
|
Kodi TV Show with seasons as years, episodes ordered by upload date
|
||||||
"""
|
"""
|
||||||
return self._tv_show_collection(name="plex_tv_show_collection")
|
return self._build_preset(
|
||||||
|
name="plex_tv_show_collection", parent_presets=[PLEX_TV_SHOW, TV_SHOW_COLLECTION]
|
||||||
|
)
|
||||||
|
|
|
||||||
|
|
@ -6,21 +6,13 @@ import pytest
|
||||||
from expected_download import assert_expected_downloads
|
from expected_download import assert_expected_downloads
|
||||||
from expected_transaction_log import assert_transaction_log_matches
|
from expected_transaction_log import assert_transaction_log_matches
|
||||||
|
|
||||||
from ytdl_sub.prebuilt_presets.tv_show import PrebuiltJellyfinTVShowPresets
|
from ytdl_sub.prebuilt_presets import PrebuiltTvShowCollectionPresets
|
||||||
from ytdl_sub.prebuilt_presets.tv_show import PrebuiltKodiTVShowPresets
|
from ytdl_sub.prebuilt_presets import PrebuiltTvShowUrlPresets
|
||||||
from ytdl_sub.prebuilt_presets.tv_show import PrebuiltPlexTVShowPresets
|
|
||||||
from ytdl_sub.subscriptions.subscription import Subscription
|
from ytdl_sub.subscriptions.subscription import Subscription
|
||||||
from ytdl_sub.utils.exceptions import ValidationException
|
from ytdl_sub.utils.exceptions import ValidationException
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize("media_player_preset", PrebuiltTvShowUrlPresets.get_preset_names())
|
||||||
"media_player_preset",
|
|
||||||
[
|
|
||||||
"kodi_tv_show_url",
|
|
||||||
"jellyfin_tv_show_url",
|
|
||||||
"plex_tv_show_url",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"tv_show_structure_preset",
|
"tv_show_structure_preset",
|
||||||
[
|
[
|
||||||
|
|
@ -122,14 +114,7 @@ class TestPrebuiltTVShowPresets:
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize("media_player_preset", PrebuiltTvShowCollectionPresets.get_preset_names())
|
||||||
"media_player_preset",
|
|
||||||
[
|
|
||||||
"kodi_tv_show_collection",
|
|
||||||
"jellyfin_tv_show_collection",
|
|
||||||
"plex_tv_show_collection",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"tv_show_structure_preset",
|
"tv_show_structure_preset",
|
||||||
[
|
[
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue