@@ -281,10 +281,29 @@ async def api_search(q: str = Query(...), limit: int = Query(100)):
281281
282282@app .post ("/api/grab" )
283283async def api_grab (item : dict ):
284- """Trigger XDCC download"""
285- # TODO: Integrate with irssi/autodl
286- return {"status" : "queued" , "item" : item }
287-
284+ """Trigger XDCC download from WebUI"""
285+ server = item .get ("server" , "" )
286+ channel = item .get ("channel" , "" )
287+ bot = item .get ("bot" , "" )
288+ pack = item .get ("pack" , "" )
289+ filename = item .get ("title" , item .get ("filename" , "" ))
290+
291+ if not all ([bot , pack ]):
292+ return {"status" : "error" , "message" : "Missing bot or pack number" }
293+
294+ # Write to queue file
295+ queue_file = Path ("/app/data/xdcc_queue.txt" )
296+ queue_file .parent .mkdir (parents = True , exist_ok = True )
297+
298+ with open (queue_file , "a" ) as f :
299+ f .write (f"{ server } |{ channel } |{ bot } |{ pack } |{ filename } \n " )
300+
301+ xdcc_cmd = f"/msg { bot } xdcc send #{ pack } "
302+ return {
303+ "status" : "queued" ,
304+ "message" : f"XDCC download queued: { bot } #{ pack } " ,
305+ "command" : xdcc_cmd
306+ }
288307
289308@app .get ("/grab" )
290309async def grab (id : str = Query (..., description = "Result ID to grab" )):
0 commit comments