summaryrefslogtreecommitdiff
path: root/plugins/artwork
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/artwork')
-rw-r--r--plugins/artwork/artwork.c4
-rw-r--r--plugins/artwork/lastfm.c15
2 files changed, 17 insertions, 2 deletions
diff --git a/plugins/artwork/artwork.c b/plugins/artwork/artwork.c
index 35bcbedb..5362a5df 100644
--- a/plugins/artwork/artwork.c
+++ b/plugins/artwork/artwork.c
@@ -1264,6 +1264,10 @@ get_album_art (const char *fname, const char *artist, const char *album, int siz
artist = "";
}
+ if (*album && !(*artist)) {
+ artist = album;
+ }
+
if (!*artist || !*album)
{
trace ("artist or album is empty, give up\n");
diff --git a/plugins/artwork/lastfm.c b/plugins/artwork/lastfm.c
index 63483406..83bda9cb 100644
--- a/plugins/artwork/lastfm.c
+++ b/plugins/artwork/lastfm.c
@@ -45,11 +45,17 @@ int
fetch_from_lastfm (const char *artist, const char *album, const char *dest)
{
char url [1024];
- char *artist_url = uri_escape (artist, 0);
- char *album_url = uri_escape (album, 0);
+ char *artist_url = NULL;
+ char *album_url = NULL;
+
+retry:
+ artist_url = uri_escape (artist, 0);
+ album_url = uri_escape (album, 0);
snprintf (url, sizeof (url), BASE_URL "?method=album.getinfo&api_key=" API_KEY "&artist=%s&album=%s", artist_url, album_url);
free (artist_url);
+ artist_url = NULL;
free (album_url);
+ album_url = NULL;
DB_FILE *fp = deadbeef->fopen (url);
if (!fp) {
@@ -78,6 +84,11 @@ fetch_from_lastfm (const char *artist, const char *album, const char *dest)
char *end = strstr (img, "</image>");
if (!end || end == img) {
+ if (artist != album) {
+ artist = album;
+ goto retry;
+ }
+
trace ("fetch_from_lastfm: bad xml (or image not found) from %s\n", url);
return -1;
}