summaryrefslogtreecommitdiff
path: root/nopsyncd/qlistener.lua
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2011-03-16 00:54:52 (GMT)
committerChristian Pointner <equinox@helsinki.at>2011-03-16 00:54:52 (GMT)
commitfba23d62b11f361af19eae4cf545f946c17b97a5 (patch)
treec02ac491b450ac3bd0f2261f8b5f593a7e8e964d /nopsyncd/qlistener.lua
parent2edacdcb0ac14a1e3ab8d6f6bc2a56f81783a88a (diff)
added rddb lookup
Diffstat (limited to 'nopsyncd/qlistener.lua')
-rwxr-xr-xnopsyncd/qlistener.lua29
1 files changed, 22 insertions, 7 deletions
diff --git a/nopsyncd/qlistener.lua b/nopsyncd/qlistener.lua
index 9498fbb..b7c74d8 100755
--- a/nopsyncd/qlistener.lua
+++ b/nopsyncd/qlistener.lua
@@ -22,7 +22,8 @@
local queue_name = "/rhnop"
mq = require "luamq"
-db = require "db"
+tempstorage = require "tempstorage"
+rddb = require "rddb"
function main_loop()
local q, err = mq.create(queue_name, "ro")
@@ -31,9 +32,16 @@ function main_loop()
os.exit(1)
end
- local ret, err = db:init()
+ local ret, err = tempstorage:init()
if ret == nil then
- io.stderr:write("creation of db failed: " .. err .. "\n")
+ io.stderr:write("creation of tempstorage failed: " .. err .. "\n")
+ os.exit(1)
+ end
+
+ local ret, err = rddb:init()
+ if ret == nil then
+ io.stderr:write("opening rivendell db failed: " .. err .. "\n")
+ tempstorage:close()
os.exit(1)
end
@@ -41,6 +49,8 @@ function main_loop()
local msg, prio = mq.receive(q)
if msg == nil then
io.stderr:write("recv error: " .. prio .. "\n")
+ rddb:close()
+ tempstorage:close()
os.exit(2)
end
@@ -48,9 +58,14 @@ function main_loop()
if not timestamp or not nowcart or not nowlen or not nextcart or not nextlen then
io.stderr:write("ignoring malformed message\n")
else
- -- TODO: lookup info in Rivendell DB and insert into temporary storage
- print("received message:\ntimestamp = " .. timestamp .. "\nnowcart = " .. nowcart .. "\nnowlen = " .. nowlen .. "\nnextcart = " .. nextcart .. "\nnextlen = " .. nextlen)
- pipe.signal()
+ local results, err = rddb:getCartInfo(nowcart);
+ if results == nil then
+ io.stderr:write("can't fetch cart info: " .. err .. "\n")
+ else
+ -- TODO: insert into tempstorage
+ print(timestamp .. " Info: '" .. results.TITLE .. "' von '" .. results.ARTIST .. "' aus '" .. results.ALBUM .. "'")
+ pipe.signal()
+ end
end
end
-end \ No newline at end of file
+end \ No newline at end of file