on xenial help sign in
Return fallback image on album fetching failure.
commit9e79b6e7a99dfd9c2986bb2402e72a42eeeb4d48 authorPawel Stolowski <pawel.stolowski@canonical.com> dateTue 8 Oct 2013, 11:34 (13 years ago) parent5ea16e0
2 files changed+9−4
plugins/Utils/albumartprovider.cpp+8−4 plugins/Utils/albumartprovider.h+1
plugins/Utils/albumartprovider.cpp+8−4
@@ -36,6 +36,8 @@
3636
3737using namespace std;
3838
39+const std::string AlbumArtProvider::DEFAULT_ALBUM_ART = "/usr/share/unity/icons/album_missing.png";
40+
3941static void on_new_pad (GstElement * /*dec*/, GstPad * pad, GstElement * fakesink) {
4042 GstPad *sinkpad;
4143
@@ -65,7 +67,7 @@ static void process_one_tag (const GstTagList * list, const gchar * tag, gpointe
6567 }
6668}
6769
68−albuminfo AlbumArtProvider::get_album_info(const std::string &filename) throw (runtime_error)
70+albuminfo AlbumArtProvider::get_album_info(const std::string &filename) throw (runtime_error)
6971{
7072 albuminfo ai;
7173 // FIXME: Need to do quoting. Files with %'s in their names seem to confuse gstreamer.
@@ -152,6 +154,8 @@ std::string AlbumArtProvider::get_lastfm_url(const albuminfo &ai) {
152154 return "";
153155 }
154156
157+
158+
155159 QXmlQuery query;
156160 QBuffer tmp;
157161 tmp.setData(reply->readAll());
@@ -214,10 +218,10 @@ std::string AlbumArtProvider::get_image(const std::string &filename) {
214218 info = get_album_info(filename);
215219 } catch(std::exception &e) {
216220 qDebug() << "Could not determine album info: " << e.what();
217− return "";
221+ return DEFAULT_ALBUM_ART;
218222 }
219223 if(info.album.empty() || info.artist.empty()) {
220− return "";
224+ return DEFAULT_ALBUM_ART;
221225 }
222226 if(cache.has_art(info.artist, info.album)) {
223227 // Image may have expired from cache between these two lines.
@@ -226,7 +230,7 @@ std::string AlbumArtProvider::get_image(const std::string &filename) {
226230 }
227231 std::string image_url = get_lastfm_url(info);
228232 if(image_url.empty()) {
229− return "";
233+ return DEFAULT_ALBUM_ART;
230234 }
231235 char tmpname[] = "/tmp/path/to/some/file/somewhere/maybe.jpg";
232236 tmpnam(tmpname);
plugins/Utils/albumartprovider.h+1
@@ -38,6 +38,7 @@ public:
3838
3939 std::string get_image(const std::string &filename);
4040
41+ const static std::string DEFAULT_ALBUM_ART;
4142private:
4243 MediaArtCache cache;
4344