Add device-side log file, remote terminal, and streaming error reporting
IPTV.py now writes logs to a rotating file and forwards critical VLC playback errors (start timeout, MediaPlayerEncounteredError) to the server instead of losing everything to unredirected print() calls. The web UI's device menu gets a working Terminal (to run diagnostic commands like tail on the log) and a Recent errors view backed by a capped last_errors list on each device document, keeping DB volume bounded to the last 5 entries per device. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
10fd5106f8
commit
3eb0d5e8cd
@@ -74,6 +74,7 @@ recents = db_iptv['recents']
|
||||
settings_collection = db_iptv['settings']
|
||||
|
||||
devices_db = db_iptv['devices']
|
||||
MAX_STREAMING_ERRORS_PER_DEVICE = 5
|
||||
devices = []
|
||||
active_xtream_imports = {}
|
||||
sio_session_ips = {}
|
||||
@@ -1471,6 +1472,21 @@ async def communication(fromSid, data):
|
||||
await sio.emit('communication', data, room=toSidDevice ,callback=messageReceived)
|
||||
|
||||
|
||||
@sio.event
|
||||
async def streaming_error(sid, data):
|
||||
IdDevice = data.get('IdDevice')
|
||||
message = data.get('message', '')
|
||||
if not IdDevice:
|
||||
return
|
||||
|
||||
print('streaming_error from device :', IdDevice, message, flush=True)
|
||||
error_entry = {'message': str(message)[:500], 'timestamp': time.time()}
|
||||
devices_db.update_one(
|
||||
{'id_device': IdDevice},
|
||||
{'$push': {'last_errors': {'$each': [error_entry], '$slice': -MAX_STREAMING_ERRORS_PER_DEVICE}}}
|
||||
)
|
||||
|
||||
|
||||
@sio.event
|
||||
def disconnect(sid):
|
||||
sio_session_ips.pop(sid, None)
|
||||
|
||||
Reference in New Issue
Block a user