commit b9e17e28bd118493b1dc9306cedfb28e4de02d58 (patch)
parent 09b77e7f5be3313091f997aa866da88b876cdb79
Author: Alex Karle <alex@alexkarle.com>
Date: Sun, 25 Apr 2021 13:30:47 -0400
cleanup: Move jam-tuesday/stats.sh -> bin/jam-stats.sh
This in prep for a real jam-tuesday/index.html
Diffstat:
3 files changed, 45 insertions(+), 44 deletions(-)
diff --git a/Makefile b/Makefile
@@ -25,8 +25,8 @@ index.html:
atom.xml: blog.7 bin/genatom.sh
./bin/genatom.sh > $@
-jam-tuesday/greatest-hits: $(SETS) jam-tuesday/stats.sh
- (date; echo; ./jam-tuesday/stats.sh) > $@
+jam-tuesday/greatest-hits: $(SETS) bin/jam-stats.sh
+ (date; echo; ./bin/jam-stats.sh) > $@
bin/kiosk: src/kiosk.c
$(CC) $(CFLAGS) -DMANDIR="\"`pwd`\"" src/kiosk.c -o $@
diff --git a/bin/jam-stats.sh b/bin/jam-stats.sh
@@ -0,0 +1,43 @@
+#!/bin/sh
+# stats.sh -- get frequencies of jam-tuesday songs/artists
+set -e
+
+N=${1:-10}
+REPO=$(dirname "$(dirname "$0")")
+DIR="$REPO/jam-tuesday"
+TMP=$(mktemp)
+for set in "$DIR"/[01][0-9]-*; do
+ # Remove leading notes, blank lines, and instrument/reprise
+ # comments (and blank lines before or after the comments)
+ sed '1,/---/d' "$set" | grep -v '^ *$' | sed 's/ *([^)]*) *//g'
+done > "$TMP"
+
+artists() {
+ sed 's/.*, *//' "$TMP" | sort -f | uniq -i -c
+}
+
+songs() {
+ sort -f "$TMP" | uniq -i -c
+}
+
+topN() {
+ sort -n -r | head -n "$N"
+}
+
+echo "Play Stats:"
+echo "-----------"
+printf "%4d Songs Total\\n" "$(wc -l < "$TMP")"
+printf "%4d Unique Songs\\n" "$(songs | wc -l)"
+printf "%4d Unique Artists\\n\\n" "$(artists | wc -l)"
+
+echo "Top $N Artists (Frequency, Name):"
+echo "---------------------------------"
+artists | topN
+
+echo ""
+echo "Top $N Songs (Frequency, Name):"
+echo "-------------------------------"
+songs | topN
+
+
+rm "$TMP"
diff --git a/jam-tuesday/stats.sh b/jam-tuesday/stats.sh
@@ -1,42 +0,0 @@
-#!/bin/sh
-# stats.sh -- get frequencies of jam-tuesday songs/artists
-set -e
-
-N=${1:-10}
-DIR=$(dirname "$0")
-TMP=$(mktemp)
-for set in "$DIR"/[01][0-9]-*; do
- # Remove leading notes, blank lines, and instrument/reprise
- # comments (and blank lines before or after the comments)
- sed '1,/---/d' "$set" | grep -v '^ *$' | sed 's/ *([^)]*) *//g'
-done > "$TMP"
-
-artists() {
- sed 's/.*, *//' "$TMP" | sort -f | uniq -i -c
-}
-
-songs() {
- sort -f "$TMP" | uniq -i -c
-}
-
-topN() {
- sort -n -r | head -n "$N"
-}
-
-echo "Play Stats:"
-echo "-----------"
-printf "%4d Songs Total\\n" "$(wc -l < "$TMP")"
-printf "%4d Unique Songs\\n" "$(songs | wc -l)"
-printf "%4d Unique Artists\\n\\n" "$(artists | wc -l)"
-
-echo "Top $N Artists (Frequency, Name):"
-echo "---------------------------------"
-artists | topN
-
-echo ""
-echo "Top $N Songs (Frequency, Name):"
-echo "-------------------------------"
-songs | topN
-
-
-rm "$TMP"