From a091f9e71a5da2509d07db01796b7674d7e8780c Mon Sep 17 00:00:00 2001 From: multikatt Date: Fri, 15 May 2015 13:25:50 -0400 Subject: [PATCH] Add support for naming remote libraries --- beetsplug/ipfs.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/beetsplug/ipfs.py b/beetsplug/ipfs.py index ffb70d63c..2d0ba04f8 100644 --- a/beetsplug/ipfs.py +++ b/beetsplug/ipfs.py @@ -121,14 +121,19 @@ class IPFSPlugin(BeetsPlugin): stdout=subprocess.PIPE) self._log.info("hash of library: {0}", _proc.stdout.readline()) - def ipfs_import(self, lib, _hash): + def ipfs_import(self, lib, args): + _hash = args[0] + if len(args) > 1: + lib_name = args[1] + else: + lib_name = _hash # TODO: should be able to tag libraries, for example by nicks lib_root = os.path.dirname(lib.path) remote_libs = lib_root + "/remotes" if not os.path.exists(remote_libs): os.makedirs(remote_libs) - path = remote_libs + "/" + _hash[0] + ".db" - subprocess.call(["ipfs", "get", _hash[0], "-o", path]) + path = remote_libs + "/" + lib_name + ".db" + subprocess.call(["ipfs", "get", _hash, "-o", path]) # add all albums from remotes into a combined library jpath = remote_libs + "/joined.db"