diff --git a/HomeWidgets/WidgetPlaylists.lua b/HomeWidgets/WidgetPlaylists.lua new file mode 100644 index 0000000..af54b71 --- /dev/null +++ b/HomeWidgets/WidgetPlaylists.lua @@ -0,0 +1,38 @@ +-- {"name": "WidgetPlaylists", "file": "HomeWidgets/WidgetPlaylists.lua", "version": 1, "desc": "Home widget for playlists.", "order":0,"arguments":["entries"]} +local headers = "Content-type: text/html\r\n" +local entries +if mympd_arguments.entries ~= nil then + entries = tonumber(mympd_arguments.entries) +else + entries = 10 +end + +local method = "MYMPD_API_PLAYLIST_LIST" +local options = { + searchstr = "", + sort = "Last-Modified", + sortdesc = false, + fields = { + "Name", + "Last-Modified" + }, + type = 0, + offset = 0, + limit = entries +} + +local rows = {} +local rc, result = mympd.api(method, options) +if rc == 0 then + for _,data in ipairs(result.data) + do + table.insert(rows, "
" .. mympd.htmlencode(data.Name) .. "
") + end +end + +local body = "
" .. + table.concat(rows) .. + "
" + +return mympd.http_reply("200", headers, body)