#!/bin/bash # Winamp/HTTPQ IP address:port and access password PASS="xxxx" SCRIPT="http://10.0.0.15:4800" # Documentation for functions here: http://httpq.sourceforge.net/reference.html # Viewer for winamp: http://www.winamp.com/plugins/details/221728 - Joseph's DKE lyrics WinAmp plugin ## [mm:ss.xx] lyrics line 1 ## [mm:ss.xx] lyrics line 2 ## ... ## [mm:ss.xx] last lyrics line ## ## ID Tags may appear before the lyrics^[2] , although some players may not recognize or simply ignore this.^[citation needed] ## ## [al:Album where the song is from] ## [ar:Lyrics artist] ## [by:Creator of the LRC file] ## [offset:+/- Overall timestamp adjustment in milliseconds] ## [re:The player or editor that creates LRC file] ## [ti:Lyrics (song) title] ## [ve:version of program] if [ "$1" == "" ]; then echo "Usage: $0 []" exit 0 fi OUT="$2" if [ "$OUT" == "" ]; then OUT="$1".lrc; fi echo -n > "$OUT" delchar="`echo -ne "\177"`" cat "$1" | replace "ä" "a:" "ö" "o:" | while read y; do ## passthrough if [ "$y" == "" ]; then echo $y >> "$OUT" echo $y continue fi if [ "${y:0:1}" == "[" ]; then echo $y >> "$OUT" echo $y continue fi oldline=$x newline=$y undoline=0 x=$y z=0 ## while-do cycle for undo function while true; do echo -en "--------" : $x "\r" ## wait for keystroke read -s -n1 kbd < /dev/stderr ## make x, u, and backspace synonymous if [ "$kbd" == "$delchar" ]; then kbd="x"; elif [ "$kbd" == "u" ]; then kbd="x"; fi ## Player-specific section begin ## Here we set the OUTPUT variable, to the MM:SS.hh format. ## The specific example uses httpq extension in WinAmp, which yields output ## as a number of milliseconds since song beginning. ## Other players may need altering this section. OUTPUT=`curl -s "$SCRIPT/getoutputtime?p=$PASS&frmt=0"` OUTMSEC=$(( $OUTPUT % 1000 )) OUTSEC=$(( $OUTPUT / 1000 )) OUTMIN=$(( $OUTSEC / 60 )) OUTSEC=$(( $OUTSEC % 60 )) OUTMSEC=$(( $OUTMSEC / 10 )) if [ $OUTMSEC -lt 10 ]; then OUTMSEC=0$OUTMSEC; fi if [ $OUTSEC -lt 10 ]; then OUTSEC=0$OUTSEC; fi if [ $OUTMIN -lt 10 ]; then OUTMIN=0$OUTMIN; fi OUTPUT=$OUTMIN:$OUTSEC.$OUTMSEC ## Player-specific section end if [ "$kbd" == "q" ]; then echo echo "ABORTING" echo "ABORTING" >> "$OUT" exit 0 elif [ "$kbd" == "x" ]; then echo "^^^ UNDO LINE " echo "^^^ UNDO LINE" >> "$OUT" x=$oldline undoline=1 else echo $OUTPUT : $x " " echo "[$OUTPUT]$x" >> "$OUT" if [ "$undoline" == "1" ]; then x=$newline undoline=0 else break fi fi z=$(( $z + 1 )) done done ## LF to CRLF unix2dos "$OUT" chmod 644 "$OUT" echo echo ================== echo cat "$OUT"