Example #1
0
    def process_conversion(self):
        for song in self.files_to_convert:
            current_format = ".{}".format(song.rsplit('.', 1)[-1])

            old_file = '{}{}{}'.format(self.target_dir, os.sep, song)
            new_file = '{}{}{}'.format(self.target_dir, os.sep,
                                       song.replace(current_format, '.mp3'))

            message = "Converting {} to 'mp3' format...".format(old_file)
            Executor.print_utf(message)

            avconv_call = ["avconv", "-i",
                           old_file.replace(' ', '\ ').replace('|', '\|'),
                           new_file.replace(' ', '\ ').replace('|', '\|')]
            if Executor.execute(avconv_call):
                message = 'Deleting {}'.format(old_file)
                Executor.print_utf(message)
                Executor.execute(["rm", old_file])