#!/bin/sh
# this is an example-script for a noad-call with
# different parameters for a call before or after 
# a recording is done
# this script should be called from inside vdr via '-r ' 
# e.g. vdr '-r /usr/local/sbin/noadcall.sh'
. /etc/vdr/sysconfig

# set the noad-binary here
NOADBIN="/usr/bin/noad nice"
LOG="/video0/noadstat"

# gibt osd-meldung aus. wenn nicht gewünscht leer lassen
OSDOPTS="--OSD"

# set the online-mode here 
# 1 means online for live-recording only
# 2 means online for every recording

# set additional args for every call here here
ADDOPTS="--background --comments --ac3 --overlap --jumplogo --asd"

# set special args for a call with 'before' here
# e.g. set a specail statistikfile
BEFOREOPTS="--statisticfile=$LOG"

# set special args for a call with 'after' here
# e.g. backup the marks from the online-call before
#      so you can compare the marks and see
#      how the marks vary between online-mode 
#      and normal scan (backup-marks are in marks0.vdr)
AFTEROPTS="--backupmarks --statisticfile=$LOG"

##### VDR-Start in Abhängigkeit der NOAD-Einstellung #####
case "$NOAD" in
      "Aus")
         exit 0
      ;;
      "Online nur Live Aufnahmen")
         ONLINEMODE="--online=1"
      ;;
      "Online alle Aufnahmen")
         ONLINEMODE="--online=2"
      ;;
esac

if [ -f "$2/noad.pid" ]; then
  # noad is still running, so we should defer
  echo  "Noad Befor ist bereits am Laufen $2" >>/ramdisk/noad.log
elif   [ $1 == "before" ]; then
  echo "Noad $1 lauft noch nicht. Scan $2"    >>/$LOG
  $NOADBIN $* $ONLINEMODE $ADDOPTS $BEFOREOPTS $OSDOPTS
elif [ $1 == "after"  ]; then
  $NOADBIN $* $ONLINEMODE $ADDOPTS $AFTEROPTS $OSDOPTS
  echo  "Film $2 mit recordingdone.sh eingetragen als schon aufgenommen" >>/$LOG
  /usr/bin/recordingdone.sh $2
  /usr/bin/CreateRecCover.sh "$2"
fi
