Skip to content

Commit

Permalink
Allow CardType-specific default season text formatters
Browse files Browse the repository at this point in the history
  • Loading branch information
CollinHeist committed Oct 16, 2023
1 parent c3e3f0c commit abcfba3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
13 changes: 9 additions & 4 deletions modules/Profile.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any
from typing import Any, Callable, Optional

from re import compile as re_compile, match, IGNORECASE

Expand Down Expand Up @@ -173,13 +173,18 @@ def convert_extras(self,
)


def get_season_text(self, episode_info: EpisodeInfo) -> str:
def get_season_text(self,
episode_info: EpisodeInfo,
default: Optional[Callable[[EpisodeInfo], str]] = None,
) -> str:
"""
Gets the season text for the given season number, after applying
this profile's rules about season text.
Args:
episode_info: Episode info to get the season text of.
default: Default function to call for getting season text
of if no customizations are present.
Returns:
The season text for the given entry as defined by this
Expand All @@ -193,11 +198,11 @@ def get_season_text(self, episode_info: EpisodeInfo) -> str:
# Generic season titles are Specials and Season {n}
if not self.__use_custom_seasons:
return self.__episode_map.get_generic_season_title(
episode_info=episode_info
episode_info=episode_info, default=default,
)

# Custom season title, query EpisodeMap for title
return self.__episode_map.get_season_title(episode_info)
return self.__episode_map.get_season_title(episode_info,default=default)


def get_episode_text(self, episode: 'Episode') -> str:
Expand Down
5 changes: 4 additions & 1 deletion modules/TitleCard.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,10 @@ def __init__(self,
'source_file': episode.source,
'card_file': episode.destination,
'title_text': self.converted_title,
'season_text': profile.get_season_text(self.episode.episode_info),
'season_text': profile.get_season_text(
self.episode.episode_info,
getattr(self.episode.card_class, 'SEASON_TEXT_FORMATTER', None),
),
'episode_text': profile.get_episode_text(self.episode),
'hide_season_text': profile.hide_season_title,
'blur': episode.blur,
Expand Down
2 changes: 1 addition & 1 deletion modules/ref/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.14.4-develop24
v1.14.4-develop25

0 comments on commit abcfba3

Please sign in to comment.