blob: 19cf9d36a9ce564f5c11d02ddad95e5c225d550e (
plain)
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
|
#!/bin/sh
export TEXTDOMAIN="$(basename $0)"
. gettext.sh 2> /dev/null
if [ $? -eq 1 ]; then
eval_gettext () {
gettext_eval="printf '%s' \"$1\""
printf "%s" "`eval \"$gettext_eval\"`"
}
gettext() {
printf "%s" "$1";
}
fi
usage(){
s="$(basename $0)"
printf "$(eval_gettext 'Usage: $s -M <mode start|kill> -d <target directory> [-n <nicelevel -20..19>] [-v <verbosity 0..5>]\n [-t <encoding type 0..5>] [-o <encoding quality -1..10>] [-l <low bitrate 32..320>]\n [-m <max. bitrate 32..320>] [-e <encoder options>] [-c <crc 0|1>] [-r <rip options>]\n [-f <fast rip 0|1>] [ -x <excludes special chars _|NTFS|HFS>] [-u <underscores 0|1>]\n [-p <create playlist 0|1>] -X <lockfile> -L <logfile> -A <stopfile>')\n"
[ -n "$cmd_error" ] && printf "\n$cmd_error"
exit 1
}
debug(){
echo "PARAM_MODE : >$PARAM_MODE<"
echo "PARAM_NICE : >$PARAM_NICE<"
echo "PARAM_VERBOSITY : >$PARAM_VERBOSITY<"
echo "PARAM_DIR : >$PARAM_DIR<"
echo "PARAM_ENCQ : >$PARAM_ENCQ<"
echo "PARAM_LOWBIT : >$PARAM_LOWBIT<"
echo "PARAM_MAXBIT : >$PARAM_MAXBIT<"
echo "PARAM_ENCOPTS : >$PARAM_ENCOPTS<"
echo "PARAM_ENCTYPE : >$PARAM_ENCTYPE<"
echo "PARAM_CRC : >$PARAM_CRC<"
echo "PARAM_FASTRIP : >$PARAM_FASTRIP<"
echo "PARAM_EXCLSPCHARS : >$PARAM_EXCLSPCHARS<"
echo "PARAM_UNDERSCORES : >$PARAM_UNDERSCORES<"
echo "PARAM_PLAYLIST : >$PARAM_PLAYLIST<"
echo "PARAM_RIPOPTS : >$PARAM_RIPOPTS<"
echo "LOCK_FILE : >$LOCK_FILE<"
echo "LOG_FILE : >$LOG_FILE<"
echo "ABORT_FILE : >$ABORT_FILE<"
}
cmd_error=""
while getopts ":M:d:n:v:t:o:l:m:e:c:r:f:x:u:p:X:L:A:" opt; do
case "$opt" in
M) PARAM_MODE="$OPTARG";;
d) PARAM_DIR="$OPTARG";;
n) PARAM_NICE="$OPTARG";;
v) PARAM_VERBOSITY="$OPTARG";;
t) PARAM_ENCTYPE="$OPTARG";;
o) PARAM_ENCQ="$OPTARG";;
l) PARAM_LOWBIT="$OPTARG";;
m) PARAM_MAXBIT="$OPTARG";;
e) PARAM_ENCOPTS="$OPTARG";;
c) PARAM_CRC="$OPTARG";;
r) PARAM_RIPOPTS="$OPTARG";;
f) PARAM_FASTRIP="$OPTARG";;
x) PARAM_EXCLSPCHARS="$OPTARG";;
u) PARAM_UNDERSCORES="$OPTARG";;
p) PARAM_PLAYLIST="$OPTARG";;
X) LOCK_FILE="$OPTARG";;
L) LOG_FILE="$OPTARG";;
A) ABORT_FILE="$OPTARG";;
--) break;;
\?) cmd_error="$(gettext 'Error: Error parsing Commandline')\n"; break;;
esac
done
([ "$PARAM_MODE" = "start" ] || [ "$PARAM_MODE" = "kill" ]) || cmd_error="${cmd_error}$(gettext 'Error: Missing or wrong Mode (-M)')\n"
([ "$PARAM_MODE" = "start" ] && [ -z "$PARAM_DIR" ]) && cmd_error="${cmd_error}$(gettext 'Error: Missing Directory Parameter (-d)')\n"
[ -n "$cmd_error" ] && usage
if ([ -z "$LOCK_FILE" ] || [ -z "$LOG_FILE" ] || [ -z "$ABORT_FILE" ] ); then
cmd_error="${cmd_error}$(gettext 'Error: Missing -X, -L or -A')\n"
usage
rm -f "$LOCK_FILE"
exit 1
fi
[ "$PARAM_MODE" = "start" ] && rm -f "$LOG_FILE"
exec >> "$LOG_FILE" 2>&1
if [ -n "$cmd_error" ]; then
usage
rm -f "$LOCK_FILE"
exit 1
fi
case "$PARAM_MODE" in
kill)
touch "$ABORT_FILE"
d="$(vdr-opticaldrive getopentime)"
printf "$(eval_gettext 'PROCESS MANUALLY ABORTED\nPlease Wait (max. $d Seconds)...')\n"
for pid in $(pidof perl); do
#echo "$(cat /proc/$pid/cmdline | sed 's/\x00/ /g'|sed 's/^perl //')" > /tmp/a
#echo "$(cat $LOCK_FILE|sed "s/'//g"|sed 's/^nice -n [[:digit:]]\{2\} //') " > /tmp/b
[ "$(cat /proc/$pid/cmdline | sed 's/\x00/ /g'| sed "s/'//g"| sed 's/^perl //')" = "$(cat $LOCK_FILE|sed "s/'//g"|sed 's/^nice -n [[:digit:]]\{2\} //') " ] && kill $pid
done
;;
start)
touch "$LOCK_FILE"
rm -f "$ABORT_FILE"
if ! vdr-opticaldrive present > /dev/null; then
printf "%s\n" "$(gettext 'Opticaldrive Drive not present. Aborting!')"
rm -f "$LOCK_FILE"
exit 1
fi
[ ! -d "$PARAM_DIR" ] && mkdir -p "$PARAM_DIR" 2> /dev/zero
if [ ! -w "$PARAM_DIR" ]; then
s="$PARAM_DIR"
printf "%s\n" "$(eval_gettext 'Error, Directory $s not writable')"
rm -f "$LOCK_FILE"
exit 1
fi
vdr-opticaldrive open
d="$(vdr-opticaldrive getopentime)"
printf "%s\n" "$(eval_gettext 'Please insert CD... (start in $d Seconds)')"
sleep $(vdr-opticaldrive getopentime)
if [ ! -f "$ABORT_FILE" ]; then
vdr-opticaldrive startburn
[ -n "$PARAM_NICE" ] && commandline="$(printf "nice -n '%s' " "$PARAM_NICE")"
commandline="${commandline}/usr/bin/ripit"
commandline="${commandline}$(printf " --nointeraction --device '%s'" "$(vdr-opticaldrive getdev)")"
[ -n "$PARAM_VERBOSITY" ] && commandline="${commandline}$(printf " -x '%s'" "$PARAM_VERBOSITY")"
case "$PARAM_ENCTYPE" in
0)
commandline="${commandline} ${PARAM_RIPOPTS}"
;;
1)
lameopt="--cbr -b $PARAM_LOWBIT"
#RipitSetup.Ripit_encopts
[ -n "$PARAM_ENCOPTS" ] && lameopt="$lameopt $PARAM_ENCOPTS"
#crcarg "-p"
[ "$PARAM_CRC" = "1" ] && lameopt="$lameopt -p"
[ -n "$lameopt" ] && commandline="${commandline} --coder '0' -q off -b off --lameopt '$lameopt'"
;;
2)
lameopt="--abr $PARAM_LOWBIT"
#RipitSetup.Ripit_encopts
[ -n "$PARAM_ENCOPTS" ] && lameopt="$lameopt $PARAM_ENCOPTS"
#crcarg "-p"
[ "$PARAM_CRC" = "1" ] && lameopt="$lameopt -p"
[ -n "$lameopt" ] && commandline="${commandline} --coder '0' -q off -b off --lameopt '$lameopt'"
;;
3)
lameopt="-V 4 -b $PARAM_LOWBIT -B $PARAM_MAXBIT"
#RipitSetup.Ripit_encopts
[ -n "$PARAM_ENCOPTS" ] && lameopt="$lameopt $PARAM_ENCOPTS"
#crcarg "-p"
[ "$PARAM_CRC" = "1" ] && lameopt="$lameopt -p"
[ -n "$lameopt" ] && commandline="${commandline} --coder '0' -q off -b off --lameopt '$lameopt'"
;;
4)
flacopt="--best"
#RipitSetup.Ripit_encopts
[ -n "$PARAM_ENCOPTS" ] && flacopt="$flacopt $PARAM_ENCOPTS"
[ -n "$flacopt" ] && commandline="${commandline} --coder '2' -q off --flacopt '$flacopt'"
;;
5)
oggopt="-q $PARAM_ENCQ"
#RipitSetup.Ripit_encopts
[ -n "$PARAM_ENCOPTS" ] && oggopt="$oggopt $PARAM_ENCOPTS"
[ -n "$oggopt" ] && commandline="${commandline} --coder '1' -q off --oggencopt '$oggopt'"
;;
esac
#--ripopt
[ "$PARAM_FASTRIP" = "1" ] && commandline="${commandline} --ripopt '-Z'"
commandline="${commandline}$(printf " --outputdir '%s'" "$PARAM_DIR")"
[ -n "$PARAM_EXCLSPCHARS" ] && commandline="${commandline}$(printf " -W '%s'" "$PARAM_EXCLSPCHARS")"
[ "$PARAM_UNDERSCORES" = "1" ] && commandline="${commandline} -u"
[ "$PARAM_PLAYLIST" = "1" ] && commandline="${commandline}$(printf " -p '%s'" "2")" \
|| commandline="${commandline}$(printf " -p '%s'" "0")" \
printf "%s\n" "$(gettext 'Ripping process started....')"
s="$commandline"
printf "%s\n" "$(eval_gettext 'Execute: $s')"
printf "%s\n" "----------------------------------------"
printf "%s\n" "$commandline" > "$LOCK_FILE"
export USER="$(whoami)"
eval "$commandline"
[ -f "$ABORT_FILE" ] && printf "%s\n" "$(gettext 'ABORTED!')" || printf "%s\n" "$(gettext 'ALL DONE!')"
else
printf "%s\n" "$(gettext 'ABORTED!')"
fi
vdr-opticaldrive stopburn
rm -f "$ABORT_FILE"
rm -f "$LOCK_FILE"
;;
esac
exit 0
|