Update of /cvsroot/lastbash/lastbash
In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv23267
Modified Files:
lastbash
Log Message:
Quick and dirty HTML output.
Index: lastbash
===================================================================
RCS file: /cvsroot/lastbash/lastbash/lastbash,v
retrieving revision 1.115
retrieving revision 1.116
diff -u -d -r1.115 -r1.116
--- lastbash 24 Jan 2007 15:22:14 -0000 1.115
+++ lastbash 29 Jan 2007 16:47:37 -0000 1.116
@@ -31,6 +31,7 @@
AUTO_PLAY="y"
HTTP_CLIENT="auto" # $HTTP_CLIENTS, builtin, auto
SAVE_NOWPLAYING="y"
+SAVE_HTML="y"
# Program identification
PROG_NAME="lastbash"
@@ -66,6 +67,7 @@
PLAYERS="mplayer"
HTTP_CLIENTS="wget curl"
REQ_PROGRAMS="rm date tput stty md5sum dd chmod"
+HTML_TEMPLATE="${HOME_DIR}/lastbash-template.html"
PLAYER_PID=""
declare -a HTTP_HEADERS HTTP_RESPONSE
declare -a HISTORY_ARTIST HISTORY_ALBUM HISTORY_TRACK HISTORY_DURATION HISTORY_MIN_SEC HISTORY_ACTION
@@ -157,6 +159,35 @@
[ "${SAVE_NOWPLAYING}" == "y" ] && echo -n "$1" > "${NOWPLAYING_FILE}"
}
+# Function: Save the HTML file {{{1
+#-----------------------------------------------------------------------------
+function save_html()
+{
+ # Return if we should not save the html file or the template is missing
+ if [ "${SAVE_HTML}" != "y" ] || [ ! -f "${HTML_TEMPLATE}" ]
+ then
+ return
+ fi
+
+ # Replace the placeholders in template
+ # Placeholders:
+ # @TITLE@ @COVER_URL@ @ARTIST_URL@ @ARTIST_NAME@ @TRACK_URL@ @LENGTH@
+ # @TRACK_NAME@ @ALBUM_URL@ @ALBUM_NAME@ @STATION_URL@ @STATION_NAME@
+
+ cat "${HTML_TEMPLATE}" | \
+ sed -e "/@TITLE@/s#@TITLE@#${META_ARTIST} - ${META_TRACK}#g" | \
+ sed -e "/@COVER_URL@/s#@COVER_URL@#${META_COVER}#g" | \
+ sed -e "/@ARTIST_URL@/s#@ARTIST_URL@#${META_ARTIST_URL}#g" | \
+ sed -e "/@ARTIST_NAME@/s#@ARTIST_NAME@#${META_ARTIST}#g" | \
+ sed -e "/@TRACK_URL@/s#@TRACK_URL@#${META_TRACK_URL}#g" | \
+ sed -e "/@TRACK_NAME@/s#@TRACK_NAME@#${META_TRACK}#g" | \
+ sed -e "/@ALBUM_URL@/s#@ALBUM_URL@#${META_ALBUM_URL}#g" | \
+ sed -e "/@ALBUM_NAME@/s#@ALBUM_NAME@#${META_ALBUM}#g" | \
+ sed -e "/@STATION_URL@/s#@STATION_URL@#${META_STATION}#g" | \
+ sed -e "/@STATION_NAME@/s#@STATION_NAME@#${META_STATION}#g" | \
+ sed -e "/@LENGTH@/s#@LENGTH@#${META_MIN_SEC}#g" > "${HTML_FILE}"
+}
+
# Function: Print usage summary {{{1
#-----------------------------------------------------------------------------
function url_encode()
@@ -650,7 +681,7 @@
then
# Do this only if ok
unset META_ARTIST META_ARTIST_URL META_TRACK META_TRACK_URL META_ALBUM META_ALBUM_URL META_COVER
- unset META_DURATION META_STATION META_STREAMING META_DISCOVERY META_RADIOMODE META_RTP
+ unset META_DURATION META_STATION META_STATION_URL META_STREAMING META_DISCOVERY META_RADIOMODE META_RTP
# Parse the result
for ((N=0; N<=${#HTTP_RESPONSE[@]}; N++))
@@ -667,6 +698,7 @@
"albumcover_medium") META_COVER="${VALUE}" ;;
"trackduration") META_DURATION="${VALUE}" ;;
"station") META_STATION="${VALUE}" ;;
+ "station_url") META_STATION_URL="${VALUE}" ;;
"streaming") META_STREAMING="${VALUE}" ;;
"discovery") META_DISCOVERY="${VALUE}" ;;
"radiomode") META_RADIOMODE="${VALUE}" ;;
@@ -1091,9 +1123,11 @@
then
set_term_title "${META_ARTIST} - ${META_TRACK}"
save_nowplaying "${META_ARTIST} - ${META_TRACK}"
+ save_html "1"
else
set_term_title "${PROG_TITLE}: Not streaming"
save_nowplaying
+ save_html
fi
}
|