HOWTO: Three ways to use xmltv.sock
#1
There are few posts about the two firsts so I'm only writing them down for the record:

1. Use socat, it's the easiest and it works great, socat also available at the Unofficial Addons Repo of OpenELEC but only for x86_64.
Code:
cat xmltv.xml | socat - UNIX-CONNECT:/home/hts/.hts/tvheadend/epggrab/xmltv.sock

2. Use openbsd-netcat, thanks for luuthe on the hts channel at freenode, notice the 5s timeout as netcat doesn't exit properly, I'm not sure if it's available at all for OpenELEC.
Code:
cat xmltv.xml | nc -w 5 -U /home/hts/.hts/tvheadend/epggrab/xmltv.sock

3. Use curl, unix socket is relatively new feature of curl v7.40, in OpenELEC this version is only in master branch hopefully in next update it will be available, notice the 5s timeout and the fact I had to supplied some url (doesn't matter which).
Code:
curl -d @xmltv.xml -X POST -m 5 --unix-socket /home/hts/.hts/tvheadend/epggrab/xmltv.sock http://google.com
Reply
#2
My tiny PR for adding socat for all platforms on OpenELEC was approved so now (or at least on next update) socat is available also for RPi and imx6 from the unofficial OpenELEC addons, hurray ! this is the best solution (if you like me can't use the tv_grab_file script from tvheadend addon settings).
Reply
#3
Can you please explain what this is?
xmltv.sock & socat
Reply
#4
(2015-02-01, 00:03)Jönke Wrote: Can you please explain what this is?
xmltv.sock & socat

Basically it feeds Tvheadends XMLTV parser using a unix socket. It's just another way for passing XMLTV data to Tvheadend, beside the XMLTV grabber method.
Reply
#5
Do you maybe also know a method to accomplish this with webgrab++?

I have webgrab++ running on my synology but can't find a automatic way to push xml to xmltv.sock
I tried adding a new internal grabber but that didn't worked either, grabber didn't show up.
Reply
#6
Did anyone manage to get socat to work from within a cronjob? works fine from ssh when called directly or within a script, but if called as part of cronjob it fails silently, only curl method works from with cronjob.
Reply
#7
This might help:

https://tvheadend.org/boards/5/topics/20
Reply
#8
(2015-08-05, 20:36)nhsman Wrote: This might help:

https://tvheadend.org/boards/5/topics/20

thanks, but this has the same problem, script works if i call it from ssh, but socat part fails if i call it as cronjob if i substitute socat part with curl e.g. curl -d @$DIR$XML -X POST -m 5 --unix-socket $SOCKET http://google.com

then it works.

sorted - forgot that cron looses all environment variables, so as a quick hack added variables to script
Reply
#9
Hey dhead,
thanks for your post. This was really helpful for me.
Reply
#10
Hi,
Using openelec 6.0, I have the same problem: I am able to import the EPG using socat with the command line, but it fails when launched by cron.
I did not manage to import the EPG using curl:

Code:
curl -d @/tmp/tnt.xml -X POST -m 60 --unix-socket /storage/.kodi/userdata/addon_data/service.multimedia.tvheadend/epggrab/xmltv.sock http://google.com
curl: (28) Operation timed out after 60001 milliseconds with 0 bytes received

Any idea about how I can import the EPG daily using cronjob?
Thanks
Reply
#11
You're saying that commands works when run manually but non when run in cron? Try using the absolute path to curl.
Reply
#12
After some testing, I've finally found a decent way to get xmltv.sock working on an ARM Synology NAS. I first had to get entware-ng installed, since the SynoCommunity repos don't seem to have netcat or socat. Also, entware's default netcat is not nmap's netcat, which is needed for UNIX socket support; the needed package is ncat. And while entware's curl is 7.40 (I believe), it is not packaged with socket support.

I ran into these problems because the packaged 4.1 TVH isn't picking up tv_grab_file. Therefore, my crontab entry is a little different than what's posted here:

/opt/bin/curl -s http://$ROUTER_IP/listings.xml | /opt/bin/ncat -i 30 -U /path/to/xmltv.sock

(My router runs tv_grab_na_dd and puts the xmltv file to be served on an internally accessible http server.) I also had to put the 30s timeout option there for netcat so it would terminate after piping the data, otherwise it would run indefinitely in the background. Hopefully this helps someone else having issues with xmltv on an ARM platform.
Reply
#13
(2016-01-31, 11:54)negge Wrote: You're saying that commands works when run manually but non when run in cron? Try using the absolute path to curl.

Hi,
No :
* The socat command works when run manually but non when run in cron, even though I used the absolute path.
* The curl command does not work at all.

Thanks
Reply
#14
dhead, thanks for the post. This, along with an irc chat with luuthe on the hts channel, got me setup using guide data in Kodi via tvheadend backend and zap2it xmltv epg grabber.

Yet, I have the same issue as a couple others here have posted when running the xmltv update and feed into sock via a cron job. No problem when executing the script manually via ssh command line terminal session, but the job fails when run via cron ... I've used absolute paths, not sure what the error is. Inspecting mailx does not yield any error results. Sad
Reply
#15
You may need to check the user running the cronjob. Whichever user runs Tvheadend should be the user running the cronjob. If that's root, then make sure you're editing root's crontab (`sudo crontab -e`). If it's another user (mine runs as hts), the make sure you're editing their crontab (i.e., `su -c 'crontab -e' hts` – if the user running TVH is not setup to have a login shell, then supply one to su via the '-s' option.)
Reply



Logout Mark Read Team Forum Stats Members Help
HOWTO: Three ways to use xmltv.sock1
This forum uses Lukasz Tkacz MyBB addons.