[lastbash-cvs] lastbash lastbash,1.116,1.117
Status: Beta
Brought to you by:
cstroie
|
From: Costin S. <cs...@us...> - 2007-02-05 13:42:45
|
Update of /cvsroot/lastbash/lastbash In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv19605 Modified Files: lastbash Log Message: Added experimental support for saving csv formatted history. Index: lastbash =================================================================== RCS file: /cvsroot/lastbash/lastbash/lastbash,v retrieving revision 1.116 retrieving revision 1.117 diff -u -d -r1.116 -r1.117 --- lastbash 29 Jan 2007 16:47:37 -0000 1.116 +++ lastbash 5 Feb 2007 13:41:52 -0000 1.117 @@ -32,6 +32,7 @@ HTTP_CLIENT="auto" # $HTTP_CLIENTS, builtin, auto SAVE_NOWPLAYING="y" SAVE_HTML="y" +SAVE_HISTORY_CSV="y" # Program identification PROG_NAME="lastbash" @@ -62,6 +63,7 @@ COMMAND_FILE="${HOME_DIR}/command" COMMAND_FILE_LOCK="${HOME_DIR}/command.lock" NOWPLAYING_FILE="${HOME_DIR}/now_playing" +HISTORY_CVS_FILE="${HOME_DIR}/history.csv" # Internal stuff PLAYERS="mplayer" @@ -188,6 +190,28 @@ sed -e "/@LENGTH@/s#@LENGTH@#${META_MIN_SEC}#g" > "${HTML_FILE}" } +# Function: Save the history in a CSV formatted file {{{1 +#----------------------------------------------------------------------------- +function save_history_csv() +{ + # $1 - index of HISTORY array to display + + # Return if we should not save the history + [ "${SAVE_HISTORY_CSV}" == "y" ] || return + + # Return if the index is invalid + if [ "$1" -ge "${#HISTORY_ARTIST[*]}" ] || [ "$1" -lt 0 ] + then + return + fi + + # The first row contains the columns titles + [ -f "${HISTORY_CVS_FILE}" ] || echo "\"Artist\",\"Album\",\"Track\",\"Length\",\"Action\"" > "${HISTORY_CVS_FILE}" + + # Save the history items + echo "\"${HISTORY_ARTIST[$1]}\",\"${HISTORY_ALBUM[$1]}\",\"${HISTORY_TRACK[$1]}\",\"${HISTORY_DURATION[$1]}\",\"${HISTORY_ACTION[$1]}\"" >> "${HISTORY_CVS_FILE}" +} + # Function: Print usage summary {{{1 #----------------------------------------------------------------------------- function url_encode() @@ -1373,6 +1397,7 @@ HISTORY_ACTION[$HINDEX]="${PREV_ACTION}" tui_history "${HINDEX}" + save_history_csv "${HINDEX}" fi fi RET="0" |