core/tags/album: Fetch album art in the same step as metadata
This will help prepare for running multiple queries to find a release. Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
86b63298a5
commit
2ea5104d42
|
@ -23,34 +23,6 @@ static inline void __album_deinit_file(struct cache_file *f)
|
||||||
g_free(f->cf_name);
|
g_free(f->cf_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Mb5Metadata __album_query_releaseid(struct album *album,
|
|
||||||
Mb5Query *mb5)
|
|
||||||
{
|
|
||||||
gchar *param, *query = "query";
|
|
||||||
Mb5Metadata metadata = NULL;
|
|
||||||
tQueryResult result;
|
|
||||||
gchar error[256];
|
|
||||||
|
|
||||||
if (album->al_artist != NULL)
|
|
||||||
param = g_strdup_printf("release:\"%s\" AND artist:%s",
|
|
||||||
album->al_lower, album->al_artist->ar_lower);
|
|
||||||
else if (album->al_year != 0)
|
|
||||||
param = g_strdup_printf("release:\"%s\" AND date:%d",
|
|
||||||
album->al_lower, album->al_year);
|
|
||||||
else
|
|
||||||
param = g_strdup_printf("release:\"%s\"", album->al_lower);
|
|
||||||
|
|
||||||
metadata = mb5_query_query(mb5, "release", "", "", 1, &query, ¶m);
|
|
||||||
result = mb5_query_get_lastresult(mb5);
|
|
||||||
if (result != 0) {
|
|
||||||
mb5_query_get_lasterrormessage(mb5, error, sizeof(error));
|
|
||||||
g_printf("MusicBrainz: %s\n", error);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_free(param);
|
|
||||||
return metadata;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool __album_fetch_cover(struct album *album, gchar *releaseid,
|
static bool __album_fetch_cover(struct album *album, gchar *releaseid,
|
||||||
CaaCoverArt *caa)
|
CaaCoverArt *caa)
|
||||||
{
|
{
|
||||||
|
@ -101,9 +73,39 @@ static void __album_foreach_fetch(struct album *album, Mb5Metadata metadata)
|
||||||
caa_coverart_delete(caa);
|
caa_coverart_delete(caa);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void __album_query_releaseid(struct album *album, Mb5Query *mb5)
|
||||||
|
{
|
||||||
|
gchar *param, *query = "query";
|
||||||
|
Mb5Metadata metadata = NULL;
|
||||||
|
tQueryResult result;
|
||||||
|
gchar error[256];
|
||||||
|
|
||||||
|
if (album->al_artist != NULL)
|
||||||
|
param = g_strdup_printf("release:\"%s\" AND artist:%s",
|
||||||
|
album->al_name, album->al_artist->ar_lower);
|
||||||
|
else if (album->al_year != 0)
|
||||||
|
param = g_strdup_printf("release:\"%s\" AND date:%d",
|
||||||
|
album->al_name, album->al_year);
|
||||||
|
else
|
||||||
|
param = g_strdup_printf("release:\"%s\"", album->al_name);
|
||||||
|
|
||||||
|
metadata = mb5_query_query(mb5, "release", "", "", 1, &query, ¶m);
|
||||||
|
result = mb5_query_get_lastresult(mb5);
|
||||||
|
if (result != 0) {
|
||||||
|
mb5_query_get_lasterrormessage(mb5, error, sizeof(error));
|
||||||
|
g_printf("MusicBrainz: %s\n", error);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (metadata) {
|
||||||
|
__album_foreach_fetch(album, metadata);
|
||||||
|
mb5_metadata_delete(metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_free(param);
|
||||||
|
}
|
||||||
|
|
||||||
static bool __album_fetch_artwork(struct album *album)
|
static bool __album_fetch_artwork(struct album *album)
|
||||||
{
|
{
|
||||||
Mb5Metadata metadata;
|
|
||||||
Mb5Query *mb5;
|
Mb5Query *mb5;
|
||||||
bool ret;
|
bool ret;
|
||||||
|
|
||||||
|
@ -114,11 +116,7 @@ static bool __album_fetch_artwork(struct album *album)
|
||||||
if (!mb5)
|
if (!mb5)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
metadata = __album_query_releaseid(album, mb5);
|
__album_query_releaseid(album, mb5);
|
||||||
if (metadata) {
|
|
||||||
__album_foreach_fetch(album, metadata);
|
|
||||||
mb5_metadata_delete(metadata);
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = mb5_query_get_lasthttpcode(mb5) != 503;
|
ret = mb5_query_get_lasthttpcode(mb5) != 503;
|
||||||
mb5_query_delete(mb5);
|
mb5_query_delete(mb5);
|
||||||
|
|
Loading…
Reference in New Issue