Clipinc.sh

Aus VDR Wiki
(Unterschied zwischen Versionen)
Wechseln zu: Navigation, Suche
(M)
(M)
Zeile 6: Zeile 6:
 
#
 
#
 
# clipinc.sh
 
# clipinc.sh
#
 
# Required: at, clipinc.pl, lame, ffmpeg ('--enable-mp3lame')
 
 
#
 
#
 
# add this lines to your reccmds.conf:
 
# add this lines to your reccmds.conf:
 
# folgende zeilen in die reccmds.conf eintragen:
 
# folgende zeilen in die reccmds.conf eintragen:
 
#
 
#
# Run clipinc       : /path_to_this_script/clipinc.sh -start
+
# Run clipinc   : /path_to_this_script/clipinc.sh -start
# Run clipinc + 2mp3 : /path_to_this_script/clipinc.sh -start -2mp3
+
# Stop clipinc? : /path_to_this_script/clipinc.sh -kill
# Stop clipinc?     : /path_to_this_script/clipinc.sh -kill
+
  
 
# CONFIG START
 
# CONFIG START
  AUDIO_CODEC=""    # force audio codec ('copy' to copy stream) -> default ('mp3')
 
  AUDIO_BITRATE=""  # set audio bitrate (in kbit/s) -> default ('192')
 
  AUDIO_SAMPLING=""  # set audio sampling rate (in Hz) -> default ('44100')
 
 
   CLIPINC_LOGFILE="/var/log/vdr/clipinc.log"
 
   CLIPINC_LOGFILE="/var/log/vdr/clipinc.log"
 
# CONFIG END
 
# CONFIG END
 
PATH=$PREFIX/bin:$PREFIX/sbin:$PATH
 
  
 
case "$1" in
 
case "$1" in
 
     -start)
 
     -start)
at now <<EOT
 
 
PID=`pidof -x clipinc.pl`
 
PID=`pidof -x clipinc.pl`
if [ -n "\$PID" ] ; then
+
if [ -n "$PID" ] ; then
    svdrpsend.pl -p ${VDR_PORT:-2001} MESG "Sorry, but clipinc.pl is running with pid (\$PID)..."
+
    echo $"Clipinc process already active (pid: $PID)" ...
 
else
 
else
    if [ -e "$2/recinfo.conf" ] ; then
+
    if pidof atd >/dev/null ; then
clipinc.pl "$2"
+
if [ -e "$2/recinfo.conf" ] ; then
    elif [ -e "$3/recinfo.conf" ] ; then
+
    (
clipinc.pl "$3"
+
echo "svdrpsend.pl -p ${VDR_PORT:-2001} MESG "$"Clipinc process started"" ... >/dev/null"
cl_() {
+
echo "clipinc.pl \"$2\" > $CLIPINC_LOGFILE 2>&1"
    sed -e 's/__/_/g' \
+
echo "svdrpsend.pl -p ${VDR_PORT:-2001} MESG "$"Clipinc process finished"" ... >/dev/null"
-e 's/^_//g' \
+
    ) | at now
-e 's/_$//g' \
+
else
-e 's/_/ /g' \
+
    echo $"recinfo.conf not found" ...
-e 's/--/-/g' \
+
fi
-e 's/^-//g' \
+
-e 's/-$//g' \
+
-e 's/-/ /g' \
+
-e 's/  //g'
+
}
+
find "$CLIPINCDIR" -name '001.vdr' -printf '%h\n' | \
+
while read DIR ; do
+
    cd "\$DIR"
+
    LABEL=\$(dirname "\$DIR")
+
    NAME="\${LABEL##*/}"
+
    if [ -f 001.vdr ] ; then
+
TITLE="\$(echo \${NAME##*_-_} | cl_)"
+
AUTHOR="\$(echo \${NAME%%_-_*} | cl_)"
+
case $2 in
+
    -2mp3)
+
SESSION="$CLIPINC2DIR/\$AUTHOR"
+
mkdir -p "\$SESSION"
+
if [ ! -e "\$SESSION/\$TITLE.mp3" ] ; then
+
    ffmpeg \
+
-i 001.vdr -acodec ${AUDIO_CODEC:-mp3} -ab ${AUDIO_BITRATE:-192} -ar ${AUDIO_SAMPLING:-44100} \
+
    \${TITLE:+-title "\$TITLE"} \${AUTHOR:+-author "\$AUTHOR"} "\$SESSION/\$TITLE.mp3" &
+
    wait
+
fi
+
;;
+
esac
+
    fi
+
done
+
 
    else
 
    else
svdrpsend.pl -p ${VDR_PORT:-2001} MESG "recinfo.conf not found..."
+
echo $"Jobmanager (atd) is not running" ...
 
    fi
 
    fi
fi \
+
fi
> $CLIPINC_LOGFILE 2>&1
+
EOT
+
 
;;
 
;;
 
     -kill)
 
     -kill)
pidof -x clipinc.pl | xargs -r kill -9
+
pidof vdrcut -x clipinc.pl | xargs -r kill -9
 
;;
 
;;
 
esac
 
esac

Version vom 7. Januar 2006, 14:27 Uhr

Script für clipinc

Datei
$PATH/clipinc.sh
#!/bin/sh
#
# clipinc.sh
#
# add this lines to your reccmds.conf:
# folgende zeilen in die reccmds.conf eintragen:
#
# Run clipinc   : /path_to_this_script/clipinc.sh -start
# Stop clipinc? : /path_to_this_script/clipinc.sh -kill

# CONFIG START
  CLIPINC_LOGFILE="/var/log/vdr/clipinc.log"
# CONFIG END

case "$1" in
    -start)
	PID=`pidof -x clipinc.pl`
	if [ -n "$PID" ] ; then
	    echo $"Clipinc process already active (pid: $PID)" ...
	else
	    if pidof atd >/dev/null ; then
		if [ -e "$2/recinfo.conf" ] ; then
		    (
			echo "svdrpsend.pl -p ${VDR_PORT:-2001} MESG "$"Clipinc process started"" ... >/dev/null"
			echo "clipinc.pl \"$2\" > $CLIPINC_LOGFILE 2>&1"
			echo "svdrpsend.pl -p ${VDR_PORT:-2001} MESG "$"Clipinc process finished"" ... >/dev/null"
		    ) | at now
		else
		    echo $"recinfo.conf not found" ...
		fi
	    else
		echo $"Jobmanager (atd) is not running" ...
	    fi
	fi
	;;
    -kill)
	pidof vdrcut -x clipinc.pl | xargs -r kill -9
	;;
esac