applications/luci-minidlna: fix status parsing
authorJo-Philipp Wich <jow@openwrt.org>
Thu, 3 May 2012 08:52:57 +0000 (08:52 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Thu, 3 May 2012 08:52:57 +0000 (08:52 +0000)
applications/luci-minidlna/luasrc/controller/minidlna.lua

index 5b9d62ef1fc3dcc1efe46ed05749d166720d38c7..1bd5617f6acb0bf17b1978ff3a08c9963bdd09c0 100644 (file)
@@ -43,14 +43,12 @@ function minidlna_status()
        if status.running then
                local fd = sys.httpget("http://127.0.0.1:%d/" % (port or 8200), true)
                if fd then
-                       local ln
-                       repeat
-                               ln = fd:read("*l")
-                               if ln and ln:match("files:") then
-                                       local ftype, fcount = ln:match("(.+) files: (%d+)")
-                                       status[ftype:lower()] = tonumber(fcount) or 0
-                               end
-                       until not ln
+                       local html = fd:read("*a")
+                       if html then
+                               status.audio = (tonumber(html:match("Audio files: (%d+)")) or 0)
+                               status.video = (tonumber(html:match("Video files: (%d+)")) or 0)
+                               status.image = (tonumber(html:match("Image files: (%d+)")) or 0)
+                       end
                        fd:close()
                end
        end