[lastbash-cvs] lastbash lastbash,1.74,1.75
Status: Beta
Brought to you by:
cstroie
|
From: Costin S. <cs...@us...> - 2006-12-05 12:53:53
|
Update of /cvsroot/lastbash/lastbash In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv6801 Modified Files: lastbash Log Message: Initial support for history storing and better duration treatment. Index: lastbash =================================================================== RCS file: /cvsroot/lastbash/lastbash/lastbash,v retrieving revision 1.74 retrieving revision 1.75 diff -u -d -r1.74 -r1.75 --- lastbash 4 Dec 2006 16:57:36 -0000 1.74 +++ lastbash 5 Dec 2006 12:53:49 -0000 1.75 @@ -65,6 +65,7 @@ HTTP_CLIENTS="wget curl" REQ_PROGRAMS="rm date sleep tput md5sum dd chmod" declare -a HTTP_HEADERS HTTP_RESPONSE +declare -a HISTORY_ARTIST HISTORY_ALBUM HISTORY_TRACK HISTORY_DURATION HISTORY_MIN_SEC HISTORY_ACTION CR=$'\x0d' LF=$'\x0a' CTRL_L=$'\x0c' @@ -914,7 +915,7 @@ #----------------------------------------------------------------------------- function tui_current() { - local LINE ACTION + local LINE printf -v LINE "${T_ATTR_BOLD}%7s${T_ATTR_NORMAL} : %s" "${LBL_ARTIST}" "${META_ARTIST:0:$TCURRENT_MAX}" tput cup 2 2 @@ -928,24 +929,11 @@ tput cup 4 2 echo -ne "${LINE}${T_EL}" - printf -v LINE "${T_ATTR_BOLD}%7s${T_ATTR_NORMAL} : %d:%02d" "${LBL_LENGTH}" "${META_MIN}" "${META_SEC}" + printf -v LINE "${T_ATTR_BOLD}%7s${T_ATTR_NORMAL} : %s" "${LBL_LENGTH}" "${META_MIN_SEC}" tput cup 5 2 echo -ne "${LINE}${T_EL}" - if [ "${META_ACTION_LOVE}" ] - then - ACTION="Loved" - elif [ "${META_ACTION_SKIP}" ] - then - ACTION="Skipped" - elif [ "${META_ACTION_BAN}" ] - then - ACTION="Banned" - else - ACTION="" - fi - - printf -v LINE "${T_ATTR_BOLD}%7s${T_ATTR_NORMAL} : %s" "${LBL_ACTION}" "${ACTION}" + printf -v LINE "${T_ATTR_BOLD}%7s${T_ATTR_NORMAL} : %s" "${LBL_ACTION}" "${META_ACTION}" tput cup 6 2 echo -ne "${LINE}${T_EL}" @@ -1001,12 +989,9 @@ local FIELD LINE S # Start with the love/ban indicator - if [ "${PREV_ACTION_LOVE}" ] - then - LINE=" L" - elif [ "${PREV_ACTION_BAN}" ] + if [ "${PREV_ACTION}" ] then - LINE=" B" + LINE=" ${PREV_ACTION:0:1}" else LINE=" " fi @@ -1033,7 +1018,7 @@ LINE="${LINE}${FIELD}" # Add the track duration - printf -v FIELD " %3d:%02d " "${PREV_MIN}" "${PREV_SEC}" + printf -v FIELD " %6s " "${PREV_MIN_SEC}" LINE="${LINE}${FIELD}" # Output the line @@ -1051,10 +1036,8 @@ local PREV_ALBUM="${META_ALBUM}" local PREV_TRACK="${META_TRACK}" local PREV_DURATION="${META_DURATION}" - local PREV_MIN="${META_MIN}" - local PREV_SEC="${META_SEC}" - local PREV_ACTION_LOVE="${META_ACTION_LOVE}" - local PREV_ACTION_BAN="${META_ACTION_BAN}" + local PREV_MIN_SEC="${META_MIN_SEC}" + local PREV_ACTION="${META_ACTION}" # Set the status line tui_sbar "Retrieving metadata..." @@ -1068,16 +1051,24 @@ [ "${META_TRACK}" != "${PREV_TRACK}" ] || \ [ "${META_DURATION}" != "${PREV_DURATION}" ] then + # Save in history + HINDEX="${#HISTORY_ARTIST[*]}" + HISTORY_ARTIST[$HINDEX]="${PREV_ARTIST}" + HISTORY_ALBUM[$HINDEX]="${PREV_ALBUM}" + HISTORY_TRACK[$HINDEX]="${PREV_TRACK}" + HISTORY_DURATION[$HINDEX]="${PREV_DURATION}" + HISTORY_MIN_SEC[$HINDEX]="${PREV_MIN_SEC}" + HISTORY_ACTION[$HINDEX]="${META_ACTION}" + # Clear the action - unset META_ACTION_LOVE META_ACTION_SKIP META_ACTION_BAN + unset META_ACTION META_ACTION_LOVE META_ACTION_SKIP META_ACTION_BAN + # Compute the minutes and seconds only if streaming if [ "${META_STREAMING}" == "true" ] then - META_MIN=$(( META_DURATION / 60 )) - META_SEC=$(( META_DURATION % 60 )) + printf -v META_MIN_SEC "%d:%02d" "$(( META_DURATION / 60 ))" "$(( META_DURATION % 60 ))" else - META_MIN="00" - META_SEC="00" + unset META_MIN_SEC fi # Refresh the display tui_current @@ -1217,6 +1208,7 @@ then RET="0" META_ACTION_LOVE="y" + META_ACTION="Loved" # Refresh the display tui_current @@ -1272,6 +1264,7 @@ then RET="0" META_ACTION_BAN="y" + META_ACTION="Banned" # Refresh the display tui_current |