mirror of
https://github.com/beetbox/beets.git
synced 2025-12-06 08:39:17 +01:00
bugfix: Python3ify the IPFS plugin
Paths were being constructed in a Python 3-incompatible way by concating bytes and strings. Do this more carefully by encoding and decoding of binary and strings.
This commit is contained in:
parent
09ea5448f1
commit
ca8c557840
2 changed files with 7 additions and 6 deletions
|
|
@ -190,7 +190,7 @@ class IPFSPlugin(BeetsPlugin):
|
||||||
else:
|
else:
|
||||||
lib_name = _hash
|
lib_name = _hash
|
||||||
lib_root = os.path.dirname(lib.path)
|
lib_root = os.path.dirname(lib.path)
|
||||||
remote_libs = lib_root + "/remotes"
|
remote_libs = os.path.join(lib_root, b"remotes")
|
||||||
if not os.path.exists(remote_libs):
|
if not os.path.exists(remote_libs):
|
||||||
try:
|
try:
|
||||||
os.makedirs(remote_libs)
|
os.makedirs(remote_libs)
|
||||||
|
|
@ -198,7 +198,7 @@ class IPFSPlugin(BeetsPlugin):
|
||||||
msg = "Could not create {0}. Error: {1}".format(remote_libs, e)
|
msg = "Could not create {0}. Error: {1}".format(remote_libs, e)
|
||||||
self._log.error(msg)
|
self._log.error(msg)
|
||||||
return False
|
return False
|
||||||
path = remote_libs + "/" + lib_name + ".db"
|
path = os.path.join(remote_libs, lib_name.encode() + b".db")
|
||||||
if not os.path.exists(path):
|
if not os.path.exists(path):
|
||||||
cmd = "ipfs get {0} -o".format(_hash).split()
|
cmd = "ipfs get {0} -o".format(_hash).split()
|
||||||
cmd.append(path)
|
cmd.append(path)
|
||||||
|
|
@ -209,7 +209,7 @@ class IPFSPlugin(BeetsPlugin):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# add all albums from remotes into a combined library
|
# add all albums from remotes into a combined library
|
||||||
jpath = remote_libs + "/joined.db"
|
jpath = os.path.join(remote_libs, b"joined.db")
|
||||||
jlib = library.Library(jpath)
|
jlib = library.Library(jpath)
|
||||||
nlib = library.Library(path)
|
nlib = library.Library(path)
|
||||||
for album in nlib.albums():
|
for album in nlib.albums():
|
||||||
|
|
@ -237,7 +237,7 @@ class IPFSPlugin(BeetsPlugin):
|
||||||
return
|
return
|
||||||
|
|
||||||
for album in albums:
|
for album in albums:
|
||||||
ui.print_(format(album, fmt), " : ", album.ipfs)
|
ui.print_(format(album, fmt), " : ", album.ipfs.decode())
|
||||||
|
|
||||||
def query(self, lib, args):
|
def query(self, lib, args):
|
||||||
rlib = self.get_remote_lib(lib)
|
rlib = self.get_remote_lib(lib)
|
||||||
|
|
@ -246,8 +246,8 @@ class IPFSPlugin(BeetsPlugin):
|
||||||
|
|
||||||
def get_remote_lib(self, lib):
|
def get_remote_lib(self, lib):
|
||||||
lib_root = os.path.dirname(lib.path)
|
lib_root = os.path.dirname(lib.path)
|
||||||
remote_libs = lib_root + "/remotes"
|
remote_libs = os.path.join(lib_root, b"remotes")
|
||||||
path = remote_libs + "/joined.db"
|
path = os.path.join(remote_libs, b"joined.db")
|
||||||
if not os.path.isfile(path):
|
if not os.path.isfile(path):
|
||||||
raise IOError
|
raise IOError
|
||||||
return library.Library(path)
|
return library.Library(path)
|
||||||
|
|
|
||||||
|
|
@ -102,6 +102,7 @@ Fixes:
|
||||||
error message. Thanks to :user:`Mary011196`. :bug:`1676` :bug:`2508`
|
error message. Thanks to :user:`Mary011196`. :bug:`1676` :bug:`2508`
|
||||||
* :doc:`/plugins/web`: Avoid a crash when sending binary data, such as
|
* :doc:`/plugins/web`: Avoid a crash when sending binary data, such as
|
||||||
Chromaprint fingerprints, in music attributes. :bug:`2542` :bug:`2532`
|
Chromaprint fingerprints, in music attributes. :bug:`2542` :bug:`2532`
|
||||||
|
* :doc:`/plugins/ipfs`: Fix Python 3 compatibility.
|
||||||
|
|
||||||
Two plugins had backends removed due to bitrot:
|
Two plugins had backends removed due to bitrot:
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue