2011-01-04, 00:25
If I used this as my JobSucessful would it work?
PHP Code:
#!/bin/sh
VIDEODIR=$1
FILENAME=$2
# Sanity checking, to make sure everything is in order.
if [ -z "$VIDEODIR" -o -z "$FILENAME" ]; then
echo "Usage: $0 <VideoDirectory> <FileName>"
exit 5
fi
if [ ! -f "$VIDEODIR/$FILENAME" ]; then
echo "File does not exist: $VIDEODIR/$FILENAME"
exit 6
fi
# The meat of the script. Flag commercials, copy the flagged commercials to
# the cutlist, and transcode the video to remove the commercials from the
# file.
mythcommflag -f $VIDEODIR/$FILENAME
ERROR=$?
if [ $ERROR -gt 126 ]; then
echo "Commercial flagging failed for ${FILENAME} with error $ERROR"
exit $ERROR
fi
mythcommflag --gencutlist -f $VIDEODIR/$FILENAME
ERROR=$?
if [ $ERROR -ne 0 ]; then
echo "Copying cutlist failed for ${FILENAME} with error $ERROR"
exit $ERROR
fi
mythtranscode --honorcutlist --showprogress -i $VIDEODIR/$FILENAME -o $VIDEODIR/$FILENAME.tmp
ERROR=$?
if [ $ERROR -ne 0 ]; then
echo "Transcoding failed for ${FILENAME} with error $ERROR"
exit $ERROR
fi
mv $VIDEODIR/$FILENAME $VIDEODIR/$FILENAME.old
mv $VIDEODIR/$FILENAME.tmp $VIDEODIR/$FILENAME
mythcommflag -f $VIDEODIR/${FILENAME} --rebuild
ERROR=$?
if [ $ERROR -ne 0 ]; then
echo "Rebuilding seek list failed for ${FILENAME} with error $ERROR"
exit $ERROR
fi
mythcommflag --clearcutlist -f $VIDEODIR/$FILENAME
ERROR=$?
if [ $ERROR -eq 0 ]; then
# Fix the database entry for the file
cat << EOF | mysql mythconverg
UPDATE
recorded
SET
cutlist = 0,
filesize = $(ls -l $VIDEODIR/$FILENAME | awk '{print $5}')
WHERE
basename = '$FILENAME';
EOF
exit 0
else
echo "Clearing cutlist failed for ${FILENAME} with error $ERROR"
rm -f $VIDEODIR/$FILENAME.tmp
exit $ERROR
fi