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 <Anna@OcarinaProject.net>
This commit is contained in:
Anna Schumaker 2016-07-11 09:43:01 -04:00
parent df3436f68a
commit 99b51f5257
1 changed files with 14 additions and 9 deletions

View File

@ -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;