]> git.0d.be Git - django-panik-emissions.git/commitdiff
create-sound-files: extend copy to all source formats
authorFrédéric Péters <fpeters@0d.be>
Fri, 27 Dec 2019 08:27:30 +0000 (09:27 +0100)
committerFrédéric Péters <fpeters@0d.be>
Fri, 27 Dec 2019 08:35:50 +0000 (09:35 +0100)
emissions/management/commands/create-sound-files.py

index d79aec838c58cafa33f44a6a66cf94d391502e9c..6e6fd9b0a6b823bb26070a806c1129b6b7036163 100644 (file)
@@ -40,7 +40,7 @@ class Command(BaseCommand):
             action='store_true',
             dest='copy',
             default=False,
-            help='Copy initial file (ogg only)')
+            help='Copy initial file')
 
     def handle(self, force, reset_metadata, copy, emission, episode, verbosity, **kwargs):
         self.verbose = (verbosity > 1)
@@ -76,10 +76,11 @@ class Command(BaseCommand):
 
         cmd = ['ffmpeg', '-y', '-i', soundfile.file.path]
 
+        if self.copy and os.path.splitext(soundfile.file.path)[-1].strip('.') == format:
+            shutil.copy(soundfile.file.path, file_path)
+            return
+
         if format == 'ogg':
-            if self.copy:
-                shutil.copy(soundfile.file.path, file_path)
-                return
             cmd.extend(['-q:a', '5'])
         elif format == 'mp3':
             cmd.extend(['-q:a', '4'])