Clipinc.sh

Aus VDR Wiki
(Unterschied zwischen Versionen)
Wechseln zu: Navigation, Suche
K (Zuordnung)
(M)
 
(11 dazwischenliegende Versionen von 8 Benutzern werden nicht angezeigt)
Zeile 1: Zeile 1:
Script für [[clipinc]]
+
Vorschlag für ein einfaches Skript um [[clipinc]] zu ''starten'', welches über die [[reccmds.conf]] ausgeführt werden kann.
  
{{Box Datei | $PATH/clipinc.sh |
+
{{Box Datei | [[Struktur|$PATH]]/clipinc.sh |
 
<pre>
 
<pre>
 
#!/bin/sh
 
#!/bin/sh
 
#
 
#
 
# 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
+
which clipinc.pl >/dev/null 2>&1 || { echo clipinc.pl $"not found" ... ; exit 1 ; }
  
case "$1" in
+
case $1 in
    -start)
+
    -start)
at now <<EOT
+
if [ -s "${PIDFILE:=$2/clipinc.pid}" ] ; then
PID=`pidof -x clipinc.pl`
+
    read PID < "$PIDFILE"
if [ -n "\$PID" ] ; then
+
    echo $"Clipinc process already active" "(pid: $PID)" ...
    svdrpsend.pl MESG "Sorry, but clipinc.pl is running with pid (\$PID)..."
+
 
else
 
else
 
    if [ -e "$2/recinfo.conf" ] ; then
 
    if [ -e "$2/recinfo.conf" ] ; then
clipinc.pl "$2"
+
screen -dm sh -c \
    elif [ -e "$3/recinfo.conf" ] ; then
+
" \
clipinc.pl "$3"
+
    clipinc.pl \"$2\" > \"$CLIPINC_LOGFILE\" 2>&1 &
cl_() {
+
    svdrpsend.pl -p ${VDR_PORT:-2001} MESG \""$"Clipinc process started"" (pid: \$!) ...\" ; \
    sed -e 's/__/_/g' \
+
    echo \$! > \"$PIDFILE\" ; \
-e 's/^_//g' \
+
    wait \$! ; \
-e 's/_$//g' \
+
    rm -f \"$PIDFILE\" ; \
-e 's/_/ /g' \
+
    svdrpsend.pl -p ${VDR_PORT:-2001} MESG \""$"Clipinc process finished"" (pid: \$!) ...\" ; \
-e 's/--/-/g' \
+
"
-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 MESG "recinfo.conf not found..."
+
echo $"recinfo.conf not found" ...
 
    fi
 
    fi
fi \
+
fi
> $CLIPINC_LOGFILE 2>&1
+
EOT
+
 
;;
 
;;
    -kill)
+
    -kill)
PID=`pidof -x clipinc.pl`
+
if [ -s "${PIDFILE:=$2/clipinc.pid}" ] ; then
eval ${PID:+kill -9 $PID}
+
    read PID < "$PIDFILE"
 +
    if ps -p $PID >/dev/null 2>&1 ; then
 +
        kill -9 $PID
 +
    fi
 +
    rm -f "$PIDFILE"
 +
fi
 
;;
 
;;
 
esac
 
esac
 +
 +
exit $?
 
</pre>
 
</pre>
 
}}
 
}}
  
[[Kategorie:Scripts]]
+
==Quellen==
 +
* [[clipinc]]
 +
 
 +
[[Kategorie:Skripte]]

Aktuelle Version vom 12. Juni 2006, 10:02 Uhr

Vorschlag für ein einfaches Skript um clipinc zu starten, welches über die reccmds.conf ausgeführt werden kann.

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

which clipinc.pl >/dev/null 2>&1 || { echo clipinc.pl $"not found" ... ; exit 1 ; }

case $1 in
     -start)
	if [ -s "${PIDFILE:=$2/clipinc.pid}" ] ; then
	    read PID < "$PIDFILE"
	    echo $"Clipinc process already active" "(pid: $PID)" ...
	else
	    if [ -e "$2/recinfo.conf" ] ; then
		screen -dm sh -c \
		" \
		    clipinc.pl \"$2\" > \"$CLIPINC_LOGFILE\" 2>&1 &
		    svdrpsend.pl -p ${VDR_PORT:-2001} MESG \""$"Clipinc process started"" (pid: \$!) ...\" ; \
		    echo \$! > \"$PIDFILE\" ; \
		    wait \$! ; \
		    rm -f \"$PIDFILE\" ; \
		    svdrpsend.pl -p ${VDR_PORT:-2001} MESG \""$"Clipinc process finished"" (pid: \$!) ...\" ; \
		"
	    else
		echo $"recinfo.conf not found" ...
	    fi
	fi
	;;
     -kill)
	if [ -s "${PIDFILE:=$2/clipinc.pid}" ] ; then
	    read PID < "$PIDFILE"
	    if ps -p $PID >/dev/null 2>&1 ; then
	        kill -9 $PID
	    fi
	    rm -f "$PIDFILE"
	fi
	;;
esac

exit $?


[Bearbeiten] Quellen