Add OnMultiplex event, for pre-multiplex

This commit is contained in:
rlaphoenix 2023-02-25 21:58:32 +00:00
parent 2635538205
commit fe320e177d
2 changed files with 7 additions and 0 deletions

View File

@ -56,6 +56,7 @@ class Track:
self.OnDownloaded: Optional[Callable] = None
self.OnDecrypted: Optional[Callable] = None
self.OnRepacked: Optional[Callable] = None
self.OnMultiplex: Optional[Callable] = None
# should only be set internally
self.path: Optional[Path] = None

View File

@ -314,6 +314,8 @@ class Tracks:
for i, vt in enumerate(self.videos):
if not vt.path or not vt.path.exists():
raise ValueError("Video Track must be downloaded before muxing...")
if callable(vt.OnMultiplex):
vt.OnMultiplex(vt)
cl.extend([
"--language", "0:{}".format(LANGUAGE_MUX_MAP.get(
str(vt.language), str(vt.language)
@ -327,6 +329,8 @@ class Tracks:
for i, at in enumerate(self.audio):
if not at.path or not at.path.exists():
raise ValueError("Audio Track must be downloaded before muxing...")
if callable(vt.OnMultiplex):
vt.OnMultiplex(vt)
cl.extend([
"--track-name", f"0:{at.get_track_name() or ''}",
"--language", "0:{}".format(LANGUAGE_MUX_MAP.get(
@ -342,6 +346,8 @@ class Tracks:
for st in self.subtitles:
if not st.path or not st.path.exists():
raise ValueError("Text Track must be downloaded before muxing...")
if callable(vt.OnMultiplex):
vt.OnMultiplex(vt)
default = bool(self.audio and is_close_match(st.language, [self.audio[0].language]) and st.forced)
cl.extend([
"--track-name", f"0:{st.get_track_name() or ''}",