18 Commits

Author SHA1 Message Date
Benjamin Bryan
30ee175cff Merge pull request #5 from ahnooie/video_identification
Distinguish udf video from udf data
2016-10-01 15:36:59 -07:00
Benjamin Bryan
02e7154e34 comment clarification 2016-10-01 15:34:27 -07:00
Benjamin Bryan
6ae9949341 flag to enable udf check 2016-10-01 15:24:51 -07:00
Benjamin Bryan
e042192cfb pipes for or 2016-10-01 14:54:24 -07:00
Benjamin Bryan
b39a6baf2d distinguish udf video from data 2016-10-01 14:33:52 -07:00
Benjamin Bryan
eb9555f3d2 Merge pull request #4 from ahnooie/derek
Derek
2016-09-21 22:03:03 -07:00
Derek Christensen
c2d6db048c Merge branch 'derek' of github.com:ahnooie/automatic-ripping-machine into derek
Added devname to abcde command
Added logging stats (timers).  "grep STAT" to see parse them out.
2016-09-20 23:14:42 -07:00
Derek Christensen
51b55f6bc7 Added devname to abcde command
Added additional logging stats (timers).  "grep STAT" to parse them out of the logs.
2016-09-20 21:47:25 -07:00
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
Derek Christensen
8b1c0966f7 Fixed bug in transcode notification 2016-09-11 00:42:51 -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 194 additions and 32 deletions

6
.gitignore vendored Normal file → Executable file
View File

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

79
config.sample Normal file
View File

@@ -0,0 +1,79 @@
#!/bin/bash
# ARM (Automatic Ripping Machine) oonfig file
#################
## ARM Options ##
#################
# Distinguish UDF video discs from UDF data discs. Requires mounting disc so adds a few seconds to the identify script.
ARM_CHECK_UDF=true
#####################
## 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,62 @@
#!/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 udf" >> $LOG
echo "found ${ID_FS_LABEL} on ${DEVNAME}" >> $LOG
if [ $ARM_CHECK_UDF == true ]; then
# check to see if this is really a video
mkdir -p /mnt/${DEVNAME}
mount ${DEVNAME} /mnt/${DEVNAME}
if [[ -d /mnt/${DEVNAME}/VIDEO_TS || -d /mnt/${DEVNAME}/BDMV ]]; then
echo "identified udf as video" >> $LOG
umount /mnt/${DEVNAME}
/opt/arm/video_rip.sh $LOG
else
umount /mnt/${DEVNAME}
echo "identified udf as data" >> $LOG
/opt/arm/data_rip.sh $LOG
eject $DEVNAME
fi
else
echo "ARM_CHECK_UDF is false, assuming udf is video" >> $LOG
/opt/arm/video_rip.sh $LOG
fi
elif (($ID_CDROM_MEDIA_TRACK_COUNT_AUDIO > 0 )); then
echo "identified audio" >> /opt/arm/log
abcde
echo "identified audio" >> $LOG
abcde -d $DEVNAME
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

28
notify.sh Executable file
View File

@@ -0,0 +1,28 @@
#!/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
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
#Notification via IFTTT
#Trigger only if variable is set
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
} >> $LOG

View File

@@ -2,19 +2,32 @@
#
# 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}
RIPSTART=$(date +%s);
mkdir $DEST
makemkvcon mkv dev:/dev/sr0 all $DEST -r
makemkvcon mkv dev:$DEVNAME all $DEST --minlength=$MINLENGTH -r
eject
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} 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
} >> /opt/arm/log
} >> $LOG

View File

@@ -1,19 +1,16 @@
#!/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
#HB_PRESET="Normal"
HB_PRESET="High Profile"
TRANSSTART=$(date +%s);
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 +19,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 +29,13 @@ echo "Start video transcoding script" >> /opt/arm/log
done
rmdir $SRC
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