forked from FozzTexx/viddin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrip-series
executable file
·152 lines (143 loc) · 3.35 KB
/
rip-series
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#!/bin/sh
#
# Copyright 2015 by Chris Osborn <[email protected]>
#
# This file is part of viddin.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License at <http://www.gnu.org/licenses/> for
# more details.
EXT=mkv
while [ $# -gt 0 -a `expr substr "${1:-empty}" 1 2` = "--" ] ; do
case "$1" in
--dvd)
DVD="$2"
shift 2
;;
--season)
SEASON="$2"
shift 2
;;
--title)
TITLE="$2 --chapters"
shift 2
;;
--chapters)
FLAGS="${FLAGS} --chapters $2"
shift 2
;;
--split-chapters)
SPLIT=1
shift
;;
--crop)
FLAGS="${FLAGS} --crop $2"
shift 2
;;
--rate)
FLAGS="${FLAGS} --rate $2"
shift 2
;;
--extension)
FLAGS="${FLAGS} --extension $2"
EXT="$2"
shift 2
;;
--start-at)
FLAGS="${FLAGS} --start-at $2"
EXT="$2"
shift 2
;;
--firstep)
EPISODE="$2"
shift 2
;;
--animation|--film|--pal-film|--decomb|--pal-animation|--lap-animation|--mangled-pal|--subtitles|--detelecine|--tv|--tv-bff|--tv-bob|--tv-bob-tff|--tv-bob-bff|--pal-tv|--restore-ntsc|--cfr|--normalize)
FLAGS="${FLAGS} $1"
shift
;;
--lang)
FLAGS="${FLAGS} $1 $2"
shift 2
;;
--debug)
FLAGS="${FLAGS} $1"
shift
;;
--bluray)
FLAGS="${FLAGS} $1"
shift
;;
--norip)
FLAGS="${FLAGS} $1"
shift
;;
*)
echo "Unknown flag:" "$1"
exit 1
;;
esac
done
if [ -z "${SEASON}" ] ; then
SEASON=$1
shift
fi
if [ -z "${EPISODE}" ] ; then
EPISODE=$1
shift
fi
TITLES="$@"
if [ -n "${SPLIT}" -a -z "${TITLES}" ] ; then
echo Chapter splitting requested without specifying titles
exit 1
fi
# If no titles specified, rip all of them
if [ -z "${TITLES}" ] ; then
if [ -n "${DVD}" ] ; then
TITLES=`(lsdvd "${DVD}" 2>/dev/null) | egrep '^Title:' | awk '{printf "%i\n", $2}' | sed -e 's/,//'`
else
TITLES=`(lsdvd 2>/dev/null) | egrep '^Title:' | awk '{printf "%i\n", $2}' | sed -e 's/,//'`
fi
fi
if [ -n "${SPLIT}" ] ; then
for i in ${TITLES} ; do
if [ -n "${DVD}" ] ; then
CHAPTERS=`(lsdvd -t $i -c "${DVD}" 2>/dev/null) | grep Chapter: | awk '{printf "'$i':%i\n", $2}'`
else
CHAPTERS=`(lsdvd -t $i -c 2>/dev/null) | grep Chapter: | awk '{printf "'$i':%i\n", $2}'`
fi
titles="${titles} ${CHAPTERS}"
done
TITLES=${titles}
fi
for i in ${TITLES} ; do
ep=`echo $EPISODE | awk '{printf "%02i\n", $1}'`
EPISODE=`expr $EPISODE + 1`
if expr match $i "[0-9][0-9]*:[0-9][0-9]*" > /dev/null ; then
i=`echo $i | sed -e 's/:/ --chapters /'`
fi
if [ -n "${DVD}" ] ; then
rip-video ${FLAGS} --title ${TITLE} $i "${DVD}" ${SEASON}x${ep}.${EXT}
else
rip-video ${FLAGS} --title ${TITLE} $i ${SEASON}x${ep}.${EXT}
fi
STATUS=$?
if [ $STATUS != 0 ] ; then
exit 1
fi
done
if [ -z "${DVD}" ] ; then
DVD=/dev/dvd
fi
DVD=$(readlink -f "${DVD}")
DIR=$(echo "${DVD}" | cut -d "/" -f2)
if [ "${DIR}" = dev ] ; then
eject ${DVD}
fi