Skip to content

Commit

Permalink
Use jq instead of sed voodoo to parse our data so it's more maintaina…
Browse files Browse the repository at this point in the history
…ble.
  • Loading branch information
Materdaddy committed Nov 4, 2015
1 parent cdc3e6c commit f29851f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "vastfmt"]
path = vastfmt
url = https://github.com/Materdaddy/vastfmt.git
[submodule "jq"]
path = jq
url = https://github.com/stedolan/jq.git
6 changes: 3 additions & 3 deletions callbacks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ case $operation in
vast_args="$vast_args --rds"
fi

# This voodoo turns our json into environment variables we
# can simply parse
eval $(echo $DATA | sed 's/^{//;s/}$//;s/,\s*/\n/g;s/"\([^"]*\)"\:\s*"\([^"]*\)"/\1="\2"/g')
# Use jq to parse our JSON data
artist=$(echo $DATA | ./jq/jq -r ".artist")
title=$(echo $DATA | ./jq/jq -r ".title")

# Try to grab artist if Media exists. This assumes the filename
# is "Artist - Title.extension"
Expand Down
8 changes: 8 additions & 0 deletions fpp_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,12 @@ make -C vastfmt CXX=$CXX
mkdir -p bin
cp vastfmt/radio bin/rds

# Get jq going for parsing our json data
pushd jq
autoreconf -i
./configure --disable-maintainer-mode
make src/builtin.inc
make
popd

popd
1 change: 1 addition & 0 deletions jq
Submodule jq added at 8f115e

0 comments on commit f29851f

Please sign in to comment.