Tvheadend server is used for grabbing video streams and publishing them as Internet streams. These video streams can come from a tuner card grabbing over-the-air signals or cable channels. The video streams can also come from various Internet TV providers. The beauty of Tvheadend is that you can add all these various stream sources in one place and then access them over your home network or the Internet via your mobile phone, web browser, VLC, or Kodi. Tvheadend also comes pre-packaged with various electronic program guide (EPG) modules. In addition to Over-the-air EPG (which is enabled by default) you can also add various internal or external XMLTV guide data. The later, “External: XMLTV”, is what I’ll be focusing on here.
In order to complete this guide you will need SSH or direct access to your TVheadend server with root privileges. You will also need to be able to access the Tvheadend web interface with admin rights.
Note: You must be using Tvheadend 4.2 or newer as that is the first version that includes the external XMLTV grabber by default. Also make sure you have already added your video sources (Networks) and mapped any services. Follow the Tvheadend docs for more information.
Activate the “External: XMLTV” Grabber Module
First thing you want to do is activate the “External: XMLTV” Grabber Module. In the Tvheadend web interface navigate to: Configuration > Channel / EPG > EPG Grabber Modules Highlight the “External: XMLTV” row and in the panel to the right tick the box “Enable” followed by the “Save” button above.
Verify that it was created:
(If it wasn’t created reboot your server.)
Create a Cron Script to Download XMLTV Listings
Your source for guide listings will differ but the process will be relatively the same. Create a new file with the contents of the code snippet below in your preferred location.
Create a new file:
Copy and paste the following:
#!/bin/bash rm /home/hts/xmltvlog/xmltv.log rm /home/hts/epg.xml* touch /home/hts/xmltvlog/xmltv.log echo "Download starting..." >> /home/hts/xmltvlog/xmltv.log echo "Time: $(date)" >> /home/hts/xmltvlog/xmltv.log # Example: Standard xml file wget http://www.domain.tld/epg.xml -P /home/hts -nv -a /home/hts/xmltvlog/$ # Example: Rename file to epg.xml #wget -O epg.xml http://domain.tld:8080/xmltv.php?username=test # Example: Compressed xml file #wget http://www.domain.tld/epg.xml.gz -P /home/hts/ -nv -a /home/hts/xmltvlog/xmltv$ #gunzip /home/hts/epg.xml.gz -f cat /home/hts/epg.xml | sudo socat - UNIX-CONNECT:/home/hts/.hts/tvheadend/epg$ echo "" >> /home/hts/xmltvlog/xmltv.log echo "Time: $(date)" >> /home/hts/xmltvlog/xmltv.log echo "EPG Updated successfully." >> /home/hts/xmltvlog/xmltv.log
Make it executeable:
chmod a+x /home/hts/epggrab
Run it to make sure it works:
Add the EPG Grabber Cron Script to the Crontab
As root, add the following line to the end of the crontab located at
/etc/crontabe. This will run your EPG Grabber once a day at 3am.
00 3 * * * root /home/hts/epggrab
Until this feature is more completely built into Tvheadend this method will have to work for getting an external xmltv program guide working. If they guide data isn’t populating always check the system error log, cron logs, and validity of the xml source data.
Originally sourced from comments: http://forum.koditvepg.com/thread.php/guide_for_installing_and_setting_up_tvheadend_iptv_epg_.1