From e3edb04cb653c12215e1f86c922474434e9490a1 Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Thu, 6 Aug 2026 10:38:53 +0200 Subject: [PATCH] exception for setting media duration --- teleforma/models/core.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) 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' -- 2.47.3