From 2847f2b9f73bc3ce016e808a091d8ce74ab2f199 Mon Sep 17 00:00:00 2001 From: Christopher Harrington Date: Wed, 10 Sep 2014 14:01:36 -0500 Subject: [PATCH] Example for capturing data from metadata FIFO This example script will read the metadata FIFO created by Shairport's -M option, and call a script with the read parameters. --- scripts/metadata_capture.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 scripts/metadata_capture.sh diff --git a/scripts/metadata_capture.sh b/scripts/metadata_capture.sh new file mode 100644 index 000000000..2f770950f --- /dev/null +++ b/scripts/metadata_capture.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +# Calls $TARGET_SCRIPT with the following parameters... +# $1: artist +# $2: title +# $3: album +# $4: genre +# $5: comment +# $6: The full pathname to the artwork file + +TARGET_SCRIPT="/home/user/shairport_now_playing.sh" +METADATA_DIR="/tmp/shairport" + +test -p $METADATA_DIR/now_playing || mkfifo $METADATA_DIR/now_playing + +while exec 3<$METADATA_DIR/now_playing +do +declare -A METADATA +IFS="=" +while read -u3 mK mV; do + if test "x$mK" = "x"; then break; fi + METADATA["$mK"]="$mV" +done +exec 3<&- +$TARGET_SCRIPT "${METADATA["artist"]}" "${METADATA["title"]}" "${METADATA["album"]}" \ + "${METADATA["genre"]}" "${METADATA["comment"]}" "$METADATA_DIR/${METADATA["artwork"]}" + +unset METADATA +done