'Transcode a file automatically after it is imported into the
library.'

def convert_on_import(self, lib, item):

    fmt = self.config['format'].as_str().lower()
    if should_transcode(item, fmt):
        (command, ext) = get_format()
        tmpdir = self.config['tmpdir'].get()
        if tmpdir:
            tmpdir = util.py3_path(util.bytestring_path(tmpdir))
        (fd, dest) = tempfile.mkstemp(util.py3_path(('.' + ext)), dir=tmpdir)
        os.close(fd)
        dest = util.bytestring_path(dest)
        _temp_files.append(dest)
        try:
            self.encode(command, item.path, dest)
        except subprocess.CalledProcessError:
            return
        item.path = dest
        item.write()
        item.read()
        item.store()
