9 Commits

Author SHA1 Message Date
Benjamin Bryan
816b3ff833 Merge pull request #1 from ahnooie/derek
Added ability to rip from multiple drives at the same time
Added a config file for parameters
Changed logging
Log name is based on ID_FS_LABEL (dvd name) variable set by udev in order to isolate logging from multiple process running simultaneously
Log file name and path set in config file
Log file cleanup based on parameter set in config file
Added phone notification options for Pushbullet and IFTTT
Remove MakeMKV destination directory after HandBrake finishes transcoding
Misc stuff
2016-09-11 15:36:17 -07:00
Benjamin Bryan
fdadc08c8c move that to a better place 2016-09-11 15:21:43 -07:00
Benjamin Bryan
5c2eff6e2f create log dir if needed 2016-09-11 15:18:13 -07:00
Benjamin Bryan
88a779d014 remove config 2016-09-11 13:07:31 -07:00
Benjamin Bryan
5c5146df52 add config to .gitignore 2016-09-11 12:47:17 -07:00
Benjamin Bryan
9f6db3a078 move config to config.sample 2016-09-11 12:46:40 -07:00
muckngrind4
4e0c05f787 Fixed bug in video_transcode.sh
Fixed bug in notification.
2016-09-11 00:48:44 -07:00
muckngrind4
7e76b84d70 Update config 2016-09-10 23:01:31 -07:00
Derek Christensen
1310c6b08d - Added ability to rip from multiple drives at the same time
- Added a config file for parameters
- Changed logging
	- Log name is based on ID_FS_LABEL (dvd name) variable set by udev in order to isolate logging from multiple process running simultaneously
	- Log file name and path set in config file
	- Log file cleanup based on parameter set in config file
- Added phone notification options for Pushbullet and IFTTT
- Remove MakeMKV destination directory after HandBrake finishes transcoding
- Misc stuff
2016-09-10 22:38:39 -07:00
7 changed files with 152 additions and 30 deletions

6
.gitignore vendored Normal file → Executable file
View File

@@ -1 +1,5 @@
log
logs/*
test.sh
archive/
config

71
config.sample Normal file
View File

@@ -0,0 +1,71 @@
#!/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=""
#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

View File

@@ -1,7 +1,7 @@
#!/bin/bash
#
# Rip Data using DD
source /opt/arm/config
{
@@ -19,4 +19,4 @@
eject
} >> /opt/arm/log
} >> $LOG

View File

@@ -1,31 +1,43 @@
#!/bin/bash
#
source /opt/arm/config
# Create log dir if needed
mkdir -p $LOGPATH
{
echo "Starting Identify Script..." >> /opt/arm/log
echo "Starting Identify Script..." >> $LOG
#Clean up old log files
FILESFOUND=( $(find $LOGPATH -mtime +$LOGLIFE -type f))
echo "Deleting ${#FILESFOUND[@]} old log files:"${FILESFOUND[@]} >> $LOG
find $LOGPATH -mtime +$LOGLIFE -type f -delete
# Set Home to home folder of user that is setup to run MakeMKV
export HOME="/root/"
if [ $ID_FS_TYPE == "udf" ]; then
echo "identified video" >> /opt/arm/log
echo "ripping video" >> /opt/arm/log
/opt/arm/video_rip.sh
echo "identified video" >> $LOG
echo "found ${ID_FS_LABEL} on ${DEVNAME}" >> $LOG
#echo "ripping video" >> $LOG
/opt/arm/video_rip.sh $LOG
elif (($ID_CDROM_MEDIA_TRACK_COUNT_AUDIO > 0 )); then
echo "identified audio" >> /opt/arm/log
echo "identified audio" >> $LOG
abcde
elif [ $ID_FS_TYPE == "iso9660" ]; then
echo "identified data" >> /opt/arm/log
/opt/arm/data_rip.sh
eject
echo "identified data" >> $LOG
/opt/arm/data_rip.sh $LOG
eject $DEVNAME
else
echo "unable to identify" >> /opt/arm/log
echo $ID_CDROM_MEDIA_TRACK_COUNT_AUDIO >> /opt/arm/log
echo $ID_FS_TYPE >> /opt/arm/log
eject
echo "unable to identify" >> $LOG
echo $ID_CDROM_MEDIA_TRACK_COUNT_AUDIO >> $LOG
echo $ID_FS_TYPE >> $LOG
eject $DEVNAME
fi
} >> /opt/arm/log
} >> $LOG

26
notify.sh Executable file
View File

@@ -0,0 +1,26 @@
#!/bin/bash
source /opt/arm/config
MSG=$1
{
#Notification via pushbullet
#Trigger onl if variable is set
if [ -z "$PB_KEY" ]; then
echo "Pushbullet notifications not enabled" >> $LOG
else
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
#Notification via IFTTT
#Trigger only if variable is set
if [ -z "$IFTTT_KEY" ]; then
echo "IFTTT notifications not enabled" >> $LOG
else
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
} >> $LOG

View File

@@ -2,19 +2,23 @@
#
# Rip video using MakeMKV then eject and call transcode script
source /opt/arm/config
{
TIMESTAMP=`date '+%Y%m%d_%H%M%S'`;
DEST=/mnt/media/ARM/raw/${TIMESTAMP}_${ID_FS_LABEL}
echo "Ripping video ${ID_FS_LABEL} from ${DEVNAME}" >> $LOG
TIMESTAMP=`date '+%Y%m%d_%H%M%S'`;
DEST=${RAWPATH}/${ID_FS_LABEL}_${TIMESTAMP}
mkdir $DEST
makemkvcon mkv dev:/dev/sr0 all $DEST -r
makemkvcon mkv dev:$DEVNAME all $DEST --minlength=$MINLENGTH -r
eject
eject $DEVNAME
echo /opt/arm/notify.sh "\"Ripped: ${ID_FS_LABEL} completed from ${DEVNAME}\"" |at now
echo /opt/arm/video_transcode.sh $DEST $ID_FS_LABEL $TIMESTAMP | batch
} >> /opt/arm/log
} >> $LOG

View File

@@ -1,19 +1,20 @@
#!/bin/bash
# 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
DEST_EXT=mkv
HANDBRAKE_CLI=HandBrakeCLI
#LOG=$4
#DEST_EXT=mkv
#HANDBRAKE_CLI=HandBrakeCLI
#HB_PRESET="Normal"
HB_PRESET="High Profile"
#HB_PRESET="High Profile"
echo "Start video transcoding script" >> /opt/arm/log
echo "Start video transcoding script" >> $LOG
DEST=/mnt/media/ARM/${TIMESTAMP}_${LABEL}
DEST=${ARMPATH}/${LABEL}_${TIMESTAMP}
mkdir $DEST
for FILE in `ls $SRC`
@@ -22,9 +23,9 @@ echo "Start video transcoding script" >> /opt/arm/log
extension=${filename##*.}
filename=${filename%.*}
echo "Transcoding file $FILE" >> /opt/arm/log
echo "Transcoding file $FILE" >> $LOG
$HANDBRAKE_CLI -i $SRC/$FILE -o $DEST/$filename.$DEST_EXT --preset="$HB_PRESET" --subtitle scan -F 2> /opt/arm/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
@@ -32,3 +33,7 @@ echo "Start video transcoding script" >> /opt/arm/log
done
rmdir $SRC
echo /opt/arm/notify.sh "\"Transcode: ${ID_FS_LABEL} complete.\"" |at now