#
# Sample file for telecable plugin
#
# You can update this file as you like. For example:
# 
# 1 ) You may need to adap the unrar command.
#
# 2 ) It is orignally designed to download telecable.rar using wget, you can use ftp instead.
#
# 3 ) The Vdr box may not be connected to internet: You can mount a USB Memory stick and copy it to the $1/telecable directory. 
#     In this case, you can even update telecablesource.conf file and still use the $2 parameter !
# 
# $1 -> VDR Config directory
# $2 -> URL to download from plugin setup and telecablesource.conf file
# $3 -> telecable.rar, mixed.rar or xmltv.rar
# $4 -> Message 'Download ok'
# $5 -> Message 'End of processing'
# $6 -> Err Messsage 'Unable to download'

PATH=/usr/local/src/VDR:$PATH

# The script begins !

cd "$1/telecable"
wget $2

# Cancel the rest of the script if no file
if test ! -f $3.rar;  then
  svdrpsend.pl MESG $6;
  exit;
fi
svdrpsend.pl MESG $4;

unrar e -y $3.rar $3.xml
mv $3.xml epg.xml
./trim_telecable.tcl
rm -f $3.rar
rm -f epg.xml
# Mise à jour de l'EPG VDR.
# Decalage 1 heure: -a -60
#./xml-1.02b.pl -c ../../channels.conf -l channels.trans -x telecable-light.xml
./xml.pl -c ../../channels.conf -l channels.trans -x epg-light.xml
rm -f epg-light.xml
svdrpsend.pl MESG $5
