Kodi Community Forum

Full Version: How to upload my own EPG .xml into TVHeadEnd
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am a bit confused from what I have looked at online as to how I can upload my own custom .xml EPG file into TVHeadEnd on Linux. Can anyone asssit?
Yep.  In TVH go to Configuration -> channel/EPG -> EPG Grabber Modules. 

Enable the first line that says "Internal: XMLTV: /usr/bin/tv_grab_wg++ is a wrapper grabber around WebGrabPlus+

If you don't see that line in tvh, its probably because the wrapper isn't installed.  It is easily created though via nano or whatever (needs sudo to write in that directory).

Code:
#!/bin/bash
xmltv_file_location=/home/xbmc/.wg++/guide.xml
dflag=
vflag=
cflag=
if (( $# < 1 ))
then
  cat "$xmltv_file_location"
  exit 0
fi

for arg
do
    delim=""
    case "$arg" in
    #translate --gnu-long-options to -g (short options)
       --description) args="${args}-d ";;
       --version) args="${args}-v ";;
       --capabilities) args="${args}-c ";;
       #pass through anything else
       *) [[ "${arg:0:1}" == "-" ]] || delim="\""
           args="${args}${delim}${arg}${delim} ";;
    esac
done

#Reset the positional parameters to the short options
eval set -- $args

while getopts "dvc" option
do
    case $option in
        d)  dflag=1;;
        v)  vflag=1;;
        c)  cflag=1;;
        \?) printf "unknown option: -%s\n" $OPTARG
            printf "Usage: %s: [--description] [--version] [--capabilities] \n" $(basename $0)
            exit 2
            ;;
    esac >&2
done

if [ "$dflag" ]
then
   printf "$0 is a wrapper grabber around WebGrab+Plus\n"
fi
if [ "$vflag" ]
then
   printf "0.1\n"
fi
if [ "$cflag" ]
then
   printf "baseline\n"
fi

exit 0

Set xmltv_file_location in the top of that file to point to your xmltv guide.  Make tv_grab_wg++ executable.

Go back to TVH and click 're-run internal grabbers'.   Wait a while for the tv guide to become populated.
Another option is to use tv-grab-file from https://github.com/Rigolo/tv-grab-file

There's an article at https://freetoairamerica.wordpress.com/2...-frontend/ that may be helpful even though it's for a slightly different purpose.  Really you need to make sure your .xml file is in the correct format, then it should be relatively easy to get Tvheadend to read it in using one of the external grabbers mentioned in this thread.  If it doesn't work check that your grabber is executable and that it can be run by the hts (Tvheadend) user, in other words if it's owned by root make sure it can be executed by any user.  Also make sure your xml file can be read by the hts user.  Linux permissions will get you every time!
(2018-09-24, 13:04)xbmclinuxuser Wrote: [ -> ]Another option is to use tv-grab-file from https://github.com/Rigolo/tv-grab-file

There's an article at https://freetoairamerica.wordpress.com/2...-frontend/ that may be helpful even though it's for a slightly different purpose.  Really you need to make sure your .xml file is in the correct format, then it should be relatively easy to get Tvheadend to read it in using one of the external grabbers mentioned in this thread.  If it doesn't work check that your grabber is executable and that it can be run by the hts (Tvheadend) user, in other words if it's owned by root make sure it can be executed by any user.  Also make sure your xml file can be read by the hts user.  Linux permissions will get you every time!
 apologies for the slow reply, i am away with work. with regards to your wordpress link, in this bit:

"If typing “which nc” returned a path, then you can use this to import your guide data into Tvheadend using the socket method, replacing the paths and filenames as needed:
cat /home/hts/.xmltv/tv_grab_file.xmltv | nc -w 5 -U /home/hts/.hts/tvheadend/epggrab/xmltv.sock"

...I am a bit confused as to how this relates to importing my custom .xml file. which bit of the command is the source and which is the target?
(2018-09-27, 00:17)gdogg371 Wrote: [ -> ]
(2018-09-24, 13:04)xbmclinuxuser Wrote: [ -> ]Another option is to use tv-grab-file from https://github.com/Rigolo/tv-grab-file

There's an article at https://freetoairamerica.wordpress.com/2...-frontend/ that may be helpful even though it's for a slightly different purpose.  Really you need to make sure your .xml file is in the correct format, then it should be relatively easy to get Tvheadend to read it in using one of the external grabbers mentioned in this thread.  If it doesn't work check that your grabber is executable and that it can be run by the hts (Tvheadend) user, in other words if it's owned by root make sure it can be executed by any user.  Also make sure your xml file can be read by the hts user.  Linux permissions will get you every time!
 apologies for the slow reply, i am away with work. with regards to your wordpress link, in this bit:

"If typing “which nc” returned a path, then you can use this to import your guide data into Tvheadend using the socket method, replacing the paths and filenames as needed:
cat /home/hts/.xmltv/tv_grab_file.xmltv | nc -w 5 -U /home/hts/.hts/tvheadend/epggrab/xmltv.sock"

...I am a bit confused as to how this relates to importing my custom .xml file. which bit of the command is the source and which is the target?   

cat /home/hts/.xmltv/tv_grab_file.xmltv is the source path, /home/hts/.hts/tvheadend/epggrab/xmltv.sock is the target.

To elaborate a bit, cat is a command that takes a filename and writes the content to somewhere, or stdin if you don't tell it where to write (so it writes it into the terminal you type the command in).  nc does a similar thing but reads and writes across network connections.  | (pipe) sends the output of one command to the input of the next.

So the whole thing takes the contents of a file and writes that to the input of nc, which writes it out again to TVH's socket.  When that grabber in TVH is enabled, it is constantly listening for input on that socket. It is unlikely that TVH is installed in a different place (unless you deliberately told it to install somewhere else) so the second path I would expect to be correct.  The only path you need to change is the one that points to your custom xmltv file.

So, cat /path/to/custom/xmltv.filename | nc -w 5 -U /home/hts/.hts/tvheadend/epggrab/xmltv.sock.  If you want to know, -w 5 means wait 5 seconds before timing out (if TVH doesn't respond) and -U means UNIX-Domain sockets.

HTH
ok, im nearly there with this now, so thanks for the support both. i've copied the EPG XML data over as the HTS user and can see EPG sources for my channels...when i open kodi i can now also see channel icons, however the guide is still empty. i know this particular .xml source builds a valid EPG guide as it works in NPVR on windows...have i missed a step out in tvheadend somewhere?
...also mapping channels is now just hanging at 0 mapped since i pulled in the EPG .xml...
Guide data can take a while to appear in TVH's interface I have noticed.  If you navigate to it with your browser and login, down at the bottom right there is a 'chevron' pointing up (Two of ^ one on top of the other).  Click that ONCE and it will open a little window in the bottom that shows the TVH log.

Now open an terminal window over the top but resize it so you can still see the log window and execute your command again to send the xmltv file to TVH.  You should see some stuff in the log window related to importing your xml file.  For instance, I get this

Code:
2018-09-28 07:52:18.309 xmltv: /usr/bin/tv_grab_wg++: grab /usr/bin/tv_grab_wg++
2018-09-28 07:52:18.323 spawn: Executing "/usr/bin/tv_grab_wg++"
2018-09-28 07:52:18.916 xmltv: /usr/bin/tv_grab_wg++: grab took 1 seconds
2018-09-28 07:52:20.461 xmltv: /usr/bin/tv_grab_wg++: parse took 1 seconds
2018-09-28 07:52:20.461 xmltv: /usr/bin/tv_grab_wg++: channels tot= 124 new= 0 mod= 0
2018-09-28 07:52:20.461 xmltv: /usr/bin/tv_grab_wg++: brands tot= 0 new= 0 mod= 0
2018-09-28 07:52:20.461 xmltv: /usr/bin/tv_grab_wg++: seasons tot= 0 new= 0 mod= 0
2018-09-28 07:52:20.461 xmltv: /usr/bin/tv_grab_wg++: episodes tot= 0 new= 0 mod= 0
2018-09-28 07:52:20.461 xmltv: /usr/bin/tv_grab_wg++: broadcasts tot=28392 new= 1493 mod= 2917

Yours will be different as you are importing it via the socket but I imagine it'll be similar enough for you to know whether or not it's worked.

...I mapped all my channels first.  If it's stopping at zero I'd imagine that it can't find anything to map.  Again, look in that log window when trying to map a channel and see what TVH does.
no idea why, but i did the socket push one more time and this time it worked!
...also, once i gave my virtual machine 6GB of RAM and 8 virtual cores and i attempted to stream at home on my fast broadband, rather than piggy backing onto 4G whilst away with work it seems to stream IPTV content like that pretty good...
Great to know it's working Smile

If you haven't already, add the socket push line to the end of whatever updates your xmltv guide and then add a call to that from cron so that it auto-updates each day.
I haven’t done that bit yet, but will do thanks. I need to add write a python script to download it from the provider each day and unpack it for the cron to pick up as well.
(2018-09-29, 16:38)gdogg371 Wrote: [ -> ]I haven’t done that bit yet, but will do thanks. I need to add write a python script to download it from the provider each day and unpack it for the cron to pick up as well.

another NextPVR user using zap2xml to pull EPG from zap2it. It updates every day and pull 14 day EPG. 

Can I use the same XML file for TVH (which is running in Windows Subsystem Linux)? How?
(2019-08-27, 17:10)acegolfer Wrote: [ -> ]
(2018-09-29, 16:38)gdogg371 Wrote: [ -> ]I haven’t done that bit yet, but will do thanks. I need to add write a python script to download it from the provider each day and unpack it for the cron to pick up as well.

another NextPVR user using zap2xml to pull EPG from zap2it. It updates every day and pull 14 day EPG. 

Can I use the same XML file for TVH (which is running in Windows Subsystem Linux)? How? 

I'll answer my own question. Yes. In TVH, I had tv_grab_file locate the same XMLTV file I used for NextPVR. TVH reads it without issues.