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)))
- soundfile.save()
+ 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)))
+ soundfile.save()
+ break
def create(self, soundfile, format):