|
a/src/mediaserver/cdplugins/uprcl/uprcl-app.py |
|
b/src/mediaserver/cdplugins/uprcl/uprcl-app.py |
|
... |
|
... |
36 |
dispatcher = cmdtalkplugin.Dispatch()
|
36 |
dispatcher = cmdtalkplugin.Dispatch()
|
37 |
# Pipe message handler
|
37 |
# Pipe message handler
|
38 |
msgproc = cmdtalkplugin.Processor(dispatcher)
|
38 |
msgproc = cmdtalkplugin.Processor(dispatcher)
|
39 |
|
39 |
|
40 |
def uprcl_init():
|
40 |
def uprcl_init():
|
41 |
global httphp, pathprefix, uprclhost, pathmap
|
41 |
global httphp, pathprefix, uprclhost, pathmap, rclconfdir
|
42 |
|
42 |
|
43 |
if "UPMPD_HTTPHOSTPORT" not in os.environ:
|
43 |
if "UPMPD_HTTPHOSTPORT" not in os.environ:
|
44 |
raise Exception("No UPMPD_HTTPHOSTPORT in environment")
|
44 |
raise Exception("No UPMPD_HTTPHOSTPORT in environment")
|
45 |
httphp = os.environ["UPMPD_HTTPHOSTPORT"]
|
45 |
httphp = os.environ["UPMPD_HTTPHOSTPORT"]
|
46 |
if "UPMPD_PATHPREFIX" not in os.environ:
|
46 |
if "UPMPD_PATHPREFIX" not in os.environ:
|
|
... |
|
... |
128 |
objid = a['objid']
|
128 |
objid = a['objid']
|
129 |
if re.match('0\$uprcl\$', objid) is None:
|
129 |
if re.match('0\$uprcl\$', objid) is None:
|
130 |
raise Exception("bad objid [%s]" % objid)
|
130 |
raise Exception("bad objid [%s]" % objid)
|
131 |
|
131 |
|
132 |
upnps = a['origsearch']
|
132 |
upnps = a['origsearch']
|
133 |
rcls = uprclsearch.upnpsearchtorecoll(upnps)
|
133 |
|
134 |
uplog("Search: recoll search: %s" % rcls)
|
134 |
entries = uprclsearch.search(rclconfdir, objid, upnps, g_myprefix, httphp, pathprefix)
|
135 |
|
135 |
|
136 |
rcldb = recoll.connect(confdir=rclconfdir)
|
|
|
137 |
rclq = rcldb.query()
|
|
|
138 |
rclq.execute(rcls)
|
|
|
139 |
uplog("Estimated query results: %d" % (rclq.rowcount))
|
|
|
140 |
|
|
|
141 |
entries = []
|
|
|
142 |
maxcnt = 0
|
|
|
143 |
totcnt = 0
|
|
|
144 |
while True:
|
|
|
145 |
docs = rclq.fetchmany()
|
|
|
146 |
for doc in docs:
|
|
|
147 |
id = g_myprefix + '$' + 'seeyoulater'
|
|
|
148 |
e = rcldoctoentry(id, objid, httphp, pathprefix, doc)
|
|
|
149 |
entries.append(e)
|
|
|
150 |
totcnt += 1
|
|
|
151 |
if (maxcnt > 0 and totcnt >= maxcnt) or len(docs) != rclq.arraysize:
|
|
|
152 |
break
|
|
|
153 |
uplog("Search retrieved %d docs" % (totcnt,))
|
|
|
154 |
|
|
|
155 |
encoded = json.dumps(entries)
|
136 |
encoded = json.dumps(entries)
|
156 |
return {"entries" : encoded}
|
137 |
return {"entries" : encoded}
|
157 |
|
138 |
|
158 |
uprcl_init()
|
139 |
uprcl_init()
|
159 |
|
140 |
|