def ipfs_import(self, lib, args):
        _hash = args[0]
        if len(args) > 1:
            lib_name = args[1]
        else:
            lib_name = _hash
        lib_root = os.path.dirname(lib.path)
        remote_libs = lib_root + "/remotes"
        if not os.path.exists(remote_libs):
            try:
                os.makedirs(remote_libs)
            except OSError as e:
                msg = "Could not create {0}. Error: {1}".format(remote_libs, e)
                self._log.error(msg)
                return False
        path = remote_libs + "/" + lib_name + ".db"
        if not os.path.exists(path):
            cmd = "ipfs get {0} -o".format(_hash).split()
            cmd.append(path)
            try:
                util.command_output(cmd)
            except (OSError, subprocess.CalledProcessError):
                self._log.error("Could not import {0}".format(_hash))
                return False

        # add all albums from remotes into a combined library
        jpath = remote_libs + "/joined.db"
        jlib = library.Library(jpath)
        nlib = library.Library(path)
        for album in nlib.albums():
            if not self.already_added(album, jlib):
                new_album = []
                for item in album.items():
                    item.id = None
                    new_album.append(item)
                added_album = jlib.add_album(new_album)
                added_album.ipfs = album.ipfs
                added_album.store()
dataset/ETHPy150Open beetbox/beets/beetsplug/ipfs.py/IPFSPlugin.ipfs_import/original