4 grep -xq '[0-9]\+' <<<"$1"
8 if [ "${1##*.}" = mkv ]; then
10 elif [ "${1##*.}" = ogm ]; then
18 if [ -r aliases ]; then
19 while read alias rest; do
20 if [ "$alias" = "$1" ]; then
30 if [ -n "$debug" ]; then echo "finding base='$1', ep='$2', qual='$3'" >&2; fi
31 local base file tail eq eqt m matches max score
33 base="$(findbase "$1")"
34 for file in "$base"*; do
35 tail="${file#"$base"}"
38 if [ "${eq%% *}" -eq "$2" ] 2>/dev/null; then
39 if [[ "$eq" == *\ * ]]; then
45 elif [ "${eq:0:${#2}}" = "$2" ]; then
47 if [ "${eqt:0:1}" = " " -o -z "$eqt" ]; then
53 if [ "$eqt" = "$3" -o "$eqt" = "($3)" ]; then
54 matches=("${matches[@]}" "$file")
58 if [ ${#matches[@]} -lt 1 ]; then return 1; fi
60 for m in "${matches[@]}"; do
61 score="$(scorefile "$m")"
62 if [ -n "$debug" ]; then echo "found \`$m': score $score" >&2; fi
63 if [ -z "$max" ] || [ "$score" -gt "$max" ]; then
68 if [ -n "$debug" ]; then echo "using \`$file'" >&2; fi
74 cmdline=(mplayer -fs -ass)
76 unset pretend printfile
78 while [ "${1:0:1}" = - ]; do
83 echo "usage: planime [-fdhtC] [-A PLAYER-ARGS... ;] [-s PAR VAL] [--] [NAME-QUAL] [EP|.] [TYPE-QUAL]" >&2
90 cmdline=("${cmdline[@]}" -ao oss:/dev/dsp1)
99 if [ "$a" = \; ]; then
102 cmdline=("${cmdline[@]}" "$a")
118 echo "planime: unknown option \`$a'"
124 dirbase="$(basename "$(pwd)")"
129 if [ $# -eq 0 ]; then
131 elif [ $# -eq 1 ]; then
138 elif [ $# -eq 2 ]; then
139 if findfile "$dirbase - " "$1" "$2" >/dev/null; then
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 if [ "$base" = . ]; then
162 if [ -r curser ]; then
168 curser="$(findbase "$base")"
170 if [ -n "$curser" ]; then
171 file="$(findfile "$dirbase $curser - " "$ep" "$tqual")" || \
172 file="$(findfile "$curser - " "$ep" "$tqual")"
174 file="$(findfile "$dirbase - " "$ep" "$tqual")"
178 if [ -z "$file" -o ! -r "$file" ]; then
179 echo "planime: no matching file found" >&2
183 case "${file##*.}" in
194 ifile=".${file}.info"
196 if [ -n "$savepar" ]; then
197 if [ -r "$ifile" ]; then
198 egrep -v "^${savepar} " "$ifile" >"$ifile.new"
199 mv -f "$ifile.new" "$ifile"
201 echo "$savepar $saveval" >>"$ifile"
207 if [ -r "$ifile" ]; then
210 while read par arg; do
211 if [ "$par" = delay ]; then
212 cmdline=("${cmdline[@]}" -delay "$arg")
213 elif [ "$par" = aspect ]; then
214 cmdline=("${cmdline[@]}" -aspect "$arg")
215 elif [ "$par" = volmod ]; then
216 cmdline=("${cmdline[@]}" -af volume="$arg")
217 elif [ "$par" = alang ]; then
220 elif [ "$par" = aid ]; then
223 elif [ "$par" = slang ]; then
226 elif [ "$par" = sid ]; then
235 if [ -n "$alang" ]; then
236 cmdline=("${cmdline[@]}" -alang "$alang")
237 elif [ -n "$aid" ]; then
238 cmdline=("${cmdline[@]}" -aid "$aid")
240 if [ -n "$slang" ]; then
241 cmdline=("${cmdline[@]}" -slang "$slang")
242 elif [ -n "$sid" ]; then
243 cmdline=("${cmdline[@]}" -sid "$sid")
246 if [ "`hostname`" = pc6 -o "`hostname`" = pc7 -a "$DISPLAY" = :1 ]; then chwp=y; fi
248 if [ -n "$pretend" ]; then
249 echo "${cmdline[@]}" "$file"
250 elif [ -n "$printfile" ]; then
253 if [ "$chwp" = y ]; then (sleep 2; randomwp) & fi
254 "${cmdline[@]}" "$file"
256 if [ "$nextep" = y ]; then
257 echo "0. Save and continue (or Space)"
258 echo "1. Continue without saving"
259 echo "2. Save and exit (or Enter)"
260 echo "3. Exit without saving (or any key)"
276 if [ "$save" = y ]; then
280 if [ "$cont" = y ]; then
281 exec "${origargs[@]}"