cmus2tsv

convert cmus' cache format to TSV
Log | Files | Refs

commit 5ee81984044a4b675bc3a395545fb2b8f1c1e886
parent 8bb8323de3c5769f5e2eb519921906138b764691
Author: hhvn <dev@hhvn.uk>
Date:   Mon, 25 Jul 2022 11:30:05 +0100

cmusextractpl

Diffstat:
MMakefile | 2++
Acmusextractpl | 19+++++++++++++++++++
2 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/Makefile b/Makefile @@ -4,6 +4,7 @@ SRC = cmus2tsv.c OBJ = $(SRC:.c=.o) BIN = cmus2tsv CFLAGS = -g3 -O0 +SH = cmusextractpl all: $(BIN) $(BIN): $(OBJ) @@ -14,6 +15,7 @@ clean: install: install -m0755 $(BIN) $(BINDIR)/$(BIN) + install -m0755 $(SH) $(BINDIR)/$(SH) uninstall: rm -f $(BINDIR)/$(BIN) diff --git a/cmusextractpl b/cmusextractpl @@ -0,0 +1,19 @@ +#!/bin/sh +# +# This script prints only the cached information for files in a playlist. +# +# cmus' cache stores information on all files ever added, even if they are then +# deleted from the library. Since the library can be exported as a playlist +# (:save -l library.pl), this sscript makes it possible to get cache +# information restricted to what is present in the library. (And also if you +# want information from playlists, as well, I guess). + +[ -z $1 ] && { + echo "usage: extractpl <playlist> [cmus2tsv args]" + exit 2 +} + +pl="$1" +shift + +cmus2tsv "$@" | cat "$pl" - | awk -F"\t" 'NF == 1 {saw[$1] = 1}; NF > 1 && saw[$1] == 1'