19 lines
411 B
Python
19 lines
411 B
Python
|
#!/usr/bin/env python3
|
||
|
"""
|
||
|
WebSocket events.
|
||
|
"""
|
||
|
import types
|
||
|
|
||
|
import rtorrent
|
||
|
|
||
|
async def active_torrents(ws, data):
|
||
|
"""Returns active torrent information."""
|
||
|
data = [vars(t) for t in rtorrent.get_active()]
|
||
|
res = {'event': 'active_torrents', 'data': data}
|
||
|
await ws.send_json(res)
|
||
|
|
||
|
events = {}
|
||
|
for obj in dir():
|
||
|
if type(locals()[obj]) == types.FunctionType:
|
||
|
events[locals()[obj].__name__] = locals()[obj]
|