Script to rip DVD / Blu-ray from any source (iso, dir, dev)

The place to discuss linux version of MakeMKV
Post Reply
beandog
Posts: 35
Joined: Sun Feb 18, 2018 7:42 am
Location: /usa/utah
Contact:

Script to rip DVD / Blu-ray from any source (iso, dir, dev)

Post by beandog »

Here's a script I wrote and use to rip all my stuff regardless of where it's at -- a device file, a directory, or an ISO I've already made, and will use the proper makemkvcon arguments.

Some example usages:

Code: Select all

dvd_makemkv /dev/sr0
dvd_makemkv bluray.iso
dvd_makemkv /mnt/bluray
Here you go, hope this helps someone :)

Code: Select all

#!/bin/bash

function is_dvd {

        device="$(realpath $1)"
        test "$device" == "/dev/sr0" || return 1

}

function is_image {

        device="$(realpath $1)"
        test -d "$device" && return 1
        test "${device: -3}" == "iso" || return 1

}

function is_directory {

        device="$(realpath $1)"
        test "${device: -3}" == "iso" || return 1
        test -d "$device" || return 1

}

device="$1"
test -z "$device" && device="/dev/sr0"
test -e "$device" || return 1
track="all"
test -z "$2" || track="`expr $2 - 1`"
output_dir="."
if [[ "${device: -3}" == "iso" ]]; then output_dir="${device:: -3}mux"; if ! -d "$output_dir"; then mkdir "$output_dir"; fi; fi
if [[ "${device: -4}" == "iso/" ]]; then output_dir="${device:: -4}mux"; if [[ ! -d "$output_dir" ]]; then mkdir "$output_dir"; fi; fi

device="$(realpath $device)"

makemkv_arg=
is_dvd "$device" && makemkv_arg="dev:${device}"
is_image "$device" && makemkv_arg="iso:${device}"
is_directory "$device" && makemkv_arg="file:${device}/VIDEO_TS"

test -z "$makemkv_arg" && exit 1

makemkvcon --minlength=0 mkv "$makemkv_arg" $track "$output_dir"
mrdonkey
Posts: 1
Joined: Mon Jun 10, 2019 3:10 pm

Re: Script to rip DVD / Blu-ray from any source (iso, dir, dev)

Post by mrdonkey »

Sorry to drag up an old thread but this iexactly what I need. Only thing is I am new to makemkv. How can set this to run in a docker container that i have running based on jlesage/makemkv?
Post Reply