[lastbash-cvs] lastbash lastbash,1.98,1.99
Status: Beta
Brought to you by:
cstroie
|
From: Costin S. <cs...@us...> - 2006-12-11 22:57:26
|
Update of /cvsroot/lastbash/lastbash In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv20889 Modified Files: lastbash Log Message: Display changing station errors. Index: lastbash =================================================================== RCS file: /cvsroot/lastbash/lastbash/lastbash,v retrieving revision 1.98 retrieving revision 1.99 diff -u -d -r1.98 -r1.99 --- lastbash 9 Dec 2006 12:26:37 -0000 1.98 +++ lastbash 11 Dec 2006 22:57:18 -0000 1.99 @@ -689,7 +689,7 @@ local URL=$(url_encode "$2") local WS_RESPONSE WS_ERROR local LASTFM_URL LASTFM_STATIONNAME - local RET ERRMSG + local RET # Do the http get if http_get "${LASTFM_BASEURL}" "${LASTFM_PORT}" "${LASTFM_BASEPATH}/adjust.php?session=$1&url=${URL}" @@ -710,24 +710,20 @@ # Check the returned data if [ "${WS_RESPONSE}" != "OK" ] then - # FIXME Are these the error codes? - case "${WS_ERROR}" in - "1") RET="2"; ERRMSG="Not enough content to play this station" ;; - "2") RET="3"; ERRMSG="Not enough members for radio" ;; - "3") RET="4"; ERRMSG="Not enough fans for radio" ;; - "4") RET="5"; ERRMSG="Not available for streaming" ;; - "5") RET="6"; ERRMSG="Feature only available to subscribers" ;; - "6") RET="7"; ERRMSG="Not enough neighbours for this radio" ;; - "7") RET="8"; ERRMSG="Streaming system is offline for maintenance" ;; - *) RET="255"; ERRMSG="Changing station failed for unknown error" ;; - esac - debug "${FUNCNAME}: Error ${WS_ERROR}. ${ERRMSG}" + if [[ "${WS_ERROR}" == ${NUMBER_REGEXP} ]] + then + debug "${FUNCNAME}: Error ${WS_ERROR}. Changing station failed" + RET="${WS_ERROR}" + else + debug "${FUNCNAME}: Changing station failed for unknown error" + RET="255" + fi else RET="0" debug "${FUNCNAME}: Station changed" fi else - RET="1" + RET="255" debug "${FUNCNAME}: Changing station failed" fi @@ -1310,32 +1306,35 @@ #----------------------------------------------------------------------------- function tui_lastfm_connect() { - local ERRCODE RET + local RET # Set the status line tui_sbar "Connecting to Last.fm..." # Try connecting lastfm_connect "${LASTFM_USER}" "${LASTFM_PASS}" - ERRCODE="$?" + RET="$?" # Check the error code - if [ "${ERRCODE}" == "0" ] + if [ "${RET}" == "0" ] then # TODO Display the LASTFM_INFO_MESSAGE - RET="0" - # Update the status line - tui_sbar "Connected" - sleep 1 # Change the station, if required - [ "${LASTFM_STATION}" ] && tui_lastfm_station "${LASTFM_STATION}" - elif [ "${ERRCODE}" == "2" ] + if [ "${LASTFM_STATION}" ] + then + tui_lastfm_station "${LASTFM_STATION}" + else + # Update the status line + tui_sbar "Connected" + sleep 1 + # Get the initial metadata + tui_metadata + fi + elif [ "${RET}" == "2" ] then - RET="2" tui_sbar "Last.fm session failed, check credentials" - elif [ "${ERRCODE}" == "3" ] + elif [ "${RET}" == "3" ] then - RET="3" tui_sbar "Player banned, contact the author" else RET="1" @@ -1352,30 +1351,39 @@ { # $1 - station - local ERRCODE RET + local RET ERRMSG # Set the status line tui_sbar "Setting new Last.fm station..." # Try changing the station lastfm_station "${LASTFM_SESSION}" "$1" - ERRCODE="$?" + RET="$?" # Check the error code - if [ "${ERRCODE}" == "0" ] + if [ "${RET}" == "0" ] then - RET="0" # Update the status line tui_sbar "Station changed" else - # TODO Display the detailed error messages - RET="1" - tui_sbar "Changing station failed" + case "${RET}" in + "1") ERRMSG="Not enough content to play this station" ;; + "2") ERRMSG="The group has not enough members for radio" ;; + "3") ERRMSG="The artist has not enough fans for radio" ;; + "4") ERRMSG="The item is not available for streaming" ;; + "5") ERRMSG="Feature available only to subscribers" ;; + "6") ERRMSG="Not enough neighbours for this radio" ;; + "7") ERRMSG="Streaming system is offline for maintenance" ;; + *) ERRMSG="Changing station failed for unknown error" ;; + esac + + # Display the detailed error messages + tui_sbar "${ERRMSG}" fi - # Sleep one moment and refresh the metadata + # Sleep one moment sleep 1 - tui_metadata + #[ "${RET}" == "0" ] && tui_metadata # Return the status code return "${RET}" @@ -2069,8 +2077,6 @@ then # Start the player player_start - # Get the initial metadata - tui_metadata # Enter the readkey loop read_key_loop else |