40777a19 |
1 | #!/bin/sh |
2 | |
3 | cmdline=(mplayer -fs) |
4 | |
5 | while [ "${1:0:1}" = - ]; do |
6 | a="$1" |
7 | shift |
8 | case "$a" in |
9 | -t) |
10 | cmdline=("${cmdline[@]}" -ao oss:/dev/dsp1) |
11 | ;; |
12 | -s) |
13 | savepar="$1" |
14 | shift |
15 | saveval="$1" |
16 | shift |
17 | ;; |
18 | esac |
19 | done |
20 | |
21 | if [ $# -lt 1 ]; then |
22 | echo "usage: planime [QUAL] EPNUM" >&2 |
23 | exit 1 |
24 | fi |
25 | if [ $# -eq 1 ]; then |
26 | ep="$1" |
27 | unset qual |
28 | elif [ $# -eq 2 ]; then |
29 | qual="$1" |
30 | ep="$2" |
31 | fi |
32 | |
33 | if [ ! -r "$ep" ]; then |
34 | if [ -z "$qual" ]; then |
35 | ep="$(basename "$(pwd)") - ${ep}" |
36 | else |
37 | ep="$(basename "$(pwd)") ${qual} - ${ep}" |
38 | fi |
39 | if [ -r "${ep}.ogm" ]; then |
40 | ep="${ep}.ogm" |
41 | defopts=(-aid 1 -sid 0) |
42 | elif [ -r "${ep}.mkv" ]; then |
43 | ep="${ep}.mkv" |
44 | defopts=(-slang eng -alang jpn) |
45 | elif [ -r "${ep}.mpg" ]; then |
46 | ep="${ep}.mpg" |
47 | elif [ -r "${ep}.mp4" ]; then |
48 | ep="${ep}.mp4" |
49 | elif [ -r "${ep}.avi" ]; then |
50 | ep="${ep}.avi" |
51 | fi |
52 | fi |
53 | |
54 | if [ ! -r "$ep" ]; then |
55 | echo "no such episode: $ep" >&2 |
56 | exit 1 |
57 | fi |
58 | |
59 | ifile=".${ep}.info" |
60 | |
61 | if [ -n "$savepar" ]; then |
62 | if [ -r "$ifile" ]; then |
081b510d |
63 | egrep -v "^${savepar}:" "$ifile" >"$ifile.new" |
64 | mv -f "$ifile.new" "$ifile" |
40777a19 |
65 | fi |
66 | echo "$savepar: $saveval" >>"$ifile" |
67 | exit 0 |
68 | fi |
69 | |
70 | unset delay |
71 | |
72 | if [ -r "$ifile" ]; then |
73 | delay="`sed -n 's/delay *: *\([^ ]*\)$/\1/p' <"$ifile"`" |
74 | cmdline=("${cmdline[@]}" -delay "$delay") |
75 | else |
76 | cmdline=("${cmdline[@]}" "${defopts[@]}") |
77 | fi |
78 | |
79 | if [ "`hostname`" = pc6 ]; then chwp=y; fi |
80 | |
81 | if [ "$chwp" = y ]; then (sleep 2; randomwp) & fi |
82 | "${cmdline[@]}" "$ep" |