#!/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
'''
REVISION HISTORY
+JSW = Stephen Worthington <stephen@jsw.gen.nz>
+
0.1 First release
0.2 Some code clean up. Added messages.
0.3 Added bindings for Linux DVB API
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
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):
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()
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:
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])
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