docs for collection seasons

This commit is contained in:
Jesse Bannon 2022-10-01 12:05:38 -07:00
parent 25c161bd36
commit f4a2971f9b
3 changed files with 125 additions and 27 deletions

View file

@ -34,7 +34,7 @@ from ytdl_sub.entries.variables.kwargs import UPLOAD_DATE_INDEX
# pylint: disable=too-many-public-methods
def _pad(num: int, width: int = 2):
def pad(num: int, width: int = 2):
return str(num).zfill(width)
@ -96,7 +96,7 @@ class EntryVariables(BaseEntryVariables):
int
The source index, padded.
"""
return _pad(self.source_index, 2)
return pad(self.source_index, 2)
@property
def source_count(self: Self) -> int:
@ -189,7 +189,7 @@ class EntryVariables(BaseEntryVariables):
str
playlist_index padded two digits
"""
return _pad(self.playlist_index, width=2)
return pad(self.playlist_index, width=2)
@property
def playlist_index_reversed_padded(self: Self) -> str:
@ -199,7 +199,7 @@ class EntryVariables(BaseEntryVariables):
str
playlist_index_reversed padded two digits
"""
return _pad(self.playlist_index_reversed, width=2)
return pad(self.playlist_index_reversed, width=2)
@property
def playlist_index_padded6(self: Self) -> str:
@ -209,7 +209,7 @@ class EntryVariables(BaseEntryVariables):
str
playlist_index padded six digits.
"""
return _pad(self.playlist_index, width=6)
return pad(self.playlist_index, width=6)
@property
def playlist_index_reversed_padded6(self: Self) -> str:
@ -219,7 +219,7 @@ class EntryVariables(BaseEntryVariables):
str
playlist_index_reversed padded six digits.
"""
return _pad(self.playlist_index_reversed, width=6)
return pad(self.playlist_index_reversed, width=6)
@property
def playlist_count(self: Self) -> int:
@ -396,7 +396,7 @@ class EntryVariables(BaseEntryVariables):
int
The upload_date_index padded two digits
"""
return _pad(self.upload_date_index, 2)
return pad(self.upload_date_index, 2)
@property
def upload_date_index_reversed(self: Self) -> int:
@ -416,7 +416,7 @@ class EntryVariables(BaseEntryVariables):
int
The upload_date_index padded two digits
"""
return _pad(self.upload_date_index_reversed, 2)
return pad(self.upload_date_index_reversed, 2)
@property
def upload_date(self: Self) -> str:
@ -477,7 +477,7 @@ class EntryVariables(BaseEntryVariables):
str
The reversed upload month, but padded. i.e. November returns "02"
"""
return _pad(self.upload_month_reversed)
return pad(self.upload_month_reversed)
@property
def upload_month_padded(self: Self) -> str:
@ -542,7 +542,7 @@ class EntryVariables(BaseEntryVariables):
str
The reversed upload day, but padded. i.e. August 30th returns "02".
"""
return _pad(self.upload_day_reversed)
return pad(self.upload_day_reversed)
@property
def upload_day_of_year(self: Self) -> int:
@ -566,7 +566,7 @@ class EntryVariables(BaseEntryVariables):
str
The upload day of year, but padded i.e. February 1st returns "032"
"""
return _pad(self.upload_day_of_year, width=3)
return pad(self.upload_day_of_year, width=3)
@property
def upload_day_of_year_reversed(self: Self) -> int:
@ -591,7 +591,7 @@ class EntryVariables(BaseEntryVariables):
str
The reversed upload day of year, but padded i.e. December 31st returns "001"
"""
return _pad(self.upload_day_of_year_reversed, width=3)
return pad(self.upload_day_of_year_reversed, width=3)
@property
def upload_date_standardized(self: Self) -> str:

View file

@ -2,16 +2,36 @@ from typing import Any
from typing import Dict
from typing import List
from typing import Optional
from typing import Set
from ytdl_sub.entries.variables.entry_variables import pad
Preset = Dict[str, Any]
####################################################
# TV SHOW TYPES
KODI_TV_SHOW = "kodi_tv_show"
JELLYFIN_TV_SHOW = "jellyfin_tv_show"
PLEX_TV_SHOW = "plex_tv_show"
#####################################################
# TV SHOW URL PRESETS
TV_SHOW_URL = "tv_show_url"
SEASON_YEAR__EPISODE_MONTH_DAY = "season_by_year__episode_by_month_day"
SEASON_YEAR__EPISODE_MONTH_DAY_REVERSED = "season_by_year__episode_by_month_day_reversed"
SEASON_YEAR_MONTH__EPISODE_DAY = "season_by_year_month__episode_by_day"
#####################################################
# TV SHOW COLLECTION PRESETS
TV_SHOW_COLLECTION = "tv_show_collection"
SEASON_COLLECTION__EPISODE_Y_M_D = "season_by_collection__episode_by_year_month_day"
SEASON_COLLECTION__EPISODE_Y_M_D_REV = "season_by_collection__episode_by_year_month_day_reversed"
class PrebuiltPresets:
@classmethod
@ -19,9 +39,13 @@ class PrebuiltPresets:
return {"presets": {name: {"preset": parent_presets}}}
@classmethod
def get_preset_names(cls) -> List[str]:
def _document_preset(cls) -> Preset:
return {}
@classmethod
def get_preset_names(cls) -> Set[str]:
preset_names = [prop for prop in dir(cls) if isinstance(getattr(cls, prop), property)]
return preset_names
return set(preset_names)
@classmethod
def get_presets(cls) -> List[Preset]:
@ -63,6 +87,29 @@ class PrebuiltTvShowUrlPresets(PrebuiltPresets):
)
class PrebuiltTvShowUrlEpisodeOrderingPresets(PrebuiltPresets):
@property
def season_by_year__episode_by_month_day(self) -> Preset:
"""
DOC
"""
return self._document_preset()
@property
def season_by_year__episode_by_month_day_reversed(self) -> Preset:
"""
DOC
"""
return self._document_preset()
@property
def season_by_year_month__episode_by_day(self) -> Preset:
"""
DOC
"""
return self._document_preset()
class PrebuiltTvShowCollectionPresets(PrebuiltPresets):
"""
Docstring for all TV SHOW URL presets
@ -95,3 +142,56 @@ class PrebuiltTvShowCollectionPresets(PrebuiltPresets):
return self._build_preset(
name="plex_tv_show_collection", parent_presets=[PLEX_TV_SHOW, TV_SHOW_COLLECTION]
)
class PrebuiltTvShowCollectionEpisodeOrderingPresets(PrebuiltPresets):
@property
def season_by_collection__episode_by_year_month_day(self) -> Preset:
"""
DOC
"""
return self._document_preset()
@property
def season_by_collection__episode_by_year_month_day_reversed(self) -> Preset:
"""
DOC
"""
return self._document_preset()
class PrebuiltTvShowCollectionSeasonPresets(PrebuiltPresets):
@property
def collection_season_1(self):
"""
DOC
"""
return self._document_preset()
@property
def collection_season_2(self):
"""
DOC
"""
return self._document_preset()
@property
def collection_season_3(self):
"""
DOC
"""
return self._document_preset()
@property
def collection_season_4(self):
"""
DOC
"""
return self._document_preset()
@property
def collection_season_5(self):
"""
DOC
"""
return self._document_preset()

View file

@ -8,18 +8,16 @@ from expected_transaction_log import assert_transaction_log_matches
from ytdl_sub.prebuilt_presets import PrebuiltTvShowCollectionPresets
from ytdl_sub.prebuilt_presets import PrebuiltTvShowUrlPresets
from ytdl_sub.prebuilt_presets.tv_show import PrebuiltTvShowCollectionEpisodeOrderingPresets
from ytdl_sub.prebuilt_presets.tv_show import PrebuiltTvShowCollectionSeasonPresets
from ytdl_sub.prebuilt_presets.tv_show import PrebuiltTvShowUrlEpisodeOrderingPresets
from ytdl_sub.subscriptions.subscription import Subscription
from ytdl_sub.utils.exceptions import ValidationException
@pytest.mark.parametrize("media_player_preset", PrebuiltTvShowUrlPresets.get_preset_names())
@pytest.mark.parametrize(
"tv_show_structure_preset",
[
"season_by_year__episode_by_month_day",
"season_by_year__episode_by_month_day_reversed",
"season_by_year_month__episode_by_day",
],
"tv_show_structure_preset", PrebuiltTvShowUrlEpisodeOrderingPresets.get_preset_names()
)
class TestPrebuiltTVShowPresets:
def test_compilation(
@ -116,14 +114,12 @@ class TestPrebuiltTVShowPresets:
@pytest.mark.parametrize("media_player_preset", PrebuiltTvShowCollectionPresets.get_preset_names())
@pytest.mark.parametrize(
"tv_show_structure_preset",
[
"season_by_collection__episode_by_year_month_day",
"season_by_collection__episode_by_year_month_day_reversed",
],
"tv_show_structure_preset", PrebuiltTvShowCollectionEpisodeOrderingPresets.get_preset_names()
)
class TestPrebuiltTvShowCollectionPresets:
@pytest.mark.parametrize("season_preset", ["collection_season_1", "collection_season_2"])
@pytest.mark.parametrize(
"season_preset", PrebuiltTvShowCollectionSeasonPresets.get_preset_names()
)
def test_compilation(
self,
config,
@ -147,7 +143,9 @@ class TestPrebuiltTvShowCollectionPresets:
},
)
@pytest.mark.parametrize("season_preset", ["collection_season_1", "collection_season_2"])
@pytest.mark.parametrize(
"season_preset", PrebuiltTvShowCollectionSeasonPresets.get_preset_names()
)
def test_compilation_errors_missing_one(
self,
config,