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,7 +415,8 @@ 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:
if (
RE_LOCALIZED_SEASON_NUMBERS.sub("", s) == "" RE_LOCALIZED_SEASON_NUMBERS.sub("", s) == ""
or s == self.parent_item.display_title or s == self.parent_item.display_title
): ):
@ -427,17 +429,21 @@ class TVSeason(Item):
) )
else: else:
return f"{self.parent_item.display_title} {s}" 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"] t["text"]
for t in self.localized_title for t in self.localized_title
if t["text"] != title if t["text"] != title
and RE_LOCALIZED_SEASON_NUMBERS.sub("", t["text"]) != "" 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"]]