[grilo-plugins] lua-factory: port grl-pocket.lua to the new lua system



commit 368693b7a8599941d5bfe3b73f440e16ff115a24
Author: George Sedov <radist morse gmail com>
Date:   Wed Dec 16 18:26:56 2015 +0300

    lua-factory: port grl-pocket.lua to the new lua system
    
    https://bugzilla.gnome.org/show_bug.cgi?id=753141
    Acked-by: Victor Toso <me victortoso com>

 src/lua-factory/sources/grl-pocket.lua |   20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)
---
diff --git a/src/lua-factory/sources/grl-pocket.lua b/src/lua-factory/sources/grl-pocket.lua
index 505c624..febc950 100644
--- a/src/lua-factory/sources/grl-pocket.lua
+++ b/src/lua-factory/sources/grl-pocket.lua
@@ -51,15 +51,15 @@ source = {
 -- Source utils --
 ------------------
 
-function grl_source_browse(media_id)
-  local count = grl.get_options("count")
-  local skip = grl.get_options("skip")
-  local operation_id = grl.get_options('operation-id')
+function grl_source_browse(media, options, callback)
+  local count = options.count
+  local skip = options.skip
 
   local url = string.format(POCKET_GET_URL, grl.goa_consumer_key(), grl.goa_access_token(), count, skip)
   grl.debug ("Fetching URL: " .. url .. " (count: " .. count .. " skip: " .. skip .. ")")
 
-  grl.fetch(url, "pocket_fetch_cb")
+  local userdata = {callback = callback, count = count}
+  grl.fetch(url, pocket_fetch_cb, userdata)
 end
 
 ------------------------
@@ -77,11 +77,11 @@ function string.starts(String,Start)
 end
 
 -- return all the media found
-function pocket_fetch_cb(results)
-  local count = grl.get_options("count")
+function pocket_fetch_cb(results, userdata)
+  local count = userdata.count
 
   if not results then
-    grl.callback ()
+    userdata.callback()
     return
   end
 
@@ -96,7 +96,7 @@ function pocket_fetch_cb(results)
     local media = create_media(item)
     if media then
       count = count - 1
-      grl.callback(media, count)
+      userdata.callback(media, count)
     end
 
     -- Bail out if we've given enough items
@@ -105,7 +105,7 @@ function pocket_fetch_cb(results)
     end
   end
 
-  grl.callback()
+  userdata.callback()
 end
 
 -------------


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