core/tags/album: Search with quotes around artist instead of album name

I think this results in a slightly better search, although there are
still a few wrong images fetched.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
Anna Schumaker 2016-07-11 08:05:33 -04:00
parent c8ccf7b844
commit df3436f68a
1 changed files with 23 additions and 10 deletions

View File

@ -77,16 +77,14 @@ static bool __album_foreach_fetch(struct album *album, Mb5Metadata metadata)
}
static bool __album_query_releaseid(struct album *album, Mb5Query *mb5,
gchar *extra)
gchar *param)
{
gchar *param, *query = "query";
Mb5Metadata metadata = NULL;
gchar *query = "query";
tQueryResult result;
gchar error[256];
bool ret = false;
param = g_strdup_printf("release:\"%s\" %s", album->al_name, extra);
do {
metadata = mb5_query_query(mb5, "release", "", "", 1, &query,
&param);
@ -102,22 +100,37 @@ static bool __album_query_releaseid(struct album *album, Mb5Query *mb5,
mb5_metadata_delete(metadata);
}
return ret;
}
static bool __album_query_name(struct album *album, Mb5Query *mb5,
gchar *extra, bool quotes)
{
gchar *fmt = "release:%s%s%s%s";
gchar *param = g_strdup_printf(fmt, quotes ? "\"" : "",
quotes ? album->al_name : album->al_lower,
quotes ? "\"" : "",
extra ? extra : "");
bool ret = __album_query_releaseid(album, mb5, param);
g_free(param);
g_free(extra);
return ret;
}
static bool __album_query_artist(struct album *album, Mb5Query *mb5)
{
gchar *fmt = "AND artist:%s";
gchar *fmt = " AND artist:\"%s\"";
gchar *param = g_strdup_printf(fmt, album->al_artist->ar_lower);
return __album_query_releaseid(album, mb5, param);
bool ret = __album_query_name(album, mb5, param, false);
g_free(param);
return ret;
}
static bool __album_query_year(struct album *album, Mb5Query *mb5)
{
gchar *param = g_strdup_printf("AND date:%d", album->al_year);
return __album_query_releaseid(album, mb5, param);
gchar *param = g_strdup_printf(" AND date:%d", album->al_year);
bool ret = __album_query_name(album, mb5, param, true);
g_free(param);
return ret;
}
static bool __album_fetch_artwork(struct album *album)
@ -135,7 +148,7 @@ static bool __album_fetch_artwork(struct album *album)
goto out;
if (album->al_year && __album_query_year(album, mb5))
goto out;
__album_query_releaseid(album, mb5, g_strdup(""));
__album_query_name(album, mb5, NULL, true);
out:
mb5_query_delete(mb5);