From 40777a191cb2a6f9c41cffe8faead32a251605c3 Mon Sep 17 00:00:00 2001 From: fredrik Date: Sat, 9 Jun 2007 23:22:19 +0000 Subject: [PATCH] Initial import. git-svn-id: svn+ssh://svn.dolda2000.com/srv/svn/repos/src/utils@1066 959494ce-11ee-0310-bf91-de5d638817bd --- planime | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100755 planime diff --git a/planime b/planime new file mode 100755 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" -- 2.11.0