summaryrefslogtreecommitdiffstats
path: root/abs/core/linhes-scripts/removecommercials.sh
diff options
context:
space:
mode:
authorJames Meyer <james.meyer@operamail.com>2010-10-23 18:17:40 (GMT)
committerJames Meyer <james.meyer@operamail.com>2010-10-23 18:19:39 (GMT)
commitadbcf19958300e9b6598990184c8815b945ba0ee (patch)
treef4283c850ac0ac202c17e78a637ee7ca8147621b /abs/core/linhes-scripts/removecommercials.sh
parent61a68250df10d29b624650948484898334ff22d0 (diff)
downloadlinhes_pkgbuild-adbcf19958300e9b6598990184c8815b945ba0ee.zip
linhes_pkgbuild-adbcf19958300e9b6598990184c8815b945ba0ee.tar.gz
linhes_pkgbuild-adbcf19958300e9b6598990184c8815b945ba0ee.tar.bz2
Removed old core and extra from repo. Renamed -testing to core/extra. This will setup the base for the testing branch.
Diffstat (limited to 'abs/core/linhes-scripts/removecommercials.sh')
-rwxr-xr-xabs/core/linhes-scripts/removecommercials.sh50
1 files changed, 35 insertions, 15 deletions
diff --git a/abs/core/linhes-scripts/removecommercials.sh b/abs/core/linhes-scripts/removecommercials.sh
index 70e2e52..0497dd5 100755
--- a/abs/core/linhes-scripts/removecommercials.sh
+++ b/abs/core/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