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:
parent
c8ccf7b844
commit
df3436f68a
|
@ -77,16 +77,14 @@ static bool __album_foreach_fetch(struct album *album, Mb5Metadata metadata)
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool __album_query_releaseid(struct album *album, Mb5Query *mb5,
|
static bool __album_query_releaseid(struct album *album, Mb5Query *mb5,
|
||||||
gchar *extra)
|
gchar *param)
|
||||||
{
|
{
|
||||||
gchar *param, *query = "query";
|
|
||||||
Mb5Metadata metadata = NULL;
|
Mb5Metadata metadata = NULL;
|
||||||
|
gchar *query = "query";
|
||||||
tQueryResult result;
|
tQueryResult result;
|
||||||
gchar error[256];
|
gchar error[256];
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
|
||||||
param = g_strdup_printf("release:\"%s\" %s", album->al_name, extra);
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
metadata = mb5_query_query(mb5, "release", "", "", 1, &query,
|
metadata = mb5_query_query(mb5, "release", "", "", 1, &query,
|
||||||
¶m);
|
¶m);
|
||||||
|
@ -102,22 +100,37 @@ static bool __album_query_releaseid(struct album *album, Mb5Query *mb5,
|
||||||
mb5_metadata_delete(metadata);
|
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(param);
|
||||||
g_free(extra);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool __album_query_artist(struct album *album, Mb5Query *mb5)
|
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);
|
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)
|
static bool __album_query_year(struct album *album, Mb5Query *mb5)
|
||||||
{
|
{
|
||||||
gchar *param = g_strdup_printf("AND date:%d", album->al_year);
|
gchar *param = g_strdup_printf(" AND date:%d", album->al_year);
|
||||||
return __album_query_releaseid(album, mb5, param);
|
bool ret = __album_query_name(album, mb5, param, true);
|
||||||
|
g_free(param);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool __album_fetch_artwork(struct album *album)
|
static bool __album_fetch_artwork(struct album *album)
|
||||||
|
@ -135,7 +148,7 @@ static bool __album_fetch_artwork(struct album *album)
|
||||||
goto out;
|
goto out;
|
||||||
if (album->al_year && __album_query_year(album, mb5))
|
if (album->al_year && __album_query_year(album, mb5))
|
||||||
goto out;
|
goto out;
|
||||||
__album_query_releaseid(album, mb5, g_strdup(""));
|
__album_query_name(album, mb5, NULL, true);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
mb5_query_delete(mb5);
|
mb5_query_delete(mb5);
|
||||||
|
|
Loading…
Reference in New Issue