feat(Track): Add a name property to use for the Track Name

This commit is contained in:
rlaphoenix 2024-03-01 04:10:06 +00:00
parent 2a6fb96c3d
commit 3ceabd0c74
1 changed files with 10 additions and 1 deletions

View File

@ -32,6 +32,7 @@ class Track:
is_original_lang: bool = False, is_original_lang: bool = False,
descriptor: Descriptor = Descriptor.URL, descriptor: Descriptor = Descriptor.URL,
needs_repack: bool = False, needs_repack: bool = False,
name: Optional[str] = None,
drm: Optional[Iterable[DRM_T]] = None, drm: Optional[Iterable[DRM_T]] = None,
edition: Optional[str] = None, edition: Optional[str] = None,
extra: Optional[Any] = None, extra: Optional[Any] = None,
@ -47,6 +48,8 @@ class Track:
raise TypeError(f"Expected descriptor to be a {Track.Descriptor}, not {type(descriptor)}") raise TypeError(f"Expected descriptor to be a {Track.Descriptor}, not {type(descriptor)}")
if not isinstance(needs_repack, bool): if not isinstance(needs_repack, bool):
raise TypeError(f"Expected needs_repack to be a {bool}, not {type(needs_repack)}") raise TypeError(f"Expected needs_repack to be a {bool}, not {type(needs_repack)}")
if not isinstance(name, (str, type(None))):
raise TypeError(f"Expected name to be a {str}, not {type(name)}")
if not isinstance(id_, (str, type(None))): if not isinstance(id_, (str, type(None))):
raise TypeError(f"Expected id_ to be a {str}, not {type(id_)}") raise TypeError(f"Expected id_ to be a {str}, not {type(id_)}")
if not isinstance(edition, (str, type(None))): if not isinstance(edition, (str, type(None))):
@ -68,6 +71,7 @@ class Track:
self.is_original_lang = is_original_lang self.is_original_lang = is_original_lang
self.descriptor = descriptor self.descriptor = descriptor
self.needs_repack = needs_repack self.needs_repack = needs_repack
self.name = name
self.drm = drm self.drm = drm
self.edition: str = edition self.edition: str = edition
self.extra: Any = extra or {} # allow anything for extra, but default to a dict self.extra: Any = extra or {} # allow anything for extra, but default to a dict
@ -122,7 +126,12 @@ class Track:
if region and territory: if region and territory:
region += f", {territory}" region += f", {territory}"
return region or None if self.name:
track_name = self.name + f" ({region})" if region else ""
else:
track_name = region or None
return track_name
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]:
""" """