- Code: Select all
#!/bin/bash
# Name: ripsubs
# Version: 0,1b
# Author: VolodyA! V Anarhist
# Year: 2010
# Licence: GPL 3.0
# the command line should be in the form
# ripsubs -i file.vob [file2.vob file3.vob] -ifo file.ifo -o base -a 20 [21 22 24] -v
# or
# ripsubs -h|--help
#if help
if [ -z "$1" ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
echo "ripsubs version 0,1b. written by VolodyA! V Anarhist"
echo "The command line should look like this:"
echo "ripsubs -i|--input file.vob [file2.vob file3.vob] -ifo|--ifo file.ifo -o|--base base -a|--streams 20 [21 22 24] -v|--verbose"
echo "For example to rip the streams 0x21 and 0x26 from the third chapter of ripped DVD you would type"
echo "ripsubs -i VTS3_*.VOB -ifo VTS3_0.IFO -a 21 26"
exit
fi
#go through all the command line a word at a time
FILES=""
IFOFILE=""
STREAMS=""
BASE=""
VERBOSE=""
STATE=""
for COMMAND in "$@"; do
if [ ${COMMAND:0:1} = "-" ]; then
if [ "$COMMAND" = "-i" ] || [ "$COMMAND" = "--input" ]; then
STATE="--input"
elif [ "$COMMAND" = "-ifo" ] || [ "$COMMAND" = "--ifo" ]; then
STATE="--ifo"
elif [ "$COMMAND" = "-a" ] || [ "$COMMAND" = "--streams" ]; then
STATE="--streams"
elif [ "$COMMAND" = "-o" ] || [ "$COMMAND" = "--base" ]; then
STATE="--base"
elif [ "$COMMAND" = "-v" ] || [ "$COMMAND" = "--verbose" ]; then
VERBOSE="-v"
else
echo "Wrong command command '$COMMAND'"
echo "Use ripsubs --help for useage information."
exit 1
fi
elif [ -n "$STATE" ]; then # if the STATE is not zero-length
if [ "$STATE" = "--input" ]; then
if [ ! -f $1 ] || [ ! -r $1 ]; then
echo "File '$1' doesn't exist or is not readable"
exit 2
fi
FILES="$FILES $1"
elif [ "$STATE" = "--ifo" ]; then
if [ ! -f $1 ] || [ ! -r $1 ]; then
echo "File '$1' doesn't exist or is not readable"
exit 2
fi
IFOFILE="$1"
elif [ "$STATE" = "--streams" ]; then
STREAMS="$STREAMS $1"
elif [ "$STATE" = "--base" ]; then
BASE="$1"
fi
else
echo "Wrong command command '$COMMAND'"
echo "Use ripsubs --help for useage information."
exit 1
fi
shift
done
#if there is an IFO file that was specified then we need to add that parameter
IFOSTRING=""
if [ -n "$IFOFILE" ]; then
IFOSTRING="-i $IFOFILE"
fi
for STREAM in $STREAMS; do
cat $FILES | tcextract -x ps1 -t vob -a 0x$STREAM |subtitle2vobsub $IFOSTRING -o $BASE-$STREAM $VERBOSE
done
You want to put this code in the file called "ripsubs" without quotes and put that file somewhere in your path. Then you should make it executable "chmod +x ripsubs". It relies on subtitle2vobsub (part of subtitleripper) and tcextract (part of transcode).
I did this because i am annoyed that people don't share the subtitles that exist on DVDs because it's difficult to rip many of them. Well, now you can do this with a single command per VOB.

