Mailing List Archive

Python 3 version of mhegepgsnoop.py
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.

_______________________________________________
mythtvnz mailing list
mythtvnz@lists.ourshack.com
https://lists.ourshack.com/mailman/listinfo/mythtvnz
Archives http://www.gossamer-threads.com/lists/mythtv/mythtvnz/
Re: Python 3 version of mhegepgsnoop.py [ In reply to ]
Thanks for the update

I run with a map file rather than the database and I thing you've got a
bug. If I specify "-f map_file" it still tries to connect to the database.

I think you need to change line 891

if py_bind:
to

elif py_bind:

Does that make sense?

> 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.
>
> _______________________________________________
> mythtvnz mailing list
> mythtvnz@lists.ourshack.com
> https://lists.ourshack.com/mailman/listinfo/mythtvnz
> Archives http://www.gossamer-threads.com/lists/mythtv/mythtvnz/
>


_______________________________________________
mythtvnz mailing list
mythtvnz@lists.ourshack.com
https://lists.ourshack.com/mailman/listinfo/mythtvnz
Archives http://www.gossamer-threads.com/lists/mythtv/mythtvnz/
Re: Python 3 version of mhegepgsnoop.py [ In reply to ]
On Wed, 12 May 2021 04:08:26 +1200, you wrote:

>Thanks for the update
>
>I run with a map file rather than the database and I thing you've got a
>bug. If I specify "-f map_file" it still tries to connect to the database.
>
>I think you need to change line 891
>
> if py_bind:
>to
>
> elif py_bind:
>
>Does that make sense?

It should only have py_bind set if you have put the -p option on the
command line to tell it to use the database. The map_file and py_bind
options are no longer mutually exclusive as both will be used if you
add the -b option, so line 891 is correct.

Can you please post your full command line so I can try to reproduce
what is happening?

_______________________________________________
mythtvnz mailing list
mythtvnz@lists.ourshack.com
https://lists.ourshack.com/mailman/listinfo/mythtvnz
Archives http://www.gossamer-threads.com/lists/mythtv/mythtvnz/
Re: Python 3 version of mhegepgsnoop.py [ In reply to ]
> On Wed, 12 May 2021 04:08:26 +1200, you wrote:
>
>>Thanks for the update
>>
>>I run with a map file rather than the database and I thing you've got a
>>bug. If I specify "-f map_file" it still tries to connect to the
>> database.
>>
>>I think you need to change line 891
>>
>> if py_bind:
>>to
>>
>> elif py_bind:
>>
>>Does that make sense?
>
> It should only have py_bind set if you have put the -p option on the
> command line to tell it to use the database. The map_file and py_bind
> options are no longer mutually exclusive as both will be used if you
> add the -b option, so line 891 is correct.
>

I pre-tune with tzap as sometimes my grabber is on different hardware.
Then run

~/bin/mhegepgsnoop-0.7.0.py -o /tmp/epg.test -z -f ~/mheg.list -d
"/dev/dvb/adapter${DVBT_CARD}/demux0" -c

Due to your logic I get an error connecting to MythTV's database

Getting channel info from MythTV database using mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using
password: NO)
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using
password: NO)

if py_bind:
# Get database channel info using Python bindings


else:
# Get database channel info from mysql

I don't want/need either option.

_______________________________________________
mythtvnz mailing list
mythtvnz@lists.ourshack.com
https://lists.ourshack.com/mailman/listinfo/mythtvnz
Archives http://www.gossamer-threads.com/lists/mythtv/mythtvnz/
Re: Python 3 version of mhegepgsnoop.py [ In reply to ]
On Wed, 12 May 2021 10:43:23 +1200, you wrote:

>> On Wed, 12 May 2021 04:08:26 +1200, you wrote:
>>
>>>Thanks for the update
>>>
>>>I run with a map file rather than the database and I thing you've got a
>>>bug. If I specify "-f map_file" it still tries to connect to the
>>> database.
>>>
>>>I think you need to change line 891
>>>
>>> if py_bind:
>>>to
>>>
>>> elif py_bind:
>>>
>>>Does that make sense?
>>
>> It should only have py_bind set if you have put the -p option on the
>> command line to tell it to use the database. The map_file and py_bind
>> options are no longer mutually exclusive as both will be used if you
>> add the -b option, so line 891 is correct.
>>
>
>I pre-tune with tzap as sometimes my grabber is on different hardware.
>Then run
>
>~/bin/mhegepgsnoop-0.7.0.py -o /tmp/epg.test -z -f ~/mheg.list -d
>"/dev/dvb/adapter${DVBT_CARD}/demux0" -c
>
>Due to your logic I get an error connecting to MythTV's database
>
>Getting channel info from MythTV database using mysql
>ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using
>password: NO)
>ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using
>password: NO)
>
> if py_bind:
> # Get database channel info using Python bindings
>
>
> else:
> # Get database channel info from mysql
>
>I don't want/need either option.

It was not the py_bind option, it was the new both option. I have put
a new version on my web server that has the right checks there now:

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

_______________________________________________
mythtvnz mailing list
mythtvnz@lists.ourshack.com
https://lists.ourshack.com/mailman/listinfo/mythtvnz
Archives http://www.gossamer-threads.com/lists/mythtv/mythtvnz/
Re: Python 3 version of mhegepgsnoop.py [ In reply to ]
> On Wed, 12 May 2021 10:43:23 +1200, you wrote:
>
>>> On Wed, 12 May 2021 04:08:26 +1200, you wrote:
>>>
>>>>Thanks for the update
>>>>
>>>>I run with a map file rather than the database and I thing you've got a
>>>>bug. If I specify "-f map_file" it still tries to connect to the
>>>> database.
>>>>
>>>>I think you need to change line 891
>>>>
>>>> if py_bind:
>>>>to
>>>>
>>>> elif py_bind:
>>>>
>>>>Does that make sense?
>>>
>>> It should only have py_bind set if you have put the -p option on the
>>> command line to tell it to use the database. The map_file and py_bind
>>> options are no longer mutually exclusive as both will be used if you
>>> add the -b option, so line 891 is correct.
>>>
>>
>>I pre-tune with tzap as sometimes my grabber is on different hardware.
>>Then run
>>
>>~/bin/mhegepgsnoop-0.7.0.py -o /tmp/epg.test -z -f ~/mheg.list -d
>>"/dev/dvb/adapter${DVBT_CARD}/demux0" -c
>>
>>Due to your logic I get an error connecting to MythTV's database
>>
>>Getting channel info from MythTV database using mysql
>>ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using
>>password: NO)
>>ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using
>>password: NO)
>>
>> if py_bind:
>> # Get database channel info using Python bindings
>>
>>
>> else:
>> # Get database channel info from mysql
>>
>>I don't want/need either option.
>
> It was not the py_bind option, it was the new both option. I have put
> a new version on my web server that has the right checks there now:
>
> http://www.jsw.gen.nz/mythtv/mhegepgsnoop-0.7.1.py
>

Awesome. Works perfectly for me. Thanks for all the hard work.

_______________________________________________
mythtvnz mailing list
mythtvnz@lists.ourshack.com
https://lists.ourshack.com/mailman/listinfo/mythtvnz
Archives http://www.gossamer-threads.com/lists/mythtv/mythtvnz/