Commit a95a4ddb authored by fred's avatar fred

create-sound-files: compute duration from mp3 if it's the only format

parent c927514c
......@@ -73,10 +73,14 @@ class Command(BaseCommand):
created = self.create(soundfile, format)
if created or reset_metadata:
self.set_metadata(soundfile, format)
if (force or not soundfile.duration) and os.path.exists(soundfile.get_format_path('ogg')):
cmd = ['soxi', '-D', soundfile.get_format_path('ogg')]
soundfile.duration = int(float(subprocess.check_output(cmd)))
if (force or not soundfile.duration):
for extension in ('ogg', 'mp3'):
soundfile_name = soundfile.get_format_path(extension)
if os.path.exists(soundfile_name):
cmd = ['soxi', '-D', soundfile_name]
soundfile.duration = int(float(subprocess.check_output(cmd)))
def create(self, soundfile, format):
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment