4 grep -xq '[0-9]\+' <<<"$1"
8 if [ "${1##*.}" = mkv ]; then
10 elif [ "${1##*.}" = ogm ]; then
18 if [ -n "$debug" ]; then echo "finding base='$1', ep='$2', qual='$3'" >&2; fi
19 local file tail eq eqt m matches max score
25 if [ "${eq%% *}" -eq "$2" ] 2>/dev/null; then
26 if [[ "$eq" == *\ * ]]; then
32 elif [ "${eq:0:${#2}}" = "$2" ]; then
34 if [ "${eqt:0:1}" = " " -o -z "$eqt" ]; then
40 if [ "$eqt" = "$3" -o "$eqt" = "($3)" ]; then
41 matches=("${matches[@]}" "$file")
45 if [ ${#matches[@]} -lt 1 ]; then return 1; fi
47 for m in "${matches[@]}"; do
48 score="$(scorefile "$m")"
49 if [ -n "$debug" ]; then echo "found \`$m': score $score" >&2; fi
50 if [ -z "$max" ] || [ "$score" -gt "$max" ]; then
55 if [ -n "$debug" ]; then echo "using \`$file'" >&2; fi
61 cmdline=(mplayer -fs -ass)
63 unset pretend printfile
65 while [ "${1:0:1}" = - ]; do
70 echo "usage: planime [-fdhtC] [-A PLAYER-ARGS... ;] [-s PAR VAL] [--] [NAME-QUAL] [EP|.] [TYPE-QUAL]" >&2
77 cmdline=("${cmdline[@]}" -ao oss:/dev/dsp1)
86 if [ "$a" = \; ]; then
89 cmdline=("${cmdline[@]}" "$a")
105 echo "planime: unknown option \`$a'"
111 base="$(basename "$(pwd)")"
115 if [ $# -eq 0 ]; then
117 if [ -r curser ]; then
118 base="$base $(<curser)"
120 elif [ $# -eq 1 ]; then
124 if findfile "$base - " "$1" >/dev/null; then
131 elif [ $# -eq 2 ]; then
132 if findfile "$base - " "$1" "$2" >/dev/null; then
136 if [ "$1" = . -a -r curser ]; then
137 base="$base $(<curser)"
144 if [ "$1" = . -a -r curser ]; then
145 base="$base $(<curser)"
152 if [ "$ep" = . ]; then nextep=y; fi
153 if [ "$nextep" = y -a -r nextep ]; then
155 if ! isnum "$ep"; then
156 echo "planime: nextep is non-numeric" >&2
160 if [ -z "$file" ]; then
161 file="$(findfile "$base - " "$ep" "$tqual")"
164 if [ -z "$file" -o ! -r "$file" ]; then
165 echo "planime: no matching file found" >&2
169 case "${file##*.}" in
180 ifile=".${file}.info"
182 if [ -n "$savepar" ]; then
183 if [ -r "$ifile" ]; then
184 egrep -v "^${savepar} " "$ifile" >"$ifile.new"
185 mv -f "$ifile.new" "$ifile"
187 echo "$savepar $saveval" >>"$ifile"
193 if [ -r "$ifile" ]; then
196 while read par arg; do
197 if [ "$par" = delay ]; then
198 cmdline=("${cmdline[@]}" -delay "$arg")
199 elif [ "$par" = aspect ]; then
200 cmdline=("${cmdline[@]}" -aspect "$arg")
201 elif [ "$par" = volmod ]; then
202 cmdline=("${cmdline[@]}" -af volume="$arg")
203 elif [ "$par" = alang ]; then
206 elif [ "$par" = aid ]; then
209 elif [ "$par" = slang ]; then
212 elif [ "$par" = sid ]; then
221 if [ -n "$alang" ]; then
222 cmdline=("${cmdline[@]}" -alang "$alang")
223 elif [ -n "$aid" ]; then
224 cmdline=("${cmdline[@]}" -aid "$aid")
226 if [ -n "$slang" ]; then
227 cmdline=("${cmdline[@]}" -slang "$slang")
228 elif [ -n "$sid" ]; then
229 cmdline=("${cmdline[@]}" -sid "$sid")
232 if [ "`hostname`" = pc6 -o "`hostname`" = pc7 -a "$DISPLAY" = :1 ]; then chwp=y; fi
234 if [ -n "$pretend" ]; then
235 echo "${cmdline[@]}" "$file"
236 elif [ -n "$printfile" ]; then
239 if [ "$chwp" = y ]; then (sleep 2; randomwp) & fi
240 "${cmdline[@]}" "$file"
242 if [ "$nextep" = y ]; then
243 echo "0. Save and continue (or Space)"
244 echo "1. Continue without saving"
245 echo "2. Save and exit (or Enter)"
246 echo "3. Exit without saving (or any key)"
262 if [ "$save" = y ]; then
266 if [ "$cont" = y ]; then
267 exec "${origargs[@]}"