Kodi Community Forum

Full Version: TVHeadend internal epg wrapper
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I have an ubuntu server with tvheadend installed via the snap store.  I created my own epg xmltv.xml file via zap2epg.py located at home/snap/tvheadend.  What is the easiest way to get TVheadend to pull in the xmltv.xml file?

I read in another thread to copy tv_grab_wgt++ file and to modify the file location and copy the file to usr/bin as root.  After doing that and restarting the tvheadend server it still does not show the epg wrapper under the epg modules tab.

Can somebody please tell me what I'm doing incorrectly or if there is an easier way to pull in the xmltv.xml file to tvheadend?

Thanks
I push the guide to tvh with this at the end of the update script.

cat /home/hts/.hts/tvheadend/scripts/guide.xml | /usr/bin/socat - UNIX-CONNECT:/home/hts/.hts/tvheadend/epggrab/xmltv.sock
(2020-11-01, 18:08)black_eagle Wrote: [ -> ]I push the guide to tvh with this at the end of the update script.

cat /home/hts/.hts/tvheadend/scripts/guide.xml | /usr/bin/socat - UNIX-CONNECT:/home/hts/.hts/tvheadend/epggrab/xmltv.sock

Thanks for replying black_eagle.

fyi, I'm not a programmer so this is kind of new to me, so I apologize in advance for my stupid question.  Under TVHeadend EPG Grabber Modules I see External XMLTV with a path of /var/snap/tvheadend/139/epggrab/xmltv.sock.  I'm assuming this is what your referring too.  so is there a file under that directory called xmltv.sock which i just put the cat statement at the bottom of it?
when I try to get into the epggrab folder via terminal it says bash: cd: epggrab: permission denied

When I view the folder via sudo nautilus it only shows a file called config

or am I suppose to create a file call xmltv.sock with the statement:
cat *****?
(2020-11-01, 21:40)Pepe999 Wrote: [ -> ]
(2020-11-01, 18:08)black_eagle Wrote: [ -> ]I push the guide to tvh with this at the end of the update script.

cat /home/hts/.hts/tvheadend/scripts/guide.xml | /usr/bin/socat - UNIX-CONNECT:/home/hts/.hts/tvheadend/epggrab/xmltv.sock

Thanks for replying black_eagle.

fyi, I'm not a programmer so this is kind of new to me, so I apologize in advance for my stupid question.  Under TVHeadend EPG Grabber Modules I see External XMLTV with a path of /var/snap/tvheadend/139/epggrab/xmltv.sock.  I'm assuming this is what your referring too.  so is there a file under that directory called xmltv.sock which i just put the cat statement at the bottom of it?
when I try to get into the epggrab folder via terminal it says bash: cd: epggrab: permission denied

When I view the folder via sudo nautilus it only shows a file called config

or am I suppose to create a file call xmltv.sock with the statement:
cat *****?
Ok, I just realized if I enable the external xmltv then the xmltv.sock file appears in the folder.  When I disable it the file disappears.

The only issue now is I can't get access to the epggrab folder where the xmltv.sock file exists to modify the location of the xmltv.xml file.
(2020-11-01, 23:12)Pepe999 Wrote: [ -> ]The only issue now is I can't get access to the epggrab folder where the xmltv.sock file exists to modify the location of the xmltv.xml file.

You can use

sudo nano /path/to/xmltv.sock

if you are trying to edit that file (if you prefer a different editor to nano you can use that instead).  Although if that is a socket then I don't think any edits would be persistent, and it may not even be something that can be edited.

Or (the Linux purists are going to hate me for telling you this) you can install Midnight Commander (sudo apt install mc) and then use that to move through the file structure.  The first time you start it up, do so as a user by typing just mc and Enter at a command prompt (so it will create the files it needs with user level permissions) but after that if you need to work on one or more files in a directory owned by the system you can use sudo mc and then anything you do will be as if you were the root user until you exit Midnight Commander.  BE CAREFUL, one wrong keystroke and you can do a lot of damage to your system quickly, so don't run mc under sudo unless you are actually wanting to work with system files, or files owned by root.

Also just so you know, there is another method for importing listings that uses a file called tv_grab_file, but the socket method is supposed to be preferable for some reason.  I keep using the older method because that's what I started with and it works, but it's a little bit hard to explain so if you get the socket method working I would stick with that.
(2020-11-02, 00:31)oldtvwatcher Wrote: [ -> ]
(2020-11-01, 23:12)Pepe999 Wrote: [ -> ]The only issue now is I can't get access to the epggrab folder where the xmltv.sock file exists to modify the location of the xmltv.xml file.

You can use

sudo nano /path/to/xmltv.sock

if you are trying to edit that file (if you prefer a different editor to nano you can use that instead).  Although if that is a socket then I don't think any edits would be persistent, and it may not even be something that can be edited.

Or (the Linux purists are going to hate me for telling you this) you can install Midnight Commander (sudo apt install mc) and then use that to move through the file structure.  The first time you start it up, do so as a user by typing just mc and Enter at a command prompt (so it will create the files it needs with user level permissions) but after that if you need to work on one or more files in a directory owned by the system you can use sudo mc and then anything you do will be as if you were the root user until you exit Midnight Commander.  BE CAREFUL, one wrong keystroke and you can do a lot of damage to your system quickly, so don't run mc under sudo unless you are actually wanting to work with system files, or files owned by root.

Also just so you know, there is another method for importing listings that uses a file called tv_grab_file, but the socket method is supposed to be preferable for some reason.  I keep using the older method because that's what I started with and it works, but it's a little bit hard to explain so if you get the socket method working I would stick with that.
Thanks for the response oldtvwatcher.  You might be giving me just enough information to make me dangerous. Smile

I tried both sudo nano and sudo mc and both gave me the same error message.
Error reading /var/snap/tvheadend/139/epggrab/xmltv.sock: no such device or address
You don't need to modify anything.  However you fetch your xml guide, with a grabber or by downloading it (and I'm assuming you have automated this with some script) then you just put the 'cat' line at the end of the script and this pushes the guide into tvheadend.

EG, I have this script, which is owned by the hts user and runs automatically via a cronjob.

#!/bin/bash

rm /home/hts/.hts/tvheadend/scripts/guide.xml
wget http://www.xmltv.co.uk/feed/8943 -O /home/hts/.hts/tvheadend/scripts/guide.xml
sleep 2
sed -i -e '/<!DOCTYPE tv SYSTEM "xmltv.dtd">/d' /home/hts/.hts/tvheadend/scripts/guide.xml
sed -i -e 's,/images/,http://xmltv.co.uk/images/,g' /home/hts/.hts/tvheadend/scripts/guide.xml
sleep 2
cat /home/hts/.hts/tvheadend/scripts/guide.xml | /usr/bin/socat - UNIX-CONNECT:/home/hts/.hts/tvheadend/epggrab/xmltv.sock

So what that does, in order is
  1. Delete any existing file
  2. Download the new file and call it guide.xml
  3. Remove a line from the file that prevents tvheadend reading it
  4. Change all the image references to point to the remote server images
  5. wait 2 seconds
  6. push the guide into tvheadend

Make sure you make your script executable and then you can call it from cron with a line similar to this.  This calls the script at 5.05AM every day, writing any errors etc into a logfile in the /tmp directory.

05 05 * * * /home/hts/.hts/tvheadend/scripts/fetch-xmltv.sh > /tmp/tvhcronjob.log 2>&1
Thanks black_eagle!

Your script worked, I just had to modify it with the zap2epg python program I'm using and change the cat location.
it ran with no issues when running as sudo and the epg got pulled into TVHeadend.

Thanks for the example it was invaluable, I will forever be your grasshopper.

I just have to add the cron job and I'll be set.