[mythtvnz] Python 3 version of mhegepgsnoop.py

Stephen Worthington stephen_agent at jsw.gen.nz
Mon May 10 11:21:10 BST 2021


The Python 3 version of mhegepgsnoop.py is now available for download
from my web server:

http://www.jsw.gen.nz/mythtv/mhegepgsnoop-0.7.0.py

This requires the Python 3 version of the MythTV Python bindings,
which is the default in MythTV v31.

I have been using it on my main MythTV box (Ubuntu 20.04, MythTV
v31-fixes) for a while and it is working fine there, but it should be
considered to be beta software until it has had wider testing.

Please let me know if you have any problems or suggestions.

Changes:

1) Converted from Python 2 to Python 3.  This has allowed the code to
be simplified in many places where it used to have to use nasty
workarounds to handle binary data.  Now "bytes" and "byte array" types
are used to handle the binary data directly.
2) Fully UTF-8 - including the output from the -v option (so the a in
Maori will have the macron over it instead of being converted to a ?
symbol).
3) The -t and -T options were not working in my Python 2 version, so I
have fixed them.  It is no longer necessary to use an external tuner
program such as dvbtune.  I recommend using the -T <chanid> option if
you have TV sources other than FreeviewHD as the -t <channum> can get
confused if there is more than one channel with the same <channum>.
4) I replaced the code in build_modules with a much faster version
(runs in 1/10th of the time).
5) The buffer overruns that used to occasionally happen when Python
was not fast enough to read the tuner data from the system buffers
should be fixed.  This problem happened more on slower machines and
when other programs were making the machine busy, and it was also data
dependent - when there was more data for a particular channel, it was
more likely to happen.  Re-running mhegepgsnoop.py at a later time
would often work when this bug was being triggered.  I increased the
size of the system buffers.  The symptom was an unhandled exception
that made you think that the Python buffer had overflowed when in fact
it was the underlying system buffer where that had happened.
6) There is a new -b (both) option to do both map file and fuzzy
mapping of channels.  This allows the use of a map file to map
channels that the fuzzy mapping does not map correctly, but the map
file only needs to map the problem channels, rather than all channels.
It works by first mapping all the channels from the map file, then
removing any channels mapped in that process from both the channels
read from the MHEG-5 data and the channels read from the database.
Then the remaining channels from both sources are mapped to each other
using the fuzzy mapping.
7) Detects the presence of the new "deleted" column in the channel
table and if present, does not map deleted channels.
8) If you have more than one source (eg Sky TV), there used to be a
problem that channels from other than FreeviewHD would be mapped. This
is now prevented by only mapping channels that are received on
multiplexes that have a dtv_multiplex.mod_sys value of "UNDEFINED" or
where mod_sys starts with "DVB-T".
9) Removed the obsolete optparse code - argparse is always available
in Python 3.
10) Prevented a hang condition on reading from the tuner for the first
time.  If it is not configured correctly there may never be any data
to read, so now there is a timeout to prevent a hang.

There are probably a few more little things that I have fixed/changed
that I can not remember at present.



More information about the mythtvnz mailing list