1 -- Copyright 2012 Gabor Juhos <juhosg@openwrt.org>
2 -- Licensed to the public under the Apache License 2.0.
4 module("luci.controller.minidlna", package.seeall)
7 if not nixio.fs.access("/etc/config/minidlna") then
13 page = entry({"admin", "services", "minidlna"}, cbi("minidlna"), _("miniDLNA"))
16 entry({"admin", "services", "minidlna_status"}, call("minidlna_status"))
19 function minidlna_status()
20 local sys = require "luci.sys"
21 local uci = require "luci.model.uci".cursor()
22 local port = tonumber(uci:get_first("minidlna", "minidlna", "port"))
25 running = (sys.call("pidof minidlna >/dev/null") == 0),
31 if status.running then
32 local fd = sys.httpget("http://127.0.0.1:%d/" % (port or 8200), true)
34 local html = fd:read("*a")
36 status.audio = (tonumber(html:match("Audio files</td><td>(%d+)")) or 0)
37 status.video = (tonumber(html:match("Video files</td><td>(%d+)")) or 0)
38 status.image = (tonumber(html:match("Image files</td><td>(%d+)")) or 0)
44 luci.http.prepare_content("application/json")
45 luci.http.write_json(status)