Commit f650277f authored by fred's avatar fred

management: also compute durations of non-podcastable files

parent cad17f07
......@@ -56,7 +56,7 @@ class Command(BaseCommand):
self.copy = copy
self.link = link
for soundfile in SoundFile.objects.select_related().exclude(podcastable=False):
for soundfile in SoundFile.objects.select_related():
if emission and soundfile.episode.emission.slug != emission:
continue
if episode and soundfile.episode.slug != episode:
......@@ -66,6 +66,17 @@ class Command(BaseCommand):
continue
except ValueError: # no file associated with it
continue
if not soundfile.podcastable:
# get duration using initial file
if not soundfile.duration:
cmd = ['soxi', '-D', soundfile.file.path]
try:
soundfile.duration = int(float(subprocess.check_output(cmd)))
except (ValueError, subprocess.CalledProcessError):
pass
else:
soundfile.save()
continue
for format in formats.split(','):
file_path = soundfile.get_format_path(format)
created = False
......
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