Clipinc.sh
Aus VDR Wiki
(Unterschied zwischen Versionen)
Zeile 25: | Zeile 25: | ||
-start) | -start) | ||
at now <<EOT | at now <<EOT | ||
− | PID=`pidof -x clipinc.pl` | + | PID=`pidof -x clipinc.pl` >/dev/null 2>&1 |
if [ -n "\$PID" ] ; then | if [ -n "\$PID" ] ; then | ||
svdrpsend.pl MESG "Sorry, but clipinc.pl is running with pid (\$PID)..." | svdrpsend.pl MESG "Sorry, but clipinc.pl is running with pid (\$PID)..." | ||
Zeile 34: | Zeile 34: | ||
clipinc.pl "$3" | clipinc.pl "$3" | ||
TIMESTAMP="$(date +%c)" | TIMESTAMP="$(date +%c)" | ||
+ | cl_() { | ||
+ | sed -e 's/__/_/g' \ | ||
+ | -e 's/^_//g' \ | ||
+ | -e 's/_$//g' \ | ||
+ | -e 's/_/ /g' \ | ||
+ | -e 's/--/-/g' \ | ||
+ | -e 's/^-//g' \ | ||
+ | -e 's/-$//g' \ | ||
+ | -e 's/-/ /g' \ | ||
+ | -e 's/ //g' | ||
+ | } | ||
find "$CLIPINCDIR" -name '001.vdr' -printf '%h\n' | \ | find "$CLIPINCDIR" -name '001.vdr' -printf '%h\n' | \ | ||
while read DIR ; do | while read DIR ; do | ||
Zeile 40: | Zeile 51: | ||
NAME="\${LABEL##*/}" | NAME="\${LABEL##*/}" | ||
if [ -f 001.vdr ] ; then | if [ -f 001.vdr ] ; then | ||
− | TITLE="\${NAME##*_-_}" | + | TITLE="\$(echo \${NAME##*_-_} | cl_)" |
− | AUTHOR="\${NAME%%_-_*}" | + | AUTHOR="\$(echo \${NAME%%_-_*} | cl_)" |
case $2 in | case $2 in | ||
-2mp3) | -2mp3) | ||
SESSION="$CLIPINC2DIR/\$TIMESTAMP" | SESSION="$CLIPINC2DIR/\$TIMESTAMP" | ||
mkdir -p "\$SESSION" | mkdir -p "\$SESSION" | ||
− | if [ ! -e "\$SESSION/\$ | + | echo "\$SESSION/\$AUTHOR - \$TITLE.mp3" |
+ | if [ ! -e "\$SESSION/\$AUTHOR - \$TITLE.mp3" ] ; then | ||
ffmpeg \ | ffmpeg \ | ||
-i 001.vdr -acodec ${AUDIO_CODEC:-mp3} -ab ${AUDIO_BITRATE:-192} -ar ${AUDIO_SAMPLING:-44100} \ | -i 001.vdr -acodec ${AUDIO_CODEC:-mp3} -ab ${AUDIO_BITRATE:-192} -ar ${AUDIO_SAMPLING:-44100} \ | ||
− | \${TITLE:+-title "\$TITLE"} \${AUTHOR:+-author "\$AUTHOR"} "\$SESSION/\$ | + | \${TITLE:+-title "\$TITLE"} \${AUTHOR:+-author "\$AUTHOR"} "\$SESSION/\$AUTHOR - \$TITLE.mp3" & |
wait | wait | ||
fi | fi |
Version vom 22. April 2005, 01:34 Uhr
#!/bin/sh # # clipinc.sh # # Required: at, clipinc.pl, lame, ffmpeg ('--enable-mp3lame') # # add this lines to your reccmds.conf: # folgende zeilen in die reccmds.conf eintragen: # # 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 # 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" # CONFIG END PATH=$PREFIX/bin:$PREFIX/sbin:$PATH case "$1" in -start) at now <<EOT PID=`pidof -x clipinc.pl` >/dev/null 2>&1 if [ -n "\$PID" ] ; then svdrpsend.pl MESG "Sorry, but clipinc.pl is running with pid (\$PID)..." else if [ -e "$2/recinfo.conf" ] ; then clipinc.pl "$2" elif [ -e "$3/recinfo.conf" ] ; then clipinc.pl "$3" TIMESTAMP="$(date +%c)" cl_() { sed -e 's/__/_/g' \ -e 's/^_//g' \ -e 's/_$//g' \ -e 's/_/ /g' \ -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/\$TIMESTAMP" mkdir -p "\$SESSION" echo "\$SESSION/\$AUTHOR - \$TITLE.mp3" if [ ! -e "\$SESSION/\$AUTHOR - \$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/\$AUTHOR - \$TITLE.mp3" & wait fi ;; esac fi done else svdrpsend.pl MESG "recinfo.conf not found..." fi fi \ > $CLIPINC_LOGFILE 2>&1 EOT ;; -kill) PID=`pidof -x clipinc.pl` eval ${PID:+kill -9 $PID} ;; esac