From 8b1c0966f7914c4ab8c77ab0e3e41123f66e22b1 Mon Sep 17 00:00:00 2001 From: Derek Christensen Date: Sun, 11 Sep 2016 00:42:51 -0700 Subject: [PATCH 1/2] Fixed bug in transcode notification --- video_transcode.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video_transcode.sh b/video_transcode.sh index fb59f9c..fb319e2 100755 --- a/video_transcode.sh +++ b/video_transcode.sh @@ -35,5 +35,5 @@ echo "Start video transcoding script" >> $LOG rmdir $SRC -echo /opt/arm/notify.sh "\"Transcode: ${ID_FS_LABEl} complete.\"" |at now +echo /opt/arm/notify.sh "\"Transcode: ${ID_FS_LABEL} complete.\"" |at now From 51b55f6bc72fcf476938a9da7bf6e56bb2fdd524 Mon Sep 17 00:00:00 2001 From: Derek Christensen Date: Tue, 20 Sep 2016 21:47:25 -0700 Subject: [PATCH 2/2] Added devname to abcde command Added additional logging stats (timers). "grep STAT" to parse them out of the logs. --- config | 71 ---------------------------------------------- identify.sh | 2 +- notify.sh | 2 ++ video_rip.sh | 11 ++++++- video_transcode.sh | 18 ++++++------ 5 files changed, 23 insertions(+), 81 deletions(-) delete mode 100644 config diff --git a/config b/config deleted file mode 100644 index 06a7358..0000000 --- a/config +++ /dev/null @@ -1,71 +0,0 @@ -#!/bin/bash -# ARM (Automatic Ripping Machine) oonfig file - -##################### -## Directory setup ## -##################### - -#Base directory of ARM media directory -#Ripped and transcoded files end up here -ARMPATH="/mnt/media/ARM/" - -#Path to raw MakeMKV directory -#Destination for MakeMKV and source for HandBrake -RAWPATH="/mnt/media/ARM/raw/" - -#Path to directory to hold log files -#Make sure to include trailing / -LOGPATH="/opt/arm/logs/" - -#How long to let log files live before deleting (in days) -LOGLIFE=1 - -######################## -## MakeMKV Parameters ## -######################## - -#Minimum length of track for MakeMKV rip (in seconds) -MINLENGTH="600" - - -########################## -## HandBrake Parameters ## -########################## - -# Handbrake preset profile -# See https://trac.handbrake.fr/wiki/BuiltInPresets -HB_PRESET="High Profile" - -#Extension of the final video file -DEST_EXT=mkv - -#Handbrake binary to call -HANDBRAKE_CLI=HandBrakeCLI - -############################# -## Notification Parameters ## -############################# - -#Pushbullet API Key -#Leave empty or comment out to disable Pushbullet notifications -PB_KEY="o.u74EXY4fkFGABUSyxjvj1NCEHxgVXZov" - -#IFTTT API KEY -#Leave empty or comment out to disable IFTTT notifications -#IFTTT_KEY="" - -#IFTTT Event Name -IFTTT_EVENT="arm_event" - -#Determine logfile name -#use the label of the DVD/CD or else use empty.log -#this is required for udev events where there is no media available -#such as ejecting the drive -if [ -z $ID_FS_LABEL]; then - LOGFILE="empty.log" -else - LOGFILE=${ID_FS_LABEL}".log" -fi - -#Set full logfile path -LOG=$LOGPATH$LOGFILE diff --git a/identify.sh b/identify.sh index d1ec3c5..48610aa 100755 --- a/identify.sh +++ b/identify.sh @@ -22,7 +22,7 @@ if [ $ID_FS_TYPE == "udf" ]; then elif (($ID_CDROM_MEDIA_TRACK_COUNT_AUDIO > 0 )); then echo "identified audio" >> $LOG - abcde + abcde -d $DEVNAME elif [ $ID_FS_TYPE == "iso9660" ]; then echo "identified data" >> $LOG diff --git a/notify.sh b/notify.sh index e2a6450..f334f68 100755 --- a/notify.sh +++ b/notify.sh @@ -9,6 +9,7 @@ MSG=$1 if [ -z "$PB_KEY" ]; then echo "Pushbullet notifications not enabled" >> $LOG else + echo "Sending Pushbullet notification" >> $LOG curl -s -u $PB_KEY: https://api.pushbullet.com/v2/pushes -d type=note -d title="Alert" -d body="$MSG" echo "Pushbullet notification sent" >> $LOG fi @@ -18,6 +19,7 @@ fi if [ -z "$IFTTT_KEY" ]; then echo "IFTTT notifications not enabled" >> $LOG else + echo "Sending IFTTT notification" >> $LOG curl -s -X POST -H "Content-Type: application/json" -d '{"value1":"'"$MSG"'"}' https://maker.ifttt.com/trigger/${IFTTT_EVENT}/with/key/${IFTTT_KEY} printf "\nIFTTT notification sent" >> $LOG fi diff --git a/video_rip.sh b/video_rip.sh index 4fe40ea..e635bc2 100755 --- a/video_rip.sh +++ b/video_rip.sh @@ -9,16 +9,25 @@ source /opt/arm/config echo "Ripping video ${ID_FS_LABEL} from ${DEVNAME}" >> $LOG TIMESTAMP=`date '+%Y%m%d_%H%M%S'`; DEST=${RAWPATH}/${ID_FS_LABEL}_${TIMESTAMP} + RIPSTART=$(date +%s); mkdir $DEST makemkvcon mkv dev:$DEVNAME all $DEST --minlength=$MINLENGTH -r + RIPEND=$(date +%s); + RIPSEC=$(($RIPEND-$RIPSTART)); + RIPTIME="$(($RIPSEC / 3600)) hours, $((($RIPSEC / 60) % 60)) minutes and $(($RIPSEC % 60)) seconds." + eject $DEVNAME - echo /opt/arm/notify.sh "\"Ripped: ${ID_FS_LABEL} completed from ${DEVNAME}\"" |at now + echo /opt/arm/notify.sh "\"Ripped: ${ID_FS_LABEL} completed from ${DEVNAME} in ${RIPTIME}\"" |at now + echo "STAT: ${ID_FS_LABEL} ripped in ${RIPTIME}" >> $LOG echo /opt/arm/video_transcode.sh $DEST $ID_FS_LABEL $TIMESTAMP | batch + echo "${ID_FS_LABEL} sent to transcoding queue..." >> $LOG + + } >> $LOG diff --git a/video_transcode.sh b/video_transcode.sh index fb319e2..4bfbffd 100755 --- a/video_transcode.sh +++ b/video_transcode.sh @@ -2,15 +2,11 @@ # Transcodes Video files using HandBrake and removes source files when done source /opt/arm/config -#SRC=/mnt/media/ARM/raw/ + SRC=$1 LABEL=$2 TIMESTAMP=$3 -#LOG=$4 -#DEST_EXT=mkv -#HANDBRAKE_CLI=HandBrakeCLI -#HB_PRESET="Normal" -#HB_PRESET="High Profile" +TRANSSTART=$(date +%s); echo "Start video transcoding script" >> $LOG @@ -25,7 +21,7 @@ echo "Start video transcoding script" >> $LOG echo "Transcoding file $FILE" >> $LOG - $HANDBRAKE_CLI -i $SRC/$FILE -o $DEST/$filename.$DEST_EXT --preset="$HB_PRESET" --subtitle scan -F 2> $LOG + $HANDBRAKE_CLI -i $SRC/$FILE -o $DEST/$filename.$DEST_EXT --preset="$HB_PRESET" --subtitle scan -F 2>> $LOG #TIMESTAMP=`date '+%Y_%m_%d__%H_%M_%S'`; #mv $SRC/$FILE $SRC/done/$TIMESTAMP.$FILE #mv $DEST/$FILE $DEST/done/$FILE @@ -35,5 +31,11 @@ echo "Start video transcoding script" >> $LOG rmdir $SRC -echo /opt/arm/notify.sh "\"Transcode: ${ID_FS_LABEL} complete.\"" |at now +TRANSEND=$(date +%s); +TRANSSEC=$(($TRANSEND-$TRANSSTART)); +TRANSTIME="$(($TRANSSEC / 3600)) hours, $((($TRANSSEC / 60) % 60)) minutes and $(($TRANSSEC % 60)) seconds." + +echo "STAT: ${ID_FS_LABEL} transcoded in ${TRANSTIME}" >> $LOG + +echo /opt/arm/notify.sh "\"Transcode: ${ID_FS_LABEL} completed in ${TRANSTIME}\"" |at now