[grilo-plugins] lastfm-cover: don't return an empty table



commit 15023e0137e5ed99ecc262747db313ef2f8695a0
Author: fosero <fosero users noreply github com>
Date:   Mon Feb 22 18:20:57 2016 +0100

    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

 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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]