fix tv season title for mini series

This commit is contained in:
mein Name 2025-03-09 12:22:45 -04:00 committed by Henri Dickson
parent a789f25505
commit 340dfd9dff

View file

@ -44,6 +44,7 @@ from catalog.common import (
) )
from catalog.common.models import LANGUAGE_CHOICES_JSONFORM, LanguageListField from catalog.common.models import LANGUAGE_CHOICES_JSONFORM, LanguageListField
from common.models.lang import RE_LOCALIZED_SEASON_NUMBERS, localize_number from common.models.lang import RE_LOCALIZED_SEASON_NUMBERS, localize_number
from common.models.misc import uniq
class TVShowInSchema(ItemInSchema): class TVShowInSchema(ItemInSchema):
@ -414,30 +415,35 @@ class TVSeason(Item):
- "Show Title Season X" with some localization - "Show Title Season X" with some localization
""" """
s = super().display_title s = super().display_title
if self.parent_item and ( if self.parent_item:
RE_LOCALIZED_SEASON_NUMBERS.sub("", s) == "" if (
or s == self.parent_item.display_title RE_LOCALIZED_SEASON_NUMBERS.sub("", s) == ""
): or s == self.parent_item.display_title
if self.parent_item.get_season_count() == 1: ):
return self.parent_item.display_title if self.parent_item.get_season_count() == 1:
elif self.season_number: return self.parent_item.display_title
return _("{show_title} Season {season_number}").format( elif self.season_number:
show_title=self.parent_item.display_title, return _("{show_title} Season {season_number}").format(
season_number=localize_number(self.season_number), show_title=self.parent_item.display_title,
) season_number=localize_number(self.season_number),
else: )
return f"{self.parent_item.display_title} {s}" else:
return f"{self.parent_item.display_title} {s}"
elif self.parent_item.display_title not in s:
return f"{self.parent_item.display_title} ({s})"
return s return s
@cached_property @cached_property
def additional_title(self) -> list[str]: def additional_title(self) -> list[str]:
title = self.display_title title = self.display_title
return [ return uniq(
t["text"] [
for t in self.localized_title t["text"]
if t["text"] != title for t in self.localized_title
and RE_LOCALIZED_SEASON_NUMBERS.sub("", t["text"]) != "" if t["text"] != title
] and RE_LOCALIZED_SEASON_NUMBERS.sub("", t["text"]) != ""
]
)
def to_indexable_titles(self) -> list[str]: def to_indexable_titles(self) -> list[str]:
titles = [t["text"] for t in self.localized_title if t["text"]] titles = [t["text"] for t in self.localized_title if t["text"]]