[mythtv-users] Remove Commercial Script hacking - How do I zero out the commercial skip list?

Vincent Loschiavo vloschiavo at gmail.com
Mon May 14 04:31:58 UTC 2007


Hello All,

Since I (1) despise commercials and (2) currently have limited disk space on
my backend/frontend box (in that order), I've been working on removing
commercials from my recordings.  

So far I've gotten both the myth.org wiki removecommercial shell script as
well as the perl script from
http://bentonroberts.com/personal/media-server/code/mythshelljob.  I've had
to modify both based on the wiki discussion:
http://www.mythtv.org/wiki/index.php/Talk:Script_-_RemoveCommercials.

The removal process works great and replaces the old file with the
commercial-less file.  The only problem is that I'd like to keep the
"auto-skip commercial during playback" feature turned on incase I don't want
to remove the commercials for whatever reason.  So what happens is the
commercials are no longer in the file, but the database still has the
skiplist for the recording in question.  

# mythcommflag --getskiplist -f <filename>
This returns some values like: 
Commercial Skip List: 0-2426,11086-15788,27565-32511

I'd like to zero out these values, but I'm mysql phobic.  :)  just kidding.
I'm not sure where/how to begin locating the correct table/column/etc of the
database to modify.  Any suggestions?  I'm sure the alternative method used
at the end of the script below would be a great template though.

Any suggestions on how I can figure this out?  This would also improve the
WAF significantly!


---------------------------
-Commercial Removal Script-
---------------------------

#!/bin/sh
#
# Version 0.2
#
VIDEODIR=$1
FILENAME=$2
CHANID=$3
STARTTIME=`echo $4 | sed -e
's/\([0-9]\{4\}\)\([0-9]\{2\}\)\([0-9]\{2\}\)\([0-9]\{2\}\)\([0-9]\{2\}\)/\1
-\2-\3-\4-\5/'`

# 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.
#
# This Section is removed because Commercials are already being flagged
automatically on my setup.
#
#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 --mpeg2 --honorcutlist -c $CHANID -s $STARTTIME -o
$VIDEODIR/$FILENAME.tmp
ERROR=$?
if [ $ERROR -ne 0 ]; then
        echo "Transcoding failed for ${FILENAME} with error $ERROR"
        exit $ERROR
fi
mv $VIDEODIR/$FILENAME /storage/tmp/$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 /usr/video/$FILENAME.tmp
        exit $ERROR
fi



More information about the mythtv-users mailing list