diff options
author | fosero <fosero@users.noreply.github.com> | 2016-02-22 18:20:57 +0100 |
---|---|---|
committer | Victor Toso <victortoso@redhat.com> | 2016-02-22 21:50:46 +0100 |
commit | 15023e0137e5ed99ecc262747db313ef2f8695a0 (patch) | |
tree | 5c9d597ce982ba30b7f09f639797b6904108bd7e | |
parent | ae252b6580037da6493734a34ce3738b02ca14b9 (diff) |
lastfm-cover: don't return an empty table
In case no thumbnails are found we should just call the callback without
the empty table as it is consider valid GrlMedia for Lua-Factory.
Related: https://bugzilla.gnome.org/show_bug.cgi?id=761852
Related: https://bugzilla.gnome.org/show_bug.cgi?id=761694
-rw-r--r-- | src/lua-factory/sources/grl-lastfm-cover.lua | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/lua-factory/sources/grl-lastfm-cover.lua b/src/lua-factory/sources/grl-lastfm-cover.lua index b70b89b..7729284 100644 --- a/src/lua-factory/sources/grl-lastfm-cover.lua +++ b/src/lua-factory/sources/grl-lastfm-cover.lua @@ -84,9 +84,15 @@ function fetch_page_cb(result, userdata) local url url = string.match(result, '<image size="' .. size .. '">(.-)</image>') - grl.debug ('Image size ' .. size .. ' = ' .. url) - table.insert(userdata.media.thumbnail, url) + if url ~= nil and url ~= '' then + grl.debug ('Image size ' .. size .. ' = ' .. url) + table.insert(userdata.media.thumbnail, url) + end end - userdata.callback(userdata.media, 0) + if #userdata.media.thumbnail == 0 then + userdata.callback() + else + userdata.callback(userdata.media, 0) + end end |