Help needed with xmltv
Added by Lisa White over 5 years ago
I am running ubunutu 18.04 with tvheadend. I am trying to import my iptv's epg url. The link that was provided was similar to this: (http://iptv name.com:826/xmltv.php?username=me&password=me). I wrote a bash script wiget o -q http://iptv name.com:826/xmltv.php?username=me&password=me and I get 404 not found, unauthorized. If I enter my url into my firefox browser, it loads and displays all of the programming but there is a message at the of the page stating "This xml file does not appear to have any style information associated with it. The document tree is associated below." It will just load the page with the information and will not send a download file. Is there something eles that I have to do to receive a download file?
Can someone provide easy instructions on how I can add the url or how I can download the url and convert it into a xmltv. I have been reading for 2 days and cannot figure this out.
Thanks
Lisa
Replies (9)
RE: Help needed with xmltv - Added by Hiro Protagonist over 5 years ago
The URL you have provided has shell metacharacters in it, try using single quotes like this:
wget -q 'http://iptvname.com:826/xmltv.php?username=me&password=me'
I note you also have a space in "iptv name.com" I assume this is an error as spaces are not valid in a URL.
What was your exact wget commandline? 'wget o -q' looks wrong, you probably want something like:
wget -qO- url... > outfile.xml
or
wget -qO outfile.xml url...
RE: Help needed with xmltv - Added by Lisa White over 5 years ago
Thanks for the reply. I ran this wget (wget -qO guide.xml 'http://myiptv.com:826/xmltv.php?username=me&password=me')from the terminal and it produced the xml. Now, how would I get this to work within tvheadend? I currently have webgrab running as the tvgrabber but in addition, I would like to have my iptv xml imported as well. I read that this can be done by having the iptv xml import under a sock. Can you help guide me with this adventure? Is there a bash script that needs created? I found a file called tvgrab remote for synology but I cannot get the above wget to work within that script. The sock is activated within tvheadend external.
Thanks for your help,
Lisa
RE: Help needed with xmltv - Added by Lisa White over 5 years ago
Ok guys, I am getting somewhat close. I used the script below and I got the epg from my iptv to download the xmltv, but I cannot get the epg.xml to load into tvheadend sock. This is what is the script that I am using:
#!/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
wget -O epg.xml 'http://myiptv.com:826/xmltv.php?username=me&password=me'
cat /home/hts/epg.xml | sudo socat - UNIX-CONNECT:/home/hts/.hts/tvheadend/epggrab/xmltv.sock
echo "" >> /home/hts/xmltvlog/xmltv.log
echo "Time: $(date)" >> /home/hts/xmltvlog/xmltv.log
echo "EPG Updated successfully." >> /home/hts/xmltvlog/xmltv.lo
I am getting an error "sudo: socat: command not found" Please help me solve.
Thanks
Lisa
RE: Help needed with xmltv - Added by Lisa White over 5 years ago
ok guys i just figured it out. I had the wrong socat installed. Mine was /home/hts/.xmltv/tv_grab_file.xmltv | nc -w 5 -U /home/hts/.hts/tvheadend/epggrab/xmltv.sock. I ran the command and xmltv loaded right in.
For those of you that try this methond instead of the tvgrab files, use these commands to see what socat linux is running:
which socat
which nc
which curl
Thanks again hiro
Lisa
RE: Help needed with xmltv - Added by Lisa White over 5 years ago
Ran into a snag with crontab. Heres my problem. I run the script manually in terminal and the tvheadend log shows the xmltv has uploaded. I created a crontab -e as 12 13 * * * /home/hts/./epggrab and the tvheadend log indicates "failed to read data" I noticed that when the crontab executes, it removes the epg.xml and will not write and create a new one. But it will write a new xml when executed manually. I think it has to do with write protection. I chmod 777 but it still has the same results. I removed the rm code from the script and it will work. It overwrites the xml that was created from the manual terminal execution. Will this work or will it corrupt the xml if I eliminate the rm command?
Any suggestions? I am so close :)
Lisa
RE: Help needed with xmltv - Added by Hiro Protagonist over 5 years ago
Yes, the nc or socat you're using needs to be the right one in order to write to a unix socket.
The 'wget -O' will overwrite epg.xml, so you don't need the rm. You don't give a path for epg.xml in the wget line, so the script would only work as expected if you're in /home/hts/.
I'd modify your script a little:
#!/bin/bash LOGFILE="/home/hts/xmltvlog/xmltv.log" EPGFILE="/tmp/epg.xml" echo "Download starting..." > $LOGFILE echo "Time: $(date)" >> $LOGFILE wget -O $EPGFILE 'http://myiptv.com:826/xmltv.php?username=me&password=me' cat $EPGFILE | sudo socat - UNIX-CONNECT:/home/hts/.hts/tvheadend/epggrab/xmltv.sock echo "" >> $LOGFILE echo "Time: $(date)" >> $LOGFILE echo "EPG Updated successfully." >> $LOGFILE
The single '>' in the "Download starting" line overwrites any previous log file.
I have a script that can be useful in these sorts of situations:
$ cat /usr/local/bin/agefile #!/bin/sh # # usage: agefile FILE1 to age FILE1 to FILE1.1 and FILE1.2 # agefile FILE1 FILE2 to age FILE1 and replace with FILE2 # OLD="$1" OLDER="$1".1 OLDEST="$1".2 if [ -s $OLD ];then if [ -e ${OLDEST} ] then rm ${OLDEST} fi if [ -e ${OLDER} ] then mv ${OLDER} ${OLDEST} fi if [ -e ${OLD} ] then mv ${OLD} ${OLDER} fi fi if [ $# -eq 2 ] then mv $2 ${OLD} fi
If you want to use this, make sure you give it executable permission and make sure /usr/local/bin/ is in $PATH.
You could add this to the script above:
#!/bin/bash LOGFILE="/home/hts/xmltvlog/xmltv.log" EPGFILE="/tmp/epg.xml" agefile $LOGFILE agefile $EPGFILE echo "Download starting..." > $LOGFILE ...
This will give you xmltv.log xmltv.log.1 xmltv.log.2 epg.xml epg.xml.1 epg.xml.2 so you can check the previous version of each file if something goes wrong.
Be careful to always run the script as the same user that the crontab is for. For example if you run it as root, you'll get epg.xml owned by root, and when the crontab operates, it won't be able to overwrite the file.
RE: Help needed with xmltv - Added by saen acro over 5 years ago
this is my crontab job
wget http://tvh7.local:9981/xmltv -O /home/hts/.xmltv/tv_grab_file.xmltv
then file is imported directly by
#cat /usr/bin/tv_grab_file
-------
#!/bin/bash
dflag=
vflag=
cflag=
if (( $# < 1 ))
then
cat ~/.xmltv/tv_grab_file.xmltv
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 "tv_grab_file is a simple grabber that just read the ~/.xmltv/tv_grab_file.xmltv file\n"
fi
if [ "$vflag" ]
then
printf "0.1\n"
fi
if [ "$cflag" ]
then
printf "baseline\n"
fi
exit 0
RE: Help needed with xmltv - Added by Lisa White over 5 years ago
You guys are sweethearts! Thank you so much for all the input. I checked the xml file this morning and the time and date were right on spot as programmed within cron. The tvheadend log indicates that it was grabbed, and the channels were loaded within program showing my iptv guide. I will monitor the guide and report back if a problem occurs. I am learning and enjoy reading everyone's postings.
My next project is going to be creating a cron for shutdown the server at night annd automatically turn on in the mornings. Any ideas?
,Thanks again guys.
RE: Help needed with xmltv - Added by saen acro over 5 years ago
Shutdown with cron,
startup with BIOS