2019-09-01 16:48:45 -04:00
|
|
|
#!/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)
|
|
|
|
|
2019-09-12 21:05:25 -04:00
|
|
|
async def tracker_stats(ws, data):
|
|
|
|
"""Returns tracker stats."""
|
|
|
|
data = rtorrent.get_stats()
|
|
|
|
res = {'event': 'tracker_stats', 'data': data}
|
|
|
|
await ws.send_json(res)
|
|
|
|
|
2019-09-01 16:48:45 -04:00
|
|
|
events = {}
|
|
|
|
for obj in dir():
|
|
|
|
if type(locals()[obj]) == types.FunctionType:
|
|
|
|
events[locals()[obj].__name__] = locals()[obj]
|