From fe320e177da4776306228d306d4f0be37098619a Mon Sep 17 00:00:00 2001 From: rlaphoenix Date: Sat, 25 Feb 2023 21:58:32 +0000 Subject: [PATCH] Add OnMultiplex event, for pre-multiplex --- devine/core/tracks/track.py | 1 + devine/core/tracks/tracks.py | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/devine/core/tracks/track.py b/devine/core/tracks/track.py index c3ac1be..c79c51d 100644 --- a/devine/core/tracks/track.py +++ b/devine/core/tracks/track.py @@ -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 diff --git a/devine/core/tracks/tracks.py b/devine/core/tracks/tracks.py index 21d596c..b285f57 100644 --- a/devine/core/tracks/tracks.py +++ b/devine/core/tracks/tracks.py @@ -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 ''}",