4 grep -xq '[0-9]\+' <<<"$1"
8 if [ "${1##*.}" = mkv ]; then
10 elif [ "${1##*.}" = ogm ]; then
18 local file tail eq eqt m matches max score
24 if [ "${eq%% *}" -eq "$2" ] 2>/dev/null; then
25 if [[ "$eq" == *\ * ]]; then
31 elif [ "${eq:0:${#2}}" = "$2" ]; then
33 if [ "${eqt:0:1}" = " " -o -z "$eqt" ]; then
39 if [ "$eqt" = "$3" -o "$eqt" = "($3)" ]; then
40 matches=("${matches[@]}" "$file")
44 if [ ${#matches[@]} -lt 1 ]; then return 1; fi
46 for m in "${matches[@]}"; do
47 score="$(scorefile "$m")"
48 if [ -z "$max" ] || [ "$score" -gt "$max" ]; then
58 cmdline=(mplayer -fs -ass)
61 while [ "${1:0:1}" = - ]; do
66 echo "usage: planime [-htC] [-s PAR VAL] [NAME-QUAL] [EP|.] [TYPE-QUAL]" >&2
70 cmdline=("${cmdline[@]}" -ao oss:/dev/dsp1)
79 if [ "$a" = \; ]; then
82 cmdline=("${cmdline[@]}" "$a")
94 base="$(basename "$(pwd)")"
100 if [ -r curser ]; then
101 base="$base $(<curser)"
103 elif [ $# -eq 1 ]; then
107 if findfile "$base - " "$1" >/dev/null; then
114 elif [ $# -eq 2 ]; then
115 if findfile "$base - " "$1" "$2" >/dev/null; then
119 if [ "$1" = . -a -r curser ]; then
120 base="$base $(<curser)"
127 if [ "$1" = . -a -r curser ]; then
128 base="$base $(<curser)"
135 if [ "$ep" = . ]; then nextep=y; fi
136 if [ "$nextep" = y -a -r nextep ]; then
138 if ! isnum "$ep"; then
139 echo "planime: nextep is non-numeric" >&2
143 if [ -z "$file" ]; then
144 file="$(findfile "$base - " "$ep" "$tqual")"
147 if [ -z "$file" -o ! -r "$file" ]; then
148 echo "planime: no matching file found" >&2
152 case "${file##*.}" in
163 ifile=".${file}.info"
165 if [ -n "$savepar" ]; then
166 if [ -r "$ifile" ]; then
167 egrep -v "^${savepar} " "$ifile" >"$ifile.new"
168 mv -f "$ifile.new" "$ifile"
170 echo "$savepar $saveval" >>"$ifile"
176 if [ -r "$ifile" ]; then
179 while read par arg; do
180 if [ "$par" = delay ]; then
181 cmdline=("${cmdline[@]}" -delay "$arg")
182 elif [ "$par" = aspect ]; then
183 cmdline=("${cmdline[@]}" -aspect "$arg")
184 elif [ "$par" = volmod ]; then
185 cmdline=("${cmdline[@]}" -af volume="$arg")
186 elif [ "$par" = alang ]; then
189 elif [ "$par" = aid ]; then
192 elif [ "$par" = slang ]; then
195 elif [ "$par" = sid ]; then
204 if [ -n "$alang" ]; then
205 cmdline=("${cmdline[@]}" -alang "$alang")
206 elif [ -n "$aid" ]; then
207 cmdline=("${cmdline[@]}" -aid "$aid")
209 if [ -n "$slang" ]; then
210 cmdline=("${cmdline[@]}" -slang "$slang")
211 elif [ -n "$sid" ]; then
212 cmdline=("${cmdline[@]}" -sid "$sid")
215 if [ "`hostname`" = pc6 -o "`hostname`" = pc7 -a "$DISPLAY" = :1 ]; then chwp=y; fi
217 if [ -n "$pretend" ]; then
218 echo "${cmdline[@]}" "$file"
220 if [ "$chwp" = y ]; then (sleep 2; randomwp) & fi
221 "${cmdline[@]}" "$file"
223 if [ "$nextep" = y ]; then
224 echo "0. Save and continue (or Space)"
225 echo "1. Continue without saving"
226 echo "2. Save and exit (or Enter)"
227 echo "3. Exit without saving (or any key)"
243 if [ "$save" = y ]; then
247 if [ "$cont" = y ]; then
248 exec "${origargs[@]}"