From c9a1796e569797f4d7ab9c1d02e4910f90359cbd Mon Sep 17 00:00:00 2001 From: Ade Date: Sat, 15 Oct 2016 09:59:11 +1300 Subject: [PATCH] Allow hyphen in mb search Fixes #2499 --- headphones/mb.py | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/headphones/mb.py b/headphones/mb.py index 397e5008..faba6b8a 100644 --- a/headphones/mb.py +++ b/headphones/mb.py @@ -91,10 +91,6 @@ def findArtist(name, limit=1): artistlist = [] artistResults = None - chars = set('!?*-') - if any((c in chars) for c in name): - name = '"' + name + '"' - criteria = {'artist': name.lower()} with mb_lock: @@ -156,16 +152,13 @@ def findRelease(name, limit=1, artist=None): if not artist and ':' in name: name, artist = name.rsplit(":", 1) - chars = set('!?*-') - if any((c in chars) for c in name): - name = '"' + name + '"' - if artist and any((c in chars) for c in artist): - artist = '"' + artist + '"' + criteria = {'release': name.lower()} + if artist: + criteria['artist'] = artist.lower() with mb_lock: try: - releaseResults = musicbrainzngs.search_releases(query=name, limit=limit, artist=artist)[ - 'release-list'] + releaseResults = musicbrainzngs.search_releases(limit=limit, **criteria)['release-list'] except musicbrainzngs.WebServiceError as e: # need to update exceptions logger.warn('Attempt to query MusicBrainz for "%s" failed: %s' % (name, str(e))) mb_lock.snooze(5) @@ -234,10 +227,6 @@ def findSeries(name, limit=1): serieslist = [] seriesResults = None - chars = set('!?*-') - if any((c in chars) for c in name): - name = '"' + name + '"' - criteria = {'series': name.lower()} with mb_lock: @@ -759,19 +748,12 @@ def findArtistbyAlbum(name): def findAlbumID(artist=None, album=None): results = None - chars = set('!?*-') try: if album and artist: - if any((c in chars) for c in album): - album = '"' + album + '"' - if any((c in chars) for c in artist): - artist = '"' + artist + '"' criteria = {'release': album.lower()} criteria['artist'] = artist.lower() else: - if any((c in chars) for c in album): - album = '"' + album + '"' criteria = {'release': album.lower()} with mb_lock: results = musicbrainzngs.search_release_groups(limit=1, **criteria).get(