From: Guillaume Pellerin Date: Thu, 6 Aug 2026 08:38:53 +0000 (+0200) Subject: exception for setting media duration X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=e3edb04cb653c12215e1f86c922474434e9490a1;p=teleforma.git exception for setting media duration --- diff --git a/teleforma/models/core.py b/teleforma/models/core.py index b6398a6c..03767df6 100644 --- a/teleforma/models/core.py +++ b/teleforma/models/core.py @@ -1157,12 +1157,18 @@ class Media(MediaBase): return None def set_duration(self): - result = subprocess.run(["ffprobe", "-v", "error", "-show_entries", - "format=duration", "-of", - "default=noprint_wrappers=1:nokey=1", self.file.path], - stdout=subprocess.PIPE, - stderr=subprocess.STDOUT) - self.duration = datetime.timedelta(days=0, seconds=float(result.stdout)) + if self.file: + if os.path.exists(self.file.path): + try: + result = subprocess.run(["ffprobe", "-v", "error", "-show_entries", + "format=duration", "-of", + "default=noprint_wrappers=1:nokey=1", self.file.path], + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT) + self.duration = datetime.timedelta(days=0, seconds=float(result.stdout)) + except: + logger.info("failed to set duration of media.id: " + str(self.id)) + continue class Meta(MetaCore): db_table = app_label + '_' + 'media'