From ba0605d2fc63b947fb3dcc0712056a6a125131a9 Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Tue, 24 Dec 2024 11:58:48 +0100 Subject: [PATCH] add is_processed check --- bin/mastering/mastering.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/bin/mastering/mastering.py b/bin/mastering/mastering.py index 6cfe861..d1323a0 100755 --- a/bin/mastering/mastering.py +++ b/bin/mastering/mastering.py @@ -88,7 +88,7 @@ class TeleCasterMastering(object): exts.append(ext) return extension in exts - def get_offset(self, within_file, find_file, window=10): + def get_offset(self, within_file, find_file, window=10): y_within, sr_within = librosa.load(within_file, sr=None, duration=60.0) y_find, _ = librosa.load(find_file, sr=sr_within, duration=60.0) c = signal.correlate(y_within, y_find[:sr_within*window], mode='valid', method='fft') @@ -160,6 +160,14 @@ class TeleCasterMastering(object): if not self.dry_run_mode: os.system(command) + def is_processed(self, source_files): + processed = False + for file in source_files: + filename, ext = os.path.splitext(file) + if ext[1:] == "log": + processed = True + return processed + def run(self): for root, dirs, files in os.walk(self.root_dir): if not dirs: @@ -179,7 +187,9 @@ class TeleCasterMastering(object): if source_files: offsets = {} - if len(source_files) > 1 and self.auto_offset_mode: + is_processed = self.is_processed(source_files) + + if len(source_files) > 1 and self.auto_offset_mode and (not is_processed or self.force_mode): date_file = datetime.datetime.fromtimestamp(os.path.getmtime(source_files[0])) if date_file >= self.date_limit and self.date_filter: offsets = self.find_best_offset(source_files) @@ -188,8 +198,10 @@ class TeleCasterMastering(object): path = os.path.abspath(file) filename, ext = os.path.splitext(file) ext = ext[1:] - date_dir = datetime.datetime.fromtimestamp(os.path.getmtime(file)) - if ext in self.source_formats and (date_dir >= self.date_limit and self.date_filter): + date_dir = datetime.datetime.fromtimestamp(os.path.getmtime(file))² + if ext in self.source_formats and \ + (date_dir >= self.date_limit and self.date_filter) and \ + (not is_processed or self.force_mode): if ext == "webm": self.remux(file) if not self.remux_only_mode: -- 2.39.5