Skip to content

Guide: How to Setup XMLTV for TVHeadEnd

rocky4546 edited this page Mar 26, 2017 · 10 revisions

XMLTV Setup

External Requirements

zap2xml.pl

Download the current copy of zap2xml.pl
Follow section zap2xml zap2it.com setup at http://zap2xml.awardspace.info
to Register and manage the favorite channels that are collected into the xmltv.xml file

xmltv-util package

On linux, run command "apt list | grep xmltv". Confirm xmltv-util says "[installed,automatic]". If not, install the package. The command "tv_find_grabbers" will list all the grabbers available on the system

Automated Installation

This automated installer will review and validate your system and let you know if there is something not right. It can be executed over and over until all issues are resolved and the software is deployed. At the end, there are manual steps that are still needed inside of TVHeadend website, but as much as possible has been automated.

  1. Download the latest release
  2. Unzip the release into a folder
  3. Run the command ./install.sh as yourself (it uses sudo to perform root-based commands)
  4. The script will either complete successfully or fail with an "ERROR: ..."
  5. Correct the error and run install.sh again.
  6. Once installed, go to the section How to Manually Update the EPG

The final configuration is

  • 14 days of a guide will be obtained
  • Only the next 2 days are updated each day to support being nice to zap2it.com
  • Time delays between HTTP requests to zap2it.com are in place to support being nice to zap2it.com
  • Cronjob is enabled to run once each morning to grab the data from zap2it.com
  • TVHeadend EPG Content Type is populated for all TV Shows except those whose genre is Series only or Unknown/None
  • TVHeadend is updated independently at some point after the cronjob executes

How to manually update the EPG

Manually Generate xmltv.xml

TBD

Manually Re-import xmltv.xml into TVHeadend

TBD

Manual Installation

This is the manual instructions that can be accomplished instead of using the install.sh script. The installation instructions are for TVHeadend 4.1. The GUI is different on 4.0, but is available. You may need to hunt to find the items since they have been moved.

Setup of zap2xml.pl and tvheadend

  1. Grap the zap2xml.pl file from the URL above and place in ~/xmltv/
  2. Make sure the file is executable using the command: chmod 775 zap2xml.pl
  3. Use the x.zap2xmlrc file in the code area. Change the filename to .zap2xmlrc and set email/password and username and place in home folder ~
  4. Test initial setup and create an xmltv_default.xml file by running the command
    ./zap2xml.pl -D -S 3
    rename resulting xmltv_default.xml to xmltv.xml
  5. Now the key to making it all work... softlink the xmltv folder to where tvheadend is installed. For me it is installed in /home/hts (where the .hts folder is located.) To make the softlink type
    sudo su - hts
    ln -s /home/[user]/xmltv .xmltv
    This should create a .xmltv folder in /home/hts pointing to where your xmltv.xml file is being generated.
  6. Install tv_grab_file from the code area (go to usr/bin) to /usr/bin as root. Change permissions to 755 (chmod 755 tv_grab_file). I recommend rebooting at this point.
  7. In TVHeadend website, go to Configuration -> Channel / EPG -> EPG Grabber Modules
    A list will appear. Go through it and make sure nothing is checked on the left side (just a round dot should be present instead of a round dot with a check inside) Look for "Internal: XMLTV: tv_grab_file reads ..." and enable that. That line should now have a check on the left
  8. In TVHeadend website, go to Configuration -> Channel / EPG -> EPG Grabber
  9. I have the settings check "Update Channel Number". Periodically save ... = 0. Cron multiline: I have the following
    0 5 * * *
    0 8 * * *
    0 12 * * *

My xmltv.xml file is generated between 3-5am every day. The above setting will pull in the same xmltv.xml file at 5am, 8am and 12 noon every day. The reason for multiple pulls is the tvheadend and kodi ingest process may not totally update all entries on the first ingest. I have not found an issue ingesting the same xmltv.xml file multiple times. BEFORE you click save, click on the 3 ^ in the bottom right corner. It brings up the tvheadend console window. Now click Save. If it works, you should see something like

xmltv: /usr/bin/tv_grab_file: channels tot= 55 new= 0 mod= 0
xmltv: /usr/bin/tv_grab_file: brands tot= 0 new= 0 mod= 0
xmltv: /usr/bin/tv_grab_file: seasons tot=22195 new=22195 mod=22195
xmltv: /usr/bin/tv_grab_file: episodes tot=22975 new= 9363 mod=17387
xmltv: /usr/bin/tv_grab_file: broadcasts tot=22975 new= 425 mod= 425

SUCCESS! You now have your EPG filled with info which you can link to channels.

Setup to update xmltv.xml

WHAT IT WILL DO: The update will change the genres to what tvheadend expects. This allows the tvguide to have colors based on genre instead of mostly grey. It also adds the season/episode to the sub-title and adds the original genre, the original date aired and the season/episode to the top of the description.

  1. Install from the code area the two files in the xmltv folder into your xmltv folder containing the zap2xml.pl file
  2. Make sure the files are executable by chmod 775 * from inside the xmltv folder
  3. Create a cronjob to create the daily xmltv.xml file by typing the following command
    crontab -e
    This will bring up the crontab file in edit mode using the vi editor. You will need to use vi command to add the following line to the end of the file.
    mm hh * * * /home/[user]/xmltv/zap2xml.sh >/dev/null 2>&1
    Fill in the mm, hh and user with a time between 3 and 5 am. For 4:27am use "27 4 * * * ..."
  4. List your changes to the crontab by the command: crontab -l
  5. After running zap2xml.sh, a log file is generated in ~/.kodi/temp/zap2xml.log It will contain information at the end of the file which will indicate if it was successful.

Using Icons with xmltv.xml

First, you can use the xmltv.xml to download the icons, but I highly recommend finding good ones on the internet. The icons auto retrieved are fuzzy at best and when they are listed in the xmltv.xml, tvheadend will force their use. Just fill out the Configuration -> Channel / EPG -> Channels (icon column).

EX: "file:///home/[user]/xmltv/icons/4.1.png"

Be Nice To zap2it.com Settings

The methods above use parameters and arguments that reduce the load to zap2it.com allowing all of us to use the service without impacting the server.

  1. Only grap the xmltv.xml once a day from zap2it.com
  2. In the .zap2xmlrc, we set nsdays=0 (don't remove any cache days from the end) and ncsdays=2 (only remove 2 cache days from the front). This means that out of the 14 days guide that are cached, only 2 days are refreshed, so the other 12 days are reused and the server will not be contacted.
  3. On the command line, there is a "-S 3" This option causes the script to request information from the server at 3 second intervals. Without this option, the server is hammered at 100-200 requests per minute. Being nice helps everyone. ;)

Other Links

Zap2xml for ATSC in OpenELEC by edit4ever
some-hints-for-getting-free-to-air-satellite-channels-into-the-electronic-program-guide-in-kodi-or-xbmc-or-another-frontend