{"id":1186,"date":"2024-10-15T10:51:35","date_gmt":"2024-10-14T22:51:35","guid":{"rendered":"https:\/\/fishy.fisher.net.nz\/?page_id=1186"},"modified":"2024-10-15T10:51:53","modified_gmt":"2024-10-14T22:51:53","slug":"stephen-worthingtons-mhegepgsnoop-py-how-to","status":"publish","type":"page","link":"https:\/\/fishy.fisher.net.nz\/?page_id=1186","title":{"rendered":"Stephen Worthington&#8217;s mhegepgsnoop.py How-To"},"content":{"rendered":"\n<p>In mythtv-setup, select &#8220;No grabber&#8221; for the EPG source and disable<br>EIT. Disable the automatic running of mythfilldatabase. Note down<br>the time you currently have mythfilldatabase running at. Exit<br>mythtv-setup.<\/p>\n\n\n\n<p>Then run these commands:<\/p>\n\n\n\n<p>sudo su<br>cd \/usr\/local\/bin<br>wget http:\/\/www.jsw.gen.nz\/mythtv\/mhegepgsnoop-0.7.4.py<br>mv -v mhegepgsnoop-0.7.4.py mhegepgsnoop.py<br>wget http:\/\/www.jsw.gen.nz\/mythtv\/do_mhegepgsnoop3.sh<br>wget http:\/\/www.jsw.gen.nz\/mythtv\/xmltv-proc-nz<br>mv -v do_mhegepgsnoop3.sh do_mhegepgsnoop.sh<br>mkdir -p \/home\/mythtv\/.mythtv<br>chown mythtv:mythtv \/home\/mythtv\/.mythtv<\/p>\n\n\n\n<p>Ignore any error or warning messages that occur in the last two<br>commands above if you already have a .mythtv directory.<\/p>\n\n\n\n<p>Now edit do_mhegepgsnoop.sh (as root) and check the configuration at<br>the top of the file. The SOURCEID needs to be set to the sourceid of<br>your FreeviewHD DVB-T channels, and the ADAPTER needs to be set to the<br>adapter number (the x in \/dev\/dvb\/adapter) of one of your DVB-T(2)<br>adapters. It is probably best to choose the one that is used least<br>often, which will normally be the one with the highest number, but it<br>depends on how you have your tuner priority and schedorder values set<br>up. Of course, if you have a spare tuner not being used (ie &gt; 5<br>DVB-T(2) tuners), select that to be used for mhegepgsnoop.<\/p>\n\n\n\n<p>These commands will show you your sourceid values:<\/p>\n\n\n\n<p>mysql mythconverg<br>select sourceid,name,xmltvgrabber,useeit from videosource order by<br>sourceid;<br>quit<\/p>\n\n\n\n<p>And these commands should show you the tuners configured in MythTV:<\/p>\n\n\n\n<p>mysql mythconverg<br>select<br>cardid,parentid,videodevice,cardtype,inputname,sourceid,displayname,schedorder,livetvorder<br>from capturecard order by videodevice,cardid;<br>quit<\/p>\n\n\n\n<p>Now continue running these commands as root:<\/p>\n\n\n\n<p>cd \/usr\/local\/bin<br>chmod u=rwx,g=rx,o=rx mhegepgsnoop.py do_mhegepgsnoop.sh<br>chmod u=rwx,g=rx,o=rx xmltv-proc-nz<br>cd \/var\/www\/html<br>wget http:\/\/www.jsw.gen.nz\/mythtv\/xmltv-proc-nz-json.tgz<br>tar xvf xmltv-proc-nz-json.tgz<\/p>\n\n\n\n<p>Now check the three +json files in the subdirectories under the<br>\/var\/www\/html\/json directory. Make sure they are using the same<br>xmltvid values that you have on your system. These commands will<br>show your current xmltvid values:<\/p>\n\n\n\n<p>mysql mythconverg<br>select chanid,channum,name,callsign,xmltvid,serviceid from channel<br>where sourceid= order by channum+0;<br>quit<\/p>\n\n\n\n<p>Replace with the correct sourceid. If your xmltvid values are<br>different from the +json ones, you can choose to change either the<br>ones in the channel table, or the ones in the +json files, so that<br>they match. If you are not using Sky EPG as well as FreeviewHD EPG,<br>you can ignore the xmltvid values in the sky-movies-xmltvids\/+json<br>file.<\/p>\n\n\n\n<p>Now continue running these commands as root:<\/p>\n\n\n\n<p>cd \/etc\/systemd\/system<br>wget http:\/\/www.jsw.gen.nz\/mythtv\/epg.service<br>wget http:\/\/www.jsw.gen.nz\/mythtv\/epg.timer<\/p>\n\n\n\n<p>Now you need to edit the epg.timer file and change the two places<br>where it says &#8220;15:10&#8221; to be whatever time you normally run<br>mythfilldatabase.<\/p>\n\n\n\n<p>Now continue running these commands as root:<\/p>\n\n\n\n<p>cd \/etc\/systemd\/system<br>chmod u=rw,g=r,o=r epg.service epg.timer<br>systemctl daemon-reload<br>systemctl enable epg.timer<br>exit<\/p>\n\n\n\n<p>At this point everything should be set up and EPG will be<br>automatically downloaded from MHEG5, processed by xmltv-proc-nz and<br>loaded into the database by mythfilldatabase, at the time specified.<\/p>\n\n\n\n<p>To test if it is working, or if you ever want to run EPG collection<br>manually for some reason, do this:<\/p>\n\n\n\n<p>sudo systemctl start epg<\/p>\n\n\n\n<p>To see the status of EPG collection, this command will show you when<br>the next automatic EPG collection will be done:<\/p>\n\n\n\n<p>systemctl status epg.timer<\/p>\n\n\n\n<p>and this will show you the result of the last EPG run:<\/p>\n\n\n\n<p>systemctl status epg<\/p>\n\n\n\n<p>and this will show you the full output from epg.service, including the<br>full output of do_mhegepgsnoop.sh, mhegepgsnoop.py, xmltv-proc-nz and<br>mythfilldatabase:<\/p>\n\n\n\n<p>journalctl -eu epg<\/p>\n\n\n\n<p>You will be in a &#8220;less&#8221; command showing the end of the systemd journal<br>for epg.service &#8211; page up to see more.<\/p>\n\n\n\n<p>Should you want to check it, the last downloaded EPG will always be<br>stored here:<\/p>\n\n\n\n<p>\/home\/mythtv\/.mythtv\/freeview.xml<\/p>\n\n\n\n<p>This is the version after xmltv-proc-nz processing. If you also want<br>to keep a copy of the raw MHEG5 data as downloaded, edit<br>do_mhegepgsnoop and change the TEMP_FILE= line to:<\/p>\n\n\n\n<p>TEMP_FILE=\/home\/mythtv\/.mythtv\/freeview-raw.xml<\/p>\n\n\n\n<p>Or you can just look at the \/tmp\/xmltv.xml file (if you have not<br>rebooted since EPG was last run.<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In mythtv-setup, select &#8220;No grabber&#8221; for the EPG source and disableEIT. Disable the automatic running of mythfilldatabase. Note downthe time you currently have mythfilldatabase running at. Exitmythtv-setup. Then run these commands: sudo sucd \/usr\/local\/binwget http:\/\/www.jsw.gen.nz\/mythtv\/mhegepgsnoop-0.7.4.pymv -v mhegepgsnoop-0.7.4.py mhegepgsnoop.pywget http:\/\/www.jsw.gen.nz\/mythtv\/do_mhegepgsnoop3.shwget http:\/\/www.jsw.gen.nz\/mythtv\/xmltv-proc-nzmv -v do_mhegepgsnoop3.sh do_mhegepgsnoop.shmkdir -p \/home\/mythtv\/.mythtvchown mythtv:mythtv \/home\/mythtv\/.mythtv Ignore any error or warning messages that occur [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-1186","page","type-page","status-publish","hentry","post-preview"],"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/fishy.fisher.net.nz\/index.php?rest_route=\/wp\/v2\/pages\/1186","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fishy.fisher.net.nz\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/fishy.fisher.net.nz\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/fishy.fisher.net.nz\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fishy.fisher.net.nz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1186"}],"version-history":[{"count":2,"href":"https:\/\/fishy.fisher.net.nz\/index.php?rest_route=\/wp\/v2\/pages\/1186\/revisions"}],"predecessor-version":[{"id":1188,"href":"https:\/\/fishy.fisher.net.nz\/index.php?rest_route=\/wp\/v2\/pages\/1186\/revisions\/1188"}],"wp:attachment":[{"href":"https:\/\/fishy.fisher.net.nz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1186"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}