Skip to content

Instantly share code, notes, and snippets.

@tacofumi
Last active December 15, 2023 16:18
Show Gist options
  • Save tacofumi/3041eac2f59da7a775c6 to your computer and use it in GitHub Desktop.
Save tacofumi/3041eac2f59da7a775c6 to your computer and use it in GitHub Desktop.
This script rips DVD/Blu-ray using makemkvcon. Use udev to invoke this script to auto-rip when disk is inserted. Some variables such as length of string to trim in order to get the title of movie may vary depending on your environment.
#!/bin/bash
{
echo $(date)
echo ">>>Disk found"
echo ">>>Setting the title..."
title=$(makemkvcon -r info)
title=`echo "$title" | grep "DRV:0\+"`
title=${title:53}
len=${#title}-12
title=${title:0:$len}
if [[ -z $title ]]; then
echo ">>>Couldn't set the title - No disk found"
echo ">>>Exit->"
exit;
else
echo ">>>Title set: $title"
echo ">>>Starting ripping..."
makemkvcon --minlength=4800 -r --decrypt --directio=true mkv disc:0 all /home/user/share > /dev/null
mv "/home/user/raid/share/"*.mkv "/home/user/raid/share/"$title.mkv
mv "/home/user/raid/share/"$title.mkv "/home/user/raid/share/Movies"
eject
echo ">>>title: $title.mkv created."
fi
} &>> "/home/user/autorip.log"
@drewwells
Copy link

Have you considered TV shows where there are multiple titles?

@KlfJoat
Copy link

KlfJoat commented Aug 26, 2020

You could use cut to pick field 6 from the output of makemkvcon -r info.

I personally like the pretty title that bdmt_eng.xml provides. I extract it with:

xmlstarlet select --text -N di="urn:BDA:bdmv;discinfo" --template --match '//di:name' --value-of . "${mountpoint}/BDMV/META/DL/bdmt_eng.xml"

Also, the output of makemkvcon will be a lot shorter if you don't include -r and you won't need > /dev/null. The command will run just fine without that option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment