]> git.parisson.com Git - telecaster-server.git/commitdiff
add is_processed check
authorGuillaume Pellerin <guillaume.pellerin@parisson.com>
Tue, 24 Dec 2024 10:58:48 +0000 (11:58 +0100)
committerGuillaume Pellerin <guillaume.pellerin@parisson.com>
Tue, 24 Dec 2024 10:58:48 +0000 (11:58 +0100)
bin/mastering/mastering.py

index 6cfe861b93d1b11b84662e3914a83b5e766cc010..d1323a05ab7c07d037c56cc9f86dfc7c889041f7 100755 (executable)
@@ -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: