forked from kenzuya/unshackle
feat(tracks): add a display-only note shown in --list and over --remote
This commit is contained in:
@@ -1722,6 +1722,7 @@ def serialize_track_common(track: Any) -> Dict[str, Any]:
|
||||
"track_name": track.get_track_name(),
|
||||
"needs_repack": bool(getattr(track, "needs_repack", False)),
|
||||
"edition": list(getattr(track, "edition", None) or []),
|
||||
"note": getattr(track, "note", None),
|
||||
"descriptor": descriptor_name(track),
|
||||
"drm": serialize_drm(track.drm) if getattr(track, "drm", None) else None,
|
||||
"drm_preference": getattr(track, "drm_preference", None),
|
||||
|
||||
@@ -288,6 +288,7 @@ def base_track_kwargs(data: Dict[str, Any]) -> Dict[str, Any]:
|
||||
"needs_repack": bool(data.get("needs_repack", False)),
|
||||
"name": data.get("name"),
|
||||
"edition": data.get("edition") or None,
|
||||
"note": data["note"] if isinstance(data.get("note"), str) else None,
|
||||
"id_": data.get("id"),
|
||||
}
|
||||
|
||||
|
||||
@@ -214,6 +214,7 @@ class Audio(Track):
|
||||
f"{self.bitrate // 1000} kb/s" if self.bitrate else None,
|
||||
self.get_track_name(),
|
||||
", ".join(self.edition) if self.edition else None,
|
||||
self.note,
|
||||
],
|
||||
)
|
||||
)
|
||||
|
||||
@@ -231,7 +231,13 @@ class Subtitle(Track):
|
||||
return " | ".join(
|
||||
filter(
|
||||
bool,
|
||||
["SUB", f"[{self.codec.value}]" if self.codec else None, str(self.language), self.get_track_name()],
|
||||
[
|
||||
"SUB",
|
||||
f"[{self.codec.value}]" if self.codec else None,
|
||||
str(self.language),
|
||||
self.get_track_name(),
|
||||
self.note,
|
||||
],
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -427,6 +427,7 @@ class Track:
|
||||
name: Optional[str] = None,
|
||||
drm: Optional[Iterable[DRM_T]] = None,
|
||||
edition: Optional[str] = None,
|
||||
note: Optional[str] = None,
|
||||
session: Optional[Union[Session, "RnetSession"]] = None,
|
||||
downloader: Optional[Callable] = None,
|
||||
downloader_args: Optional[dict] = None,
|
||||
@@ -451,6 +452,8 @@ class Track:
|
||||
raise TypeError(f"Expected id_ to be a {str}, not {type(id_)}")
|
||||
if not isinstance(edition, (str, list, type(None))):
|
||||
raise TypeError(f"Expected edition to be a {str}, {list}, or None, not {type(edition)}")
|
||||
if not isinstance(note, (str, type(None))):
|
||||
raise TypeError(f"Expected note to be a {str}, not {type(note)}")
|
||||
if not isinstance(downloader, (Callable, type(None))):
|
||||
raise TypeError(f"Expected downloader to be a {Callable}, not {type(downloader)}")
|
||||
if not isinstance(downloader_args, (dict, type(None))):
|
||||
@@ -483,6 +486,7 @@ class Track:
|
||||
self.drm = drm
|
||||
self._drm_preference: Optional[str] = None
|
||||
self.edition: list[str] = [edition] if isinstance(edition, str) else (edition or [])
|
||||
self.note = note
|
||||
self.session = session
|
||||
self.downloader = downloader
|
||||
self.downloader_args = downloader_args
|
||||
@@ -981,6 +985,7 @@ class Track:
|
||||
"needs_repack": self.needs_repack,
|
||||
"name": self.name,
|
||||
"edition": self.edition,
|
||||
"note": self.note,
|
||||
}
|
||||
return data
|
||||
|
||||
@@ -999,6 +1004,7 @@ class Track:
|
||||
"needs_repack": data.get("needs_repack", False),
|
||||
"name": data.get("name"),
|
||||
"edition": data.get("edition") or None,
|
||||
"note": data.get("note"),
|
||||
"id_": data.get("id"),
|
||||
}
|
||||
|
||||
|
||||
@@ -412,6 +412,7 @@ class Video(Track):
|
||||
)
|
||||
),
|
||||
", ".join(self.edition) if self.edition else None,
|
||||
self.note,
|
||||
],
|
||||
)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user