+function mpc:currentsong()
+ local currentsong
+ self:send("currentsong", function(err, song)
+ if err then error(err) end
+ currentsong = song
+ end)
+ return currentsong
+end
+
+local function escape(str)
+ return "\"" .. str .. "\""
+end
+
+function mpc:albumart(uri, handler)
+ local image_table = {}
+ local get_art_at
+ get_art_at = function(off)
+ self:send("albumart " .. escape(uri) .. " " .. tostring(off), function(success, data)
+ if not success then
+ handler(success, data)
+ end
+ table.insert(image_table, data.binary)
+ if data.binary and #data.binary > 0 then
+ get_art_at(off + #data.binary)
+ else
+ data.binary = table.concat(image_table)
+ handler(success, data)
+ end
+ end)
+ end
+ get_art_at(0)
+end
+