Initial import.
authorfredrik <fredrik@959494ce-11ee-0310-bf91-de5d638817bd>
Sat, 9 Jun 2007 23:22:19 +0000 (23:22 +0000)
committerfredrik <fredrik@959494ce-11ee-0310-bf91-de5d638817bd>
Sat, 9 Jun 2007 23:22:19 +0000 (23:22 +0000)
git-svn-id: svn+ssh://svn.dolda2000.com/srv/svn/repos/src/utils@1066 959494ce-11ee-0310-bf91-de5d638817bd

planime [new file with mode: 0755]

diff --git a/planime b/planime
new file mode 100755 (executable)
index 0000000..899a1c9
--- /dev/null
+++ b/planime
@@ -0,0 +1,84 @@
+#!/bin/sh
+
+cmdline=(mplayer -fs)
+
+while [ "${1:0:1}" = - ]; do
+    a="$1"
+    shift
+    case "$a" in
+       -t)
+           cmdline=("${cmdline[@]}" -ao oss:/dev/dsp1)
+           ;;
+       -s)
+           savepar="$1"
+           shift
+           saveval="$1"
+           shift
+           ;;
+    esac
+done
+
+if [ $# -lt 1 ]; then
+    echo "usage: planime [QUAL] EPNUM" >&2
+    exit 1
+fi
+if [ $# -eq 1 ]; then
+    ep="$1"
+    unset qual
+elif [ $# -eq 2 ]; then
+    qual="$1"
+    ep="$2"
+fi
+
+if [ ! -r "$ep" ]; then
+    if [ -z "$qual" ]; then
+       ep="$(basename "$(pwd)") - ${ep}"
+    else
+       ep="$(basename "$(pwd)") ${qual} - ${ep}"
+    fi
+    if [ -r "${ep}.ogm" ]; then
+       ep="${ep}.ogm"
+       defopts=(-aid 1 -sid 0)
+    elif [ -r "${ep}.mkv" ]; then
+       ep="${ep}.mkv"
+       defopts=(-slang eng -alang jpn)
+    elif [ -r "${ep}.mpg" ]; then
+       ep="${ep}.mpg"
+    elif [ -r "${ep}.mp4" ]; then
+       ep="${ep}.mp4"
+    elif [ -r "${ep}.avi" ]; then
+       ep="${ep}.avi"
+    fi
+fi
+
+if [ ! -r "$ep" ]; then
+    echo "no such episode: $ep" >&2
+    exit 1
+fi
+
+ifile=".${ep}.info"
+
+if [ -n "$savepar" ]; then
+    if [ -r "$ifile" ]; then
+       exec 3<"$ifile"
+       rm "$ifile"
+       egrep -v "^${savepar}:" 0<&3 >"$ifile"
+       exec 3<&-
+    fi
+    echo "$savepar: $saveval" >>"$ifile"
+    exit 0
+fi
+
+unset delay
+
+if [ -r "$ifile" ]; then
+    delay="`sed -n 's/delay *: *\([^ ]*\)$/\1/p' <"$ifile"`"
+    cmdline=("${cmdline[@]}" -delay "$delay")
+else
+    cmdline=("${cmdline[@]}" "${defopts[@]}")
+fi
+
+if [ "`hostname`" = pc6 ]; then chwp=y; fi
+
+if [ "$chwp" = y ]; then (sleep 2; randomwp) & fi
+"${cmdline[@]}" "$ep"