From 4e577df50508fb1c2ad9cc2c4b8e233f4dc8834b Mon Sep 17 00:00:00 2001 From: Craig Drummond Date: Thu, 5 Nov 2015 21:26:35 +0000 Subject: [PATCH] Fix context widget backdrop retrieval from fan-art --- ChangeLog | 2 +- context/contextwidget.cpp | 36 +++++++++++++++++++++++++++--------- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index eaa72654c..31d48bc19 100644 --- a/ChangeLog +++ b/ChangeLog @@ -75,7 +75,7 @@ 53. Fix starting Cantata maximised. 54. Ignore 'The' (if configured) when sorting play queue. 55. No longer using discogs - API has changed. - +56. Fix context widget backdrop retrieval from fan-art 1.5.2 ----- 1. Fix Ubuntu Touch builds. diff --git a/context/contextwidget.cpp b/context/contextwidget.cpp index 542184ad2..4108d2c3d 100644 --- a/context/contextwidget.cpp +++ b/context/contextwidget.cpp @@ -861,7 +861,18 @@ void ContextWidget::musicbrainzResponse() getMusicbrainzId(artist); } } else { - QUrl url("http://api.fanart.tv/webservice/artist/"+constFanArtApiKey+"/"+id+"/json/artistbackground/1"); + QUrl url("http://webservice.fanart.tv/v3/music/"+id); + #if QT_VERSION < 0x050000 + QUrl &query=url; + #else + QUrlQuery query; + #endif + + query.addQueryItem("api_key", constFanArtApiKey); + #if QT_VERSION >= 0x050000 + url.setQuery(query); + #endif + job=NetworkAccessManager::self()->get(url); DBUG << url.toString(); connect(job, SIGNAL(finished()), this, SLOT(fanArtResponse())); @@ -889,14 +900,21 @@ void ContextWidget::fanArtResponse() #endif if (ok && !parsed.isEmpty()) { - QVariantMap artist=parsed[parsed.keys().first()].toMap(); - if (artist.contains("artistbackground")) { - QVariantList artistbackgrounds=artist["artistbackground"].toList(); - if (!artistbackgrounds.isEmpty()) { - QVariantMap artistbackground=artistbackgrounds.first().toMap(); - if (artistbackground.contains("url")) { - url=artistbackground["url"].toString(); - } + QVariantList artistbackgrounds; + + if (parsed.contains("artistbackground")) { + artistbackgrounds=parsed["artistbackground"].toList(); + } else { + QVariantMap artist=parsed[parsed.keys().first()].toMap(); + + if (artist.contains("artistbackground")) { + artistbackgrounds=artist["artistbackground"].toList(); + } + } + if (!artistbackgrounds.isEmpty()) { + QVariantMap artistbackground=artistbackgrounds.first().toMap(); + if (artistbackground.contains("url")) { + url=artistbackground["url"].toString(); } } }