[mythtvnz] EPG Using mhegepgsnoop.py success

Robert Fisher robert at fisher.net.nz
Sun Jul 3 22:45:07 BST 2022


I want to express my thanks and praise to Stephen Worthington for the 
work recently done,

firstly by creating a "how-to" to set up his mhegepgsnoop.py (copied 
below into this post)

and secondly helping me to sort out why it wasn't quite working 
correctly on my system.

(I will leave it to Stephen to decide if he wants to publish the two 
tweaks I needed to make it work properly)

The big advantage to using this method is that 3rd Party EPG sources are 
not permanently reliable.

Rob

----------------------------------------------------------------------------------------------------------------------------------------

So here is a full set of instructions (I hope) for getting set up to use
mhepgsnoop and xmltv-proc-nz.

In mythtv-setup, select "No grabber" for the EPG source and disable
EIT. Disable the automatic running of mythfilldatabase. Note down
the time you currently have mythfilldatabase running at. Exit
mythtv-setup.

Then run these commands:

sudo su
cd /usr/local/bin
wget http://www.jsw.gen.nz/mythtv/mhegepgsnoop-0.7.2.py
mv -v mhegepgsnoop-0.7.2.py mhegepgsnoop.py
wget http://www.jsw.gen.nz/mythtv/do_mhegepgsnoop3.sh
wget http://www.jsw.gen.nz/mythtv/xmltv-proc-nz
mv -v do_mhegepgsnoop3.sh do_mhegepgsnoop.sh
mkdir -p /home/mythtv/.mythtv
chown mythtv:mythtv /home/mythtv/.mythtv

Ignore any error or warning messages that occur in the last two
commands above if you already have a .mythtv directory.

Now edit do_mhegepgsnoop.sh (as root) and check the configuration at
the top of the file. The SOURCEID needs to be set to the sourceid of
your FreeviewHD DVB-T channels, and the ADAPTER needs to be set to the
adapter number (the x in /dev/dvb/adapter<x>) of one of your DVB-T(2)
adapters. It is probably best to choose the one that is used least
often, which will normally be the one with the highest number, but it
depends on how you have your tuner priority and schedorder values set
up. Of course, if you have a spare tuner not being used (ie > 5
DVB-T(2) tuners), select that to be used for mhegepgsnoop.

These commands will show you your sourceid values:

mysql mythconverg
select sourceid,name,xmltvgrabber,useeit from videosource order by
sourceid;
quit

And these commands should show you the tuners configured in MythTV:

mysql mythconverg
select
cardid,parentid,videodevice,cardtype,inputname,sourceid,displayname,schedorder,livetvorder
from capturecard order by videodevice,cardid;
quit

Now continue running these commands as root:

cd /usr/local/bin
chmod u=rwx,g=rx,o=rx mhegepgsnoop.py do_mhegepgsnoop.sh
chmod u=rwx,g=rx,o=rx xmltv-proc-nz
cd /var/www/html
wget http://www.jsw.gen.nz/mythtv/xmltv-proc-nz-json.tgz
tar xvf xmltv-proc-nz-json.tgz

Now check the three +json files in the subdirectories under the
/var/www/html/json directory. Make sure they are using the same
xmltvid values that you have on your system. These commands will
show your current xmltvid values:

mysql mythconverg
select chanid,channum,name,callsign,xmltvid,serviceid from channel
where sourceid=<x> order by channum+0;
quit

Replace <x> with the correct sourceid. If your xmltvid values are
different from the +json ones, you can choose to change either the
ones in the channel table, or the ones in the +json files, so that
they match. If you are not using Sky EPG as well as FreeviewHD EPG,
you can ignore the xmltvid values in the sky-movies-xmltvids/+json
file.

Now continue running these commands as root:

cd /etc/systemd/system
wget http://www.jsw.gen.nz/mythtv/epg.service
wget http://www.jsw.gen.nz/mythtv/epg.timer

Now you need to edit the epg.timer file and change the two places
where it says "15:10" to be whatever time you normally run
mythfilldatabase.

Now continue running these commands as root:

cd /etc/systemd/system
chmod u=rw,g=r,o=r epg.service epg.timer
systemctl daemon-reload
systemctl enable epg.timer
exit

At this point everything should be set up and EPG will be
automatically downloaded from MHEG5, processed by xmltv-proc-nz and
loaded into the database by mythfilldatabase, at the time specified.

To test if it is working, or if you ever want to run EPG collection
manually for some reason, do this:

sudo systemctl start epg

To see the status of EPG collection, this command will show you when
the next automatic EPG collection will be done:

systemctl status epg.timer

and this will show you the result of the last EPG run:

systemctl status epg

and this will show you the full output from epg.service, including the
full output of do_mhegepgsnoop.sh, mhegepgsnoop.py, xmltv-proc-nz and
mythfilldatabase:

journalctl -eu epg

You will be in a "less" command showing the end of the systemd journal
for epg.service - page up to see more.

Should you want to check it, the last downloaded EPG will always be
stored here:

/home/mythtv/.mythtv/freeview.xml

This is the version after xmltv-proc-nz processing. If you also want
to keep a copy of the raw MHEG5 data as downloaded, edit
do_mhegepgsnoop and change the TEMP_FILE= line to:

TEMP_FILE=/home/mythtv/.mythtv/freeview-raw.xml

Or you can just look at the /tmp/xmltv.xml file (if you have not
rebooted since EPG was last run.

I do not have a system I can test the above on, so please let me know
if I have done a typo somewhere or if something does not work.





More information about the mythtvnz mailing list