]> git.parisson.com Git - teleforma.git/commitdiff
fix no duration
authorGuillaume Pellerin <yomguy@parisson.com>
Tue, 30 Dec 2014 21:29:34 +0000 (22:29 +0100)
committerGuillaume Pellerin <yomguy@parisson.com>
Tue, 30 Dec 2014 21:29:34 +0000 (22:29 +0100)
teleforma/management/commands/teleforma-import-seminar-media.py

index 442b0efcc6a8e542632421af3a1795d65df05580..727198420551bea7db06c876d0373069dcba8248 100644 (file)
@@ -78,13 +78,16 @@ class Command(BaseCommand):
             self.delete_media(preview)
 
     def get_duration(self, file):
-        decoder = timeside.decoder.FileDecoder(file)
-        decoder.setup()
-        # time.sleep(0.5)
-        value = str(datetime.timedelta(0,decoder.input_duration))
-        t = value.split(':')
-        t[2] = t[2].split('.')[0]
-        return ':'.join(t)
+        try:
+            decoder = timeside.decoder.FileDecoder(file)
+            decoder.setup()
+            # time.sleep(0.5)
+            value = str(datetime.timedelta(0,decoder.input_duration))
+            t = value.split(':')
+            t[2] = t[2].split('.')[0]
+            return ':'.join(t)
+        except:
+            return '0:0:0'
 
     def get_item(self, collection, id):
         items = MediaItem.objects.filter(collection=collection, code=id)