From 99b51f5257e49a531bb398684da23a3d9495136f Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Mon, 11 Jul 2016 09:43:01 -0400 Subject: [PATCH] core/tags/album: Make quotes around artist name configurable This allows me to search for `"release" AND artist` but also `release AND "artist"` Signed-off-by: Anna Schumaker --- core/tags/album.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/core/tags/album.c b/core/tags/album.c index 2759d547..778c4269 100644 --- a/core/tags/album.c +++ b/core/tags/album.c @@ -104,23 +104,26 @@ static bool __album_query_releaseid(struct album *album, Mb5Query *mb5, } static bool __album_query_name(struct album *album, Mb5Query *mb5, - gchar *extra, bool quotes) + gchar *extra, bool quoted) { gchar *fmt = "release:%s%s%s%s"; - gchar *param = g_strdup_printf(fmt, quotes ? "\"" : "", - quotes ? album->al_name : album->al_lower, - quotes ? "\"" : "", + gchar *param = g_strdup_printf(fmt, quoted ? "\"" : "", + quoted ? album->al_name : album->al_lower, + quoted ? "\"" : "", extra ? extra : ""); bool ret = __album_query_releaseid(album, mb5, param); g_free(param); return ret; } -static bool __album_query_artist(struct album *album, Mb5Query *mb5) +static bool __album_query_artist(struct album *album, Mb5Query *mb5, bool quoted) { - gchar *fmt = " AND artist:\"%s\""; - gchar *param = g_strdup_printf(fmt, album->al_artist->ar_lower); - bool ret = __album_query_name(album, mb5, param, false); + struct artist *artist = album->al_artist; + gchar *fmt = " AND artist:%s%s%s"; + gchar *param = g_strdup_printf(fmt, quoted ? "\"" : "", + quoted ? artist->ar_name : artist->ar_lower, + quoted ? "\"" : ""); + bool ret = __album_query_name(album, mb5, param, !quoted); g_free(param); return ret; } @@ -144,7 +147,9 @@ static bool __album_fetch_artwork(struct album *album) if (!mb5) return false; - if (album->al_artist && __album_query_artist(album, mb5)) + if (album->al_artist && __album_query_artist(album, mb5, false)) + goto out; + if (album->al_artist && __album_query_artist(album, mb5, true)) goto out; if (album->al_year && __album_query_year(album, mb5)) goto out;