summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/db.lua8
-rw-r--r--src/playlog.lua7
-rw-r--r--src/qlistener.lua5
-rw-r--r--src/rddb.lua2
4 files changed, 10 insertions, 12 deletions
diff --git a/src/db.lua b/src/db.lua
index ebd8caa..5d0eabf 100644
--- a/src/db.lua
+++ b/src/db.lua
@@ -24,9 +24,9 @@ luasql = require "luasql.mysql"
-- for destination database
-- CREATE DATABASE nop CHARACTER SET utf8 COLLATE utf8_unicode_ci;
-- USE nop
--- CREATE TABLE IF NOT EXISTS master (timestamp BIGINT UNSIGNED PRIMARY KEY NOT NULL, cart INT NOT NULL, len INT, showtitle VARCHAR(255), title VARCHAR(255), artist VARCHAR(255), album VARCHAR(255), ismusic BOOLEAN);
+-- CREATE TABLE IF NOT EXISTS master (timestamp BIGINT UNSIGNED PRIMARY KEY NOT NULL, cart INT NOT NULL, len INT, showtitle VARCHAR(255), title VARCHAR(255), artist VARCHAR(255), album VARCHAR(255), carttype ENUM('show','pool','jingle'));
-- ALTER TABLE master CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;
--- CREATE TABLE IF NOT EXISTS standby (timestamp BIGINT UNSIGNED PRIMARY KEY NOT NULL, cart INT NOT NULL, len INT, showtitle VARCHAR(255), title VARCHAR(255), artist VARCHAR(255), album VARCHAR(255), ismusic BOOLEAN);
+-- CREATE TABLE IF NOT EXISTS standby (timestamp BIGINT UNSIGNED PRIMARY KEY NOT NULL, cart INT NOT NULL, len INT, showtitle VARCHAR(255), title VARCHAR(255), artist VARCHAR(255), album VARCHAR(255), carttype ENUM('show','pool','jingle'));
-- ALTER TABLE standby CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;
-- CREATE TABLE IF NOT EXISTS state (timestamp BIGINT UNSIGNED PRIMARY KEY NOT NULL, state VARCHAR(32));
-- ALTER TABLE state CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;
@@ -112,9 +112,9 @@ function db.init(db, user, pwd, host, port, table)
local title = self.con:escape(data.title)
local artist = self.con:escape(data.artist)
local album = self.con:escape(data.album)
- local ismusic = self.con:escape(data.ismusic)
+ local carttype = self.con:escape(data.carttype)
- local cur, err = self.con:execute("REPLACE INTO " .. self.table .. " VALUES('" .. timestamp .. "', '" .. cart .. "', '" .. len .. "', '" .. showtitle .. "', '" .. title .. "', '" .. artist .."', '" .. album .. "', '" .. ismusic .. "')")
+ local cur, err = self.con:execute("REPLACE INTO " .. self.table .. " VALUES('" .. timestamp .. "', '" .. cart .. "', '" .. len .. "', '" .. showtitle .. "', '" .. title .. "', '" .. artist .."', '" .. album .. "', '" .. carttype .. "')")
if cur == nil then
return nil, err
end
diff --git a/src/playlog.lua b/src/playlog.lua
index ddb31f3..b93a3cc 100644
--- a/src/playlog.lua
+++ b/src/playlog.lua
@@ -25,7 +25,7 @@ luasql = require "luasql.mysql"
-- GRANT select,insert,update ON rhnop.* TO 'nopfetchd' IDENTIFIED BY '<password>';
-- GRANT select ON rhnop.* TO 'nopsyncd' IDENTIFIED BY '<password>';
-- USE rhnop
--- CREATE TABLE IF NOT EXISTS now (timestamp BIGINT UNSIGNED PRIMARY KEY NOT NULL, cart INT NOT NULL, len INT, showtitle VARCHAR(255), title VARCHAR(255), artist VARCHAR(255), album VARCHAR(255), ismusic BOOLEAN);
+-- CREATE TABLE IF NOT EXISTS now (timestamp BIGINT UNSIGNED PRIMARY KEY NOT NULL, cart INT NOT NULL, len INT, showtitle VARCHAR(255), title VARCHAR(255), artist VARCHAR(255), album VARCHAR(255), carttype ENUM('show','pool','jingle'));
-- ALTER TABLE now CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;
local playlog = {}
@@ -67,11 +67,10 @@ function playlog:getLastCart()
return cart
end
-function playlog:insertNow(timestamp, cart, len, showtitle, title, artist, album, isMusic)
+function playlog:insertNow(timestamp, cart, len, showtitle, title, artist, album, carttype)
cart = tonumber(cart)
len = tonumber(len)
- if isMusic then isMusic = '1' else isMusic = '0' end
- local cur, err = self.con:execute("INSERT into now VALUES(" .. self.con:escape(timestamp) .. ", " .. cart .. ", " .. len .. ", '" .. self.con:escape(showtitle) .. "', '" .. self.con:escape(title) .. "', '" .. self.con:escape(artist) .."', '" .. self.con:escape(album) .. "', " .. isMusic .. ")")
+ local cur, err = self.con:execute("INSERT into now VALUES(" .. self.con:escape(timestamp) .. ", " .. cart .. ", " .. len .. ", '" .. self.con:escape(showtitle) .. "', '" .. self.con:escape(title) .. "', '" .. self.con:escape(artist) .."', '" .. self.con:escape(album) .. "', '" .. self.con:escape(carttype) .. "')")
if cur == nil then
return nil, err
end
diff --git a/src/qlistener.lua b/src/qlistener.lua
index a80dbac..d3fc9fd 100644
--- a/src/qlistener.lua
+++ b/src/qlistener.lua
@@ -41,13 +41,12 @@ function handle_now(timestamp, nowcart, nowlen)
io.stderr:write("ERROR: can't fetch cart info: " .. err .. "\n")
return nil
else
- -- print(timestamp .. " Info: '" .. results.TITLE .. "' von '" .. results.ARTIST .. "' aus '" .. results.ALBUM .. "'")
- local showtitle, isMusic, err = rddb:getCartShowName(nowcart)
+ local showtitle, carttype, err = rddb:getCartShowName(nowcart)
if showtitle == nil then
io.stderr:write("ERROR: can't fetch show/pool name: " .. err .. "\n")
return nil
else
- local ret, err = playlog:insertNow(timestamp, nowcart, nowlen, showtitle, results.TITLE, results.ARTIST, results.ALBUM, isMusic)
+ local ret, err = playlog:insertNow(timestamp, nowcart, nowlen, showtitle, results.TITLE, results.ARTIST, results.ALBUM, carttype)
if ret == nil then
io.stderr:write("ERROR: can't insert cart info: " .. err .. "\n")
else
diff --git a/src/rddb.lua b/src/rddb.lua
index fd755f7..b18ae67 100644
--- a/src/rddb.lua
+++ b/src/rddb.lua
@@ -67,7 +67,7 @@ end
function rddb:getCartShowName(cartnum)
--TODO: implement this
- return "unknown", true, nil
+ return "unknown", "music", nil
end
function rddb:close()