From d1af78455dfab9e371770228191e28ed8386bd2f Mon Sep 17 00:00:00 2001 From: kaliko Date: Fri, 18 Jun 2021 12:38:06 +0200 Subject: [PATCH] Fixed double quote error, missing escape character (Closes #52) --- sima/lib/meta.py | 4 ++-- sima/mpdclient.py | 4 ---- tests/test_meta.py | 7 +++++++ 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/sima/lib/meta.py b/sima/lib/meta.py index e6b9f46..9e858a2 100644 --- a/sima/lib/meta.py +++ b/sima/lib/meta.py @@ -61,8 +61,8 @@ def serialize(func): def wrapper(*args, **kwargs): ans = func(*args, **kwargs) if isinstance(ans, set): - return {s.replace("'", r"\'") for s in ans} - return ans.replace("'", r"\'") + return {s.replace("'", r"\'").replace('"', r'\"') for s in ans} + return ans.replace("'", r"\'").replace('"', r'\"') return wrapper diff --git a/sima/mpdclient.py b/sima/mpdclient.py index 6b5b976..45d3dcd 100644 --- a/sima/mpdclient.py +++ b/sima/mpdclient.py @@ -365,15 +365,11 @@ class MPD(MPDClient): # #### Search Methods ##### def _find_musicbrainz_artistid(self, artist): """Find MusicBrainzArtistID when possible. - For artist with aliases having a mbid but not the main name, no mbid is - fetched… - Searching for Artist('Russian Circls') do not reslove the MBID """ if not self.use_mbid: return None mbids = None for name in artist.names_sz: - self.log.debug(name) filt = f'((artist == "{name}") AND (MUSICBRAINZ_ARTISTID != ""))' mbids = self.list('MUSICBRAINZ_ARTISTID', filt) if mbids: diff --git a/tests/test_meta.py b/tests/test_meta.py index aefd339..b8a36b5 100644 --- a/tests/test_meta.py +++ b/tests/test_meta.py @@ -125,6 +125,13 @@ class TestMetaObject(unittest.TestCase): self.assertEqual(heavens_door.name_sz, target) heavens_door = Artist(name=name) self.assertEqual(heavens_door.name_sz, target) + # Same with double quote + name = 'Bonnie "Prince" Billy' + bonnie = Meta(name=name) + target = r"Bonnie \"Prince\" Billy" + self.assertEqual(bonnie.name_sz, target) + self.assertEqual(bonnie.name, name) + class TestArtistObject(unittest.TestCase): -- 2.39.5