fix(Track): Don't modify lang when getting name

This commit is contained in:
rlaphoenix 2024-03-01 04:01:48 +00:00
parent 5b7c72d270
commit c14b37a696
1 changed files with 17 additions and 13 deletions

View File

@ -104,19 +104,23 @@ class Track:
return isinstance(other, Track) and self.id == other.id return isinstance(other, Track) and self.id == other.id
def get_track_name(self) -> Optional[str]: def get_track_name(self) -> Optional[str]:
"""Return the base Track Name. This may be enhanced in sub-classes.""" """Get the Track Name."""
if (self.language.language or "").lower() == (self.language.territory or "").lower(): simplified_language = self.language.simplify_script()
self.language.territory = None # e.g. en-en, de-DE script = simplified_language.script_name(max_distance=25)
if self.language.territory == "US": territory = simplified_language.territory_name(max_distance=25)
self.language.territory = None territory = TERRITORY_MAP.get(territory, territory)
reduced = self.language.simplify_script()
extra_parts = [] if (script or "").lower() == (territory or "").lower():
if reduced.script is not None: script = None
extra_parts.append(reduced.script_name(max_distance=25)) territory = None
if reduced.territory is not None: if territory == "US":
territory = reduced.territory_name(max_distance=25) territory = None
extra_parts.append(TERRITORY_MAP.get(territory, territory))
return ", ".join(extra_parts) or None region = script
if region and territory:
region += f", {territory}"
return region or None
def get_key_id(self, init_data: Optional[bytes] = None, *args, **kwargs) -> Optional[UUID]: def get_key_id(self, init_data: Optional[bytes] = None, *args, **kwargs) -> Optional[UUID]:
""" """