Commit 64439ffa authored by fred's avatar fred

create-sound-files: add --link option

parent 8cd6233b
......@@ -45,10 +45,16 @@ class Command(BaseCommand):
dest='copy',
default=False,
help='Copy initial file')
parser.add_argument('--link',
action='store_true',
dest='link',
default=False,
help='Link initial file')
def handle(self, force, reset_metadata, copy, emission, episode, verbosity, formats, **kwargs):
def handle(self, force, reset_metadata, copy, link, emission, episode, verbosity, formats, **kwargs):
self.verbose = (verbosity > 1)
self.copy = copy
self.link = link
for soundfile in SoundFile.objects.select_related().exclude(podcastable=False):
if emission and soundfile.episode.emission.slug != emission:
......@@ -78,12 +84,15 @@ class Command(BaseCommand):
if not os.path.exists(os.path.dirname(file_path)):
os.mkdir(os.path.dirname(file_path))
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 self.link and os.path.splitext(soundfile.file.path)[-1].strip('.') == format:
os.symlink(soundfile.file.path, file_path)
return
cmd = ['ffmpeg', '-y', '-i', soundfile.file.path]
if format == 'ogg':
cmd.extend(['-q:a', '5'])
elif format == 'mp3':
......
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