# Buggy code
def convert_item(self, dest_dir, keep_new, path_formats, format, pretend=False):
    command, ext = get_format(format)
    item, original, converted = None, None, None
    while True:
        item = yield (item, original, converted)
        dest = item.destination(basedir=dest_dir, path_formats=path_formats)

        # When keeping the new file in the library, we first move the
        # current (pristine) file to the destination. We'll then copy it
        # back to its old path or transcode it to a new path.
        if keep_new:
            original = dest
            converted = item.path
            if should_transcode(item, format):
                converted = replace_ext(converted, ext)
        else:
            original = item.path
            if should_transcode(item, format):
                dest = replace_ext(dest, ext)
            converted = dest

        # Ensure that only one thread tries to create directories at a
        # time. (The existence check is not atomic with the directory
        # creation inside this function.)
        if not pretend:
            with _fs_lock:
                util.mkdirall(dest)

        if os.path.exists(util.syspath(dest)):
            self._log.info(
                "Skipping {0} (target file exists)", util.displayable_path(item.path)
            )
            continue

        if keep_new:
            if pretend:
                self._log.info(
                    "mv {0} {1}",
                    util.displayable_path(item.path),
                    util.displayable_path(original),
                )
            else:
                self._log.info("Moving to {0}", util.displayable_path(original))
                util.move(item.path, original)

        if should_transcode(item, format):
            try:
                self.encode(command, original, converted, pretend)
            except subprocess.CalledProcessError:
                continue
        else:
            if pretend:
                self._log.info(
                    "cp {0} {1}",
                    util.displayable_path(original),
                    util.displayable_path(converted),
                )
            else:
                # No transcoding necessary.
                self._log.info("Copying {0}", util.displayable_path(item.path))
                util.copy(original, converted)

        if pretend:
            continue

        # Write tags from the database to the converted file.
        item.try_write(path=converted)

        if keep_new:
            # If we're keeping the transcoded file, read it again (after
            # writing) to get new bitrate, duration, etc.
            item.path = converted
            item.read()
            item.store()  # Store new path and audio data.

        if self.config["embed"]:
            album = item.get_album()
            if album and album.artpath:
                EmbedCoverArtPlugin().embed_item(
                    item, album.artpath, itempath=converted
                )

        if keep_new:
            plugins.send("after_convert", item=item, dest=dest, keepnew=True)
        else:
            plugins.send("after_convert", item=item, dest=converted, keepnew=False)


# Traceback (TypeError)
C:\Users\100557855>beet duplicates
Traceback (most recent call last):
File "C:\Python27\Scripts\beet-script.py", line 9, in <module>
load_entry_point('beets==1.3.11', 'console_scripts', 'beet')()
File "c:\users\100557855\src\beets\beets\ui\__init__.py", line 953, in main
_raw_main(args)
File "c:\users\100557855\src\beets\beets\ui\__init__.py", line 943, in _raw_ma
in
subcommand.func(lib, suboptions, subargs)
File "c:\users\100557855\src\beets\beetsplug\duplicates.py", line 232, in _dup

format=fmt.format(obj_count))
File "c:\users\100557855\src\beets\beetsplug\duplicates.py", line 48, in _proc
ess_item
print_(format(item, format))
TypeError: 'unicode' object is not callable

# Fixed code
def convert_item(self, dest_dir, keep_new, path_formats, fmt, pretend=False):
    command, ext = get_format(fmt)
    item, original, converted = None, None, None
    while True:
        item = yield (item, original, converted)
        dest = item.destination(basedir=dest_dir, path_formats=path_formats)

        # When keeping the new file in the library, we first move the
        # current (pristine) file to the destination. We'll then copy it
        # back to its old path or transcode it to a new path.
        if keep_new:
            original = dest
            converted = item.path
            if should_transcode(item, fmt):
                converted = replace_ext(converted, ext)
        else:
            original = item.path
            if should_transcode(item, fmt):
                dest = replace_ext(dest, ext)
            converted = dest

        # Ensure that only one thread tries to create directories at a
        # time. (The existence check is not atomic with the directory
        # creation inside this function.)
        if not pretend:
            with _fs_lock:
                util.mkdirall(dest)

        if os.path.exists(util.syspath(dest)):
            self._log.info(
                "Skipping {0} (target file exists)", util.displayable_path(item.path)
            )
            continue

        if keep_new:
            if pretend:
                self._log.info(
                    "mv {0} {1}",
                    util.displayable_path(item.path),
                    util.displayable_path(original),
                )
            else:
                self._log.info("Moving to {0}", util.displayable_path(original))
                util.move(item.path, original)

        if should_transcode(item, fmt):
            try:
                self.encode(command, original, converted, pretend)
            except subprocess.CalledProcessError:
                continue
        else:
            if pretend:
                self._log.info(
                    "cp {0} {1}",
                    util.displayable_path(original),
                    util.displayable_path(converted),
                )
            else:
                # No transcoding necessary.
                self._log.info("Copying {0}", util.displayable_path(item.path))
                util.copy(original, converted)

        if pretend:
            continue

        # Write tags from the database to the converted file.
        item.try_write(path=converted)

        if keep_new:
            # If we're keeping the transcoded file, read it again (after
            # writing) to get new bitrate, duration, etc.
            item.path = converted
            item.read()
            item.store()  # Store new path and audio data.

        if self.config["embed"]:
            album = item.get_album()
            if album and album.artpath:
                EmbedCoverArtPlugin().embed_item(
                    item, album.artpath, itempath=converted
                )

        if keep_new:
            plugins.send("after_convert", item=item, dest=dest, keepnew=True)
        else:
            plugins.send("after_convert", item=item, dest=converted, keepnew=False)