From 19b0d8b6f5f4bd69ef05f342a78e367d926e6b43 Mon Sep 17 00:00:00 2001 From: garret Date: Sat, 4 Feb 2023 18:42:34 +0000 Subject: [PATCH] Fix mpegts error when no 'index' in data Trying to run mpegts on a captured TS gave the following error: Traceback (most recent call last): File "/home/g/Downloads/DVBdirect/./mpegts", line 91, in channelStreams[lastChannelName].append(data['index']) KeyError: 'index' I added a check to see if 'index' was in fact in the data before doing stuff with it, and it now seems to work perfectly. --- mpegts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/mpegts b/mpegts index f851cbf..ef21335 100755 --- a/mpegts +++ b/mpegts @@ -86,11 +86,12 @@ while True: if 'tag:service_name' in data: lastChannelName = data['tag:service_name'].lower() channels[lastChannelName] = data - elif nb_streams > 0: - nb_streams -= 1 - channelStreams[lastChannelName].append(data['index']) elif 'index' in data: - streams[data['index']] = data + if nb_streams > 0: + nb_streams -= 1 + channelStreams[lastChannelName].append(data['index']) + else: + streams[data['index']] = data proc.wait() if proc.returncode != 0: