diff options
author | Christian Pointner <equinox@helsinki.at> | 2011-03-29 15:36:00 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2011-03-29 15:36:00 (GMT) |
commit | 27a967a7fbbd9345bf205e44bbfd047f5752a42e (patch) | |
tree | 9becd79e8ac21da53a2f5fcbc5ae9b9cb1e037cf /nopsyncd/playlog.lua | |
parent | 473634799142c6cc9f7c78778add94958f5293d2 (diff) |
added minimal config parser
Diffstat (limited to 'nopsyncd/playlog.lua')
-rw-r--r-- | nopsyncd/playlog.lua | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/nopsyncd/playlog.lua b/nopsyncd/playlog.lua index 3aa0361..37b9ea6 100644 --- a/nopsyncd/playlog.lua +++ b/nopsyncd/playlog.lua @@ -25,6 +25,8 @@ require "luasql.mysql" -- GRANT select,insert,update ON rhnop.* TO 'nopsyncd' IDENTIFIED BY '123456'; -- CREATE TABLE IF NOT EXISTS now (timestamp VARCHAR(16) PRIMARY KEY NOT NULL, cart INT NOT NULL, len INT, showtitle VARCHAR(255), title VARCHAR(255), artist VARCHAR(255), album VARCHAR(255), ismusic BOOLEAN) +conf = require "conf" + local playlog = {} function playlog:init() @@ -35,7 +37,7 @@ function playlog:init() return nil, err end - self.con, err = self.env:connect("rhnop", "nopsyncd", "123456", "127.0.0.1") + self.con, err = self.env:connect(conf.playlog_db, conf.playlog_user, conf.playlog_pwd, conf.playlog_host, conf.playlog_port) if self.con == nil then return nil, err end @@ -59,7 +61,7 @@ function playlog:getLastCart() return cart end -function playlog:insertMusic(timestamp, cart, len, title, artist, album) +function playlog:insertNowMusic(timestamp, cart, len, title, artist, album) cart = tonumber(cart) len = tonumber(len) if cart < 400000 or cart > 450000 then @@ -67,7 +69,6 @@ function playlog:insertMusic(timestamp, cart, len, title, artist, album) else poolnum = math.floor(cart/1000) - 399 end - -- usage of undocumented escape function... local cur, err = self.con:execute("INSERT into now VALUES(" .. self.con:escape(timestamp) .. ", " .. cart .. ", " .. len .. ", 'Musikpool " .. poolnum .. "', '" .. self.con:escape(title) .. "', '" .. self.con:escape(artist) .."', '" .. self.con:escape(album) .. "', 1)") if cur == nil then return nil, err |