From 11ffb90e0feeb03d50e18644730ac4a8adbb3bdb Mon Sep 17 00:00:00 2001 From: Andrew Ruthven Date: Sat, 11 Jun 2022 17:23:43 +1200 Subject: [PATCH] Import version 0.7.2 from http://www.jsw.gen.nz/mythtv/mhegepgsnoop-0.7.2.py --- bin/mhegepgsnoop.py | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/bin/mhegepgsnoop.py b/bin/mhegepgsnoop.py index bbff13c..3c9d25e 100644 --- a/bin/mhegepgsnoop.py +++ b/bin/mhegepgsnoop.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 -VERSION = '0.7.1' +VERSION = '0.7.2' ''' mhegepgsnoop.py - Freeview DVB-T MHEG-5 to XMLTV EPG converter Version 0.7.0 JSW modified version converted to Python 3 @@ -73,6 +73,8 @@ Example usage to collect EPG data from default adapter, write to tvguide.xml, an ''' REVISION HISTORY +JSW = Stephen Worthington + 0.1 First release 0.2 Some code clean up. Added messages. 0.3 Added bindings for Linux DVB API @@ -115,6 +117,7 @@ REVISION HISTORY Removed optparse (not needed with Python 3). Prevented hang on tuner open error - it will now timeout and die. 0.7.1 JSW Fixed a problem with -b option where the database was being accessed when only the map file was being used. +0.7.2 JSW Add --hdhr option, Mike Brady's changes to allow using dvbsnoop option with a capture file created using HDHomerun tuners. TO DO @@ -840,7 +843,17 @@ def argparse_parse(defs): help='''Clean up silly things prepended to titles. Default (just -c with no string specified) removes "All New ". Customize the text to be removed by specifying a matching regular expression string like this: "Remove this|And this" or this: "Remove this".''') + parser.add_argument('--hdhr', action='store_true', default=False, + help='Use dvbsnoop to read a .ts file captured externally from an HDHomerun tuner. Implies -s and removes -n 1 option from the dvbsnoop command line. Requires -e.') args = parser.parse_args() + if args.hdhr: + args.n1 = '' + args.use_dvbsnoop = True + if args.extra_args == defs.extra_args: + print('Error: --hdhr option requires -e option.') + sys.exit(1) + else: + args.n1 = '-n 1 ' return args def get_tune_info(py_bind, sql_select, tune_ch, tuning_fields): @@ -1087,7 +1100,7 @@ def find_pid3(dmxfd, demux_filter): return carousel_pid def find_pid(): - f = os.popen("dvbsnoop -n 1 -nph -ph 2 " + options.extra_args + " 0") + f = os.popen("dvbsnoop -nph -ph 2 " + options.n1 + options.extra_args + " 0") for line in f.read().split("\n"): if line.find("Program_map_PID:") != -1: f.close() @@ -1096,7 +1109,7 @@ def find_pid(): return -1 def find_pid2(pid): - f = os.popen("dvbsnoop -n 1 -nph -ph 2 " + options.extra_args + " " + pid) + f = os.popen("dvbsnoop -nph -ph 2 " + options.n1 + options.extra_args + " " + pid) next_one = False for line in f.read().split("\n"): if line.find("Stream_type: 11") != -1: @@ -1194,7 +1207,7 @@ def download(pid, datablocks, module_numbers): if DSIorDII: if line.find(b"blockSize:") != -1: # Store the DDB block size - block_size = int(line.split(b" ")[1]) + block_size = int(line.strip().split(b" ")[1]) elif line.find(b"moduleId:") != -1: # Store module number... module_num = int(line.strip().split(b" ")[1]) @@ -1212,10 +1225,10 @@ def download(pid, datablocks, module_numbers): if DDB: if line.find(b"moduleId:") != -1: # Store the module number - module_num = int(line.split(b" ")[1]) + module_num = int(line.strip().split(b" ")[1]) elif line.find(b"blockNumber:") != -1: # Store the block number - block_num = int(line.split(b" ")[1]) + block_num = int(line.strip().split(b" ")[1]) elif line.find(b"Block Data:") != -1: # Set flag to store the data on the next line store_data = True -- 2.30.2