alexkarle.com

Source for alexkarle.com
git clone git://git.alexkarle.com/alexkarle.com.git
Log | Files | Refs | README | LICENSE

commit c20ec2761ac2d90dc6162a655ff2fe3e6d6df27f (patch)
parent 6ac273d5bbee293ed78026c7f150c26c6240c128
Author: Alex Karle <alex@alexkarle.com>
Date:   Thu, 11 Nov 2021 21:17:18 -0500

jams: Add plaintext rendering of the full archive

For gopher!

Diffstat:
MMakefile | 2+-
Mbin/jam-stats.sh | 22+++++++++++++++++++++-
2 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile @@ -56,7 +56,7 @@ clean: # Individual files to build jam-tuesday/stats: $(SETS) bin/jam-stats.sh - (date; echo; $(DIR)/bin/jam-stats.sh) > $@ + (date; echo; $(DIR)/bin/jam-stats.sh -f) > $@ jam-tuesday/index.html: $(SETS) bin/jam-index.sh bin/jam-stats.sh $(DIR)/bin/jam-index.sh > $@ diff --git a/bin/jam-stats.sh b/bin/jam-stats.sh @@ -1,8 +1,9 @@ #!/bin/sh # stats.sh -- get frequencies of jam-tuesday songs/artists +# run with -f to show a plaintext table of the "full archive" set -e -N=${1:-10} +N=10 REPO=$(dirname "$(dirname "$0")") DIR="$REPO/jam-tuesday" TMP=$(mktemp) @@ -42,5 +43,24 @@ echo "Top $N Songs (Frequency, Name):" echo "-------------------------------" songs | topN +# TODO: Don't hardcode the width to be perfect (if we ever have more setlists...) +if [ "$1" = "-f" ]; then + printf "\n\n\nFull Archive:\n" + SEP="----------------------------+---------------------------------------+--\n" + sed 's/.*, *//' "$TMP" | sort -u -f | while read artist; do + first="" + grep ", *$artist\$" "$TMP" | sort -f | sed "s#, *$artist *##" | uniq -c -i | \ + while read plays song; do + if [ -z "$first" ]; then + first=1 + printf "$SEP" + printf "%-27s | %-37s |%2d\n" "$artist" "$song" "$plays" + else + printf "%-27s | %-37s |%2d\n" "" "$song" "$plays" + fi + done + done + printf "$SEP" +fi rm "$TMP"