diff options
Diffstat (limited to 'src/rddb.lua')
-rw-r--r-- | src/rddb.lua | 46 |
1 files changed, 44 insertions, 2 deletions
diff --git a/src/rddb.lua b/src/rddb.lua index b18ae67..0827f62 100644 --- a/src/rddb.lua +++ b/src/rddb.lua @@ -65,9 +65,51 @@ function rddb:getCartInfo(cartnum) return results, err end +function rddb:getGroupNameAndCartType(cartnum) + local cur, err = self.con:execute("select NAME,DESCRIPTION from GROUPS where DEFAULT_LOW_CART <= " .. self.con:escape(cartnum) .. " and DEFAULT_HIGH_CART >= " .. self.con:escape(cartnum)) + if cur == nil then + return nil, err + end + + local groupname = nil + local carttype = nil + local groupdesc = nil + while true do + local data = {} + data = cur:fetch(data, "a") + if data == nil then break end + if data.NAME == "ALL_SHOWS" then + carttype = "show" + elseif data.NAME == "ALL_POOLS" then + carttype = "pool" + elseif data.NAME == "ALL_JINGLE" then + carttype = "jingle" + else + groupname = data.NAME + groupdesc = data.DESCRIPTION + end + if groupname and carttype then break end + end + cur:close() + + if carttype == nil then + return nil, "unable to detect group type for cart: " .. cartnum + end + if groupname == nil then + return nil, "can't find any group for cart: " .. cartnum + end + return carttype, groupname, groupdesc +end + function rddb:getCartShowName(cartnum) - --TODO: implement this - return "unknown", "music", nil + local carttype, groupname, groupdesc = self:getGroupNameAndCartType(cartnum) + if carttype == nil then + return nil, groupname + end + if carttype == "show" then + return nil, "show carts not yet supported" + end + return groupdesc, carttype end function rddb:close() |