core/tags/album: Improve MusicBrainz query accuracy
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
4f1f76b764
commit
9928c3239f
|
@ -112,40 +112,42 @@ static bool __album_run_query(struct album *album, gchar *term1,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool __album_query_artist(struct album *album, struct artist *al_artist)
|
||||||
|
{
|
||||||
|
gchar *release, *artist, *year;
|
||||||
|
bool found;
|
||||||
|
|
||||||
|
if (!al_artist || strncmp(al_artist->ar_lower, "various", 7) == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
release = g_strdup_printf("release:\"%s\"~", album->al_lower);
|
||||||
|
artist = g_strdup_printf("artist:\"%s\"~", al_artist->ar_name);
|
||||||
|
year = g_strdup_printf("date:%d*", album->al_year);
|
||||||
|
|
||||||
|
if (album->al_year > 0)
|
||||||
|
found = __album_run_query(album, release, artist, year);
|
||||||
|
if (!found)
|
||||||
|
found = __album_run_query(album, release, artist, NULL);
|
||||||
|
if (!found && album->al_year > 0)
|
||||||
|
found = __album_run_query(album, album->al_lower, artist, year);
|
||||||
|
if (!found)
|
||||||
|
found = __album_run_query(album, album->al_lower, artist, NULL);
|
||||||
|
|
||||||
|
g_free(release);
|
||||||
|
g_free(artist);
|
||||||
|
g_free(year);
|
||||||
|
return found;
|
||||||
|
}
|
||||||
|
|
||||||
static bool __album_fetch_artwork(struct album *album)
|
static bool __album_fetch_artwork(struct album *album)
|
||||||
{
|
{
|
||||||
struct artist *artist = album->al_artist;
|
|
||||||
gchar *terms[4] = {NULL, NULL, NULL, NULL};
|
|
||||||
unsigned int i = 0;
|
|
||||||
|
|
||||||
if (album_artwork_exists(album))
|
if (album_artwork_exists(album))
|
||||||
return true;
|
return true;
|
||||||
if (string_length(album->al_name) == 0)
|
if (string_length(album->al_name) == 0)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
terms[i++] = g_strdup_printf("release:\"%s\"~", album->al_lower);
|
if (!__album_query_artist(album, album->al_artist))
|
||||||
if (artist && strncmp(artist->ar_lower, "various", 7) != 0)
|
__album_run_query(album, album->al_lower, NULL, NULL);
|
||||||
terms[i++] = g_strdup_printf("artist:\"%s\"~", artist->ar_name);
|
|
||||||
if (album->al_year > 0)
|
|
||||||
terms[i++] = g_strdup_printf("date:%d*", album->al_year);
|
|
||||||
|
|
||||||
if (terms[2]) {
|
|
||||||
if (__album_run_query(album, terms[0], terms[1], terms[2]))
|
|
||||||
goto out;
|
|
||||||
if (__album_run_query(album, terms[0], terms[2], NULL))
|
|
||||||
goto out;
|
|
||||||
if (__album_run_query(album, terms[1], terms[2], NULL))
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (terms[1] && __album_run_query(album, terms[0], terms[1], NULL))
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
__album_run_query(album, terms[0], NULL, NULL);
|
|
||||||
|
|
||||||
out:
|
|
||||||
for (i = 0; terms[i]; i++)
|
|
||||||
g_free(terms[i]);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue