Skip to content

Instantly share code, notes, and snippets.

Created January 2, 2013 00:42
Show Gist options
  • Save anonymous/4431327 to your computer and use it in GitHub Desktop.
Save anonymous/4431327 to your computer and use it in GitHub Desktop.
Make a high quality DVD rip with HandBrake, then scp it over to the NAS. HandBrake is restricted to using 1/2 of the available cores on the box, and status updates are sent out using Pushover.
#!/bin/bash
# Handy for those times you need to rip a title other than #1
HANDBRAKE_EXTRA_OPTIONS=$@
TITLE=`lsdvd /dev/sr0 | grep "Disc Title" | cut -d' ' -f 3`
HandBrakeCLI -i /dev/sr0 -o ${TITLE}.mp4 ${HANDBRAKE_EXTRA_OPTIONS} -Z "High Profile" &
# Restrict HandBrake to 1/2 the available cores.
cpulimit -p $! -l $(expr `nproc` / 2)00
if [ $? -eq 0 ]; then
curl -s \
-F "token=${PUSHOVER_RIPDVD}" \
-F "user=${PUSHOVER_USER}" \
-F "message=${TITLE} ripped" \
https://api.pushover.net/1/messages.json
scp ${TITLE}.mp4 tchaikowsky:/nas/movies/
if [ $? -eq 0 ]; then
curl -s \
-F "token=${PUSHOVER_RIPDVD}" \
-F "user=${PUSHOVER_USER}" \
-F "message=${TITLE} SCPed" \
https://api.pushover.net/1/messages.json
rm ${TITLE}.mp4
else
curl -s \
-F "token=${PUSHOVER_RIPDVD}" \
-F "user=${PUSHOVER_USER}" \
-F "message=Error SCPing ${TITLE}" \
https://api.pushover.net/1/messages.json
# The movie was successfully ripped, so we don't delete the file.
fi
else
curl -s \
-F "token=${PUSHOVER_RIPDVD}" \
-F "user=${PUSHOVER_USER}" \
-F "message=Error ripping ${TITLE}" \
https://api.pushover.net/1/messages.json
rm ${TITLE}.mp4
fi
# vim: set ts=4 sw=4 sts=4 ai et :
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment