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 dirbase="$(basename "$(pwd)")"
116 if [ $# -eq 0 ]; then
118 elif [ $# -eq 1 ]; then
125 elif [ $# -eq 2 ]; then
126 if findfile "$dirbase - " "$1" "$2" >/dev/null; then
139 if [ "$ep" = . ]; then nextep=y; fi
140 if [ "$nextep" = y -a -r nextep ]; then
142 if ! isnum "$ep"; then
143 echo "planime: nextep is non-numeric" >&2
147 if [ -z "$file" ]; then
148 if [ "$base" = . ]; then
149 if [ -r curser ]; then
157 if [ -n "$curser" ]; then
158 file="$(findfile "$dirbase $curser - " "$ep" "$tqual")" || \
159 file="$(findfile "$curser - " "$ep" "$tqual")"
161 file="$(findfile "$dirbase - " "$ep" "$tqual")"
165 if [ -z "$file" -o ! -r "$file" ]; then
166 echo "planime: no matching file found" >&2
170 case "${file##*.}" in
181 ifile=".${file}.info"
183 if [ -n "$savepar" ]; then
184 if [ -r "$ifile" ]; then
185 egrep -v "^${savepar} " "$ifile" >"$ifile.new"
186 mv -f "$ifile.new" "$ifile"
188 echo "$savepar $saveval" >>"$ifile"
194 if [ -r "$ifile" ]; then
197 while read par arg; do
198 if [ "$par" = delay ]; then
199 cmdline=("${cmdline[@]}" -delay "$arg")
200 elif [ "$par" = aspect ]; then
201 cmdline=("${cmdline[@]}" -aspect "$arg")
202 elif [ "$par" = volmod ]; then
203 cmdline=("${cmdline[@]}" -af volume="$arg")
204 elif [ "$par" = alang ]; then
207 elif [ "$par" = aid ]; then
210 elif [ "$par" = slang ]; then
213 elif [ "$par" = sid ]; then
222 if [ -n "$alang" ]; then
223 cmdline=("${cmdline[@]}" -alang "$alang")
224 elif [ -n "$aid" ]; then
225 cmdline=("${cmdline[@]}" -aid "$aid")
227 if [ -n "$slang" ]; then
228 cmdline=("${cmdline[@]}" -slang "$slang")
229 elif [ -n "$sid" ]; then
230 cmdline=("${cmdline[@]}" -sid "$sid")
233 if [ "`hostname`" = pc6 -o "`hostname`" = pc7 -a "$DISPLAY" = :1 ]; then chwp=y; fi
235 if [ -n "$pretend" ]; then
236 echo "${cmdline[@]}" "$file"
237 elif [ -n "$printfile" ]; then
240 if [ "$chwp" = y ]; then (sleep 2; randomwp) & fi
241 "${cmdline[@]}" "$file"
243 if [ "$nextep" = y ]; then
244 echo "0. Save and continue (or Space)"
245 echo "1. Continue without saving"
246 echo "2. Save and exit (or Enter)"
247 echo "3. Exit without saving (or any key)"
263 if [ "$save" = y ]; then
267 if [ "$cont" = y ]; then
268 exec "${origargs[@]}"