diff options
-rw-r--r-- | abs/core-testing/linhes-scripts/PKGBUILD | 4 | ||||
-rwxr-xr-x | abs/core-testing/linhes-scripts/removecommercials.sh | 50 |
2 files changed, 37 insertions, 17 deletions
diff --git a/abs/core-testing/linhes-scripts/PKGBUILD b/abs/core-testing/linhes-scripts/PKGBUILD index d4bdc50..07ddbc9 100644 --- a/abs/core-testing/linhes-scripts/PKGBUILD +++ b/abs/core-testing/linhes-scripts/PKGBUILD @@ -3,7 +3,7 @@ pkgname=linhes-scripts pkgver=1 -pkgrel=77 +pkgrel=78 pkgdesc="Various scripts that help to make LinHES, LinHES." arch=('i686' 'x86_64') license=('GPL2') @@ -84,7 +84,7 @@ md5sums=('f56985b2d602e11dc1e10d3e7848b2a5' '65629302a4d2c3adf88cdf0ebc10d493' '2734054f08c4c885bb9070dce239d4c3' '87b0dc855181f98516acb18a7d551601' - '25c1baeb97a49656456ae33f7e7a9f06' + 'c54a3afd4aa3c1af560c9b6adb600f3a' '2fb25aef03ffd1282414d8cca3df7056' 'd2a29444ab9036fb385bbf044daf1ff5' 'df727c98350a64e2171c950bbefc9c5d' diff --git a/abs/core-testing/linhes-scripts/removecommercials.sh b/abs/core-testing/linhes-scripts/removecommercials.sh index 70e2e52..0497dd5 100755 --- a/abs/core-testing/linhes-scripts/removecommercials.sh +++ b/abs/core-testing/linhes-scripts/removecommercials.sh @@ -1,7 +1,7 @@ #!/bin/sh # remove commercials from recordings using the user generated cutlist or # optionally using the mythcommflag generated cutlist. -# version 0.2 3/24/2010 +# version 0.3 9/1/2010 # usage: # first parameter must be %DIR% of the recording @@ -18,7 +18,13 @@ # to generate a cutlist. # WARNING: Using this option could result in part of the recording being cut if # mythcommflag incorrectly flagged the commercial. -USE_MYTHCOMMFLAG_CUTLIST=NO +# The USE_MYTHCOMMFLAG_CUTLIST option is saved in ~/.removecommercials.cfg and will +# not be overwritten by updates to this script. The ~/.removecommercials.cfg +# will be created by this script if it doesn't exist. +# To enable set USE_MYTHCOMMFLAG_CUTLIST=YES in ~/.removecommercials.cfg + +[[ ! -f ~/.removecommercials.cfg ]] && printf "# If no cutlist is found USE_MYTHCOMMFLAG_CUTLIST=YES will use mythcommflag\n# to generate a cutlist.\n# WARNING: Using this option could result in part of the recording being cut if\n# mythcommflag incorrectly flagged the commercial.\nUSE_MYTHCOMMFLAG_CUTLIST=NO" > ~/.removecommercials.cfg +. ~/.removecommercials.cfg # Auguments passed from command line VIDEODIR=$1 @@ -33,7 +39,8 @@ DBUSERNAME=${DBUSERNAME:-"mythtv"} DBPASSWORD=${DBPASSWORD:-"mythtv"} SQLCMD="mysql -u $DBUSERNAME --password=$DBPASSWORD -h $BACKEND_HOSTNAME mythconverg -e" -LOG="/var/log/mythtv/removecommercials.log" +LOG="/dev/null" +#LOG="/var/log/mythtv/removecommercials.log" #------FUNCTIONS--------------- update_comment() @@ -149,18 +156,22 @@ update_status 4 check_myth_jobcmds +echo "" >> $LOG +date >> $LOG +$VIDEODIR/$FILENAME >> $LOG + # check for cutlist MYTHCOMMFRAMES=`mythcommflag --getcutlist -f $VIDEODIR/$FILENAME | grep 'Cutlist:' | cut -d \ -f 2` if [ $USE_MYTHCOMMFLAG_CUTLIST=YES ] && [ -z "$MYTHCOMMFRAMES" ]; then - echo "Generating cutlist..." + echo "Generating cutlist..." >> $LOG update_comment "Generating cutlist..." /usr/bin/nice -n19 /usr/bin/mythcommflag --gencutlist -f $VIDEODIR/$FILENAME MYTHCOMMFRAMES=`mythcommflag --getcutlist -f $VIDEODIR/$FILENAME | grep 'Cutlist:' | cut -d \ -f 2` fi if [ -n "$MYTHCOMMFRAMES" ]; then - echo "Removing Commercials..." + echo "Removing Commercials..." >> $LOG update_comment "Removing Commercials..." ( /usr/bin/nice -n19 /usr/bin/mythtranscode -c $CHANID -s $STARTTIME -o $TMPFILE $MPEG --honorcutlist --showprogress > $STATUSFILE 2>&1 ; echo "Done" >> $STATUSFILE ) & TPID=$! @@ -168,46 +179,55 @@ if [ -n "$MYTHCOMMFRAMES" ]; then check_background_progress ERROR=$? if [ $ERROR -ne 0 ]; then - echo "Transcoding failed for ${FILENAME} with error $ERROR" + echo "Transcoding failed for ${FILENAME} with error $ERROR" >> $LOG exit $ERROR fi check_myth_jobcmds # move temp file to output location - echo "Moving file..." + echo "Moving file..." >> $LOG update_comment "Moving file..." if [ `$SQLCMD "select data from settings where value='SaveTranscoding';" | sed '/[0-9]/!d'` = 1 ]; then - echo "DB is set to save transcoding" + echo "DB is set to save transcoding" >> $LOG mv $VIDEODIR/$FILENAME $VIDEODIR/$FILENAME.old fi mv $TMPFILE $VIDEODIR/$FILENAME # file has changed, rebuild index - echo "Rebuilding index..." + echo "Rebuilding index..." >> $LOG update_comment "Rebuilding index..." mythcommflag -c $CHANID -s $STARTTIME --rebuild ERROR=$? if [ $ERROR -ne 0 ]; then - echo "Rebuilding seek list failed for ${FILENAME} with error $ERROR" + echo "Rebuilding seek list failed for ${FILENAME} with error $ERROR" >> $LOG exit $ERROR fi # remove old cutlist - echo "Removing old cutlist..." + echo "Removing old cutlist..." >> $LOG update_comment "Removing old cutlist..." mythcommflag -c $CHANID -s $STARTTIME --clearcutlist ERROR=$? if [ $ERROR -eq 0 ]; then # Fix the database entry for the file - `$SQLCMD UPDATE recorded SET cutlist = 0, filesize = $(ls -l $VIDEODIR/$FILENAME | awk '{print $5}') WHERE basename = '$FILENAME';` > /dev/null + echo "Fixing database entry..." >> $LOG + `$SQLCMD "UPDATE recorded SET cutlist = 0, filesize = $(ls -l $VIDEODIR/$FILENAME | awk '{print $5}') WHERE basename = '$FILENAME';"` > /dev/null else - echo "Clearing cutlist failed for ${FILENAME} with error $ERROR" + echo "Clearing cutlist failed for ${FILENAME} with error $ERROR" >> $LOG + clean_up_files + update_status 272 + update_comment "Error: Clearing cutlist failed." exit $ERROR fi + + # clear autoskip list + echo "Clearing autoskip list..." >> $LOG + `$SQLCMD "DELETE FROM recordedmarkup WHERE CONCAT( chanid, starttime ) IN (SELECT CONCAT( chanid, starttime ) FROM recorded WHERE basename = '$FILENAME');"` > /dev/null + clean_up_files - echo "Commercials Removed" + echo "Commercials Removed" >> $LOG update_status 272 update_comment "Sucessfully Completed." else - echo "No cutlist found." + echo "No cutlist found." >> $LOG fi |