Thread: aUDIOBOOK?
View Single Post
konus's Avatar
Posts: 41 | Thanked: 21 times | Joined on Apr 2008 @ Nurnberg
#29
Originally Posted by jldiaz View Post
It did not work for me... I'm unsure why (because I don't fully understand its purpose, for example, the variable FILESUM). I have some ogg files, and your script relies on the assumption that only mp3 files are present.

Anyway...
i forget, that i use bash on my IT
i dont know, why, but in busybox this script dont work...
so, here is for busybox:
Code:
#!/bin/sh
if  [ -z "$1" ]
	then
	LASTFILE=`cat $HOME/.mplayer/abook.resume | tail -n2 | awk -Fmp3 '{print $1}'`
	RESPOINT=`cat $HOME/.mplayer/abook.resume | tail -n1`
	FILESUM=`wc -l $HOME/.mplayer/abook.plist | awk '/[0-1]/ {print $1}'`
	CPLIST=`cat $HOME/.mplayer/abook.plist | grep -A$FILESUM "$LASTFILE"`
	else
		echo " " > $HOME/.mplayer/abook.plist
		cd "$1"
		ABFILES=`ls -1`
		for I in $ABFILES
		do
			echo "`pwd`/$I" >> $HOME/.mplayer/abook.plist
		done
		CPLIST=`cat $HOME/.mplayer/abook.plist`
		RESPOINT=0
fi
mplayer -ss $RESPOINT $CPLIST > $HOME/.mplayer/abook.temp
awk '/Playing/ {print $2}' $HOME/.mplayer/abook.temp > $HOME/.mplayer/abook.resume
awk 'BEGIN{RS="\r"}{if ($1=="A:") t=$2}END{print t}' $HOME/.mplayer/abook.temp >> $HOME/.mplayer/abook.resume
about ogg...:

LASTFILE=`cat $HOME/.mplayer/abook.resume | tail -n2 | awk -Fmp3 '{print $1}'`

s/mp3/ogg/

and it will work...


What about the following? (not tested)

Code:
mplayer -ss $RESPOINT $CPLIST | awk 'BEGIN{RS="\r"}/Playing/{print $2}/^A:/{t=$2}END{print t}' > $HOME/.mplayer/abook.resume
The use of pipes in a single line avoids the existence of the temporal file, which is a good thing, because that file grows very faster (mplayer outputs status information about ten times per second!)
Thanks.