1
0

Update to an album-based collection

This commit is contained in:
2025-05-02 17:31:04 -04:00
parent 46b18734b3
commit 8a8ef0b3b4
3 changed files with 65 additions and 50 deletions

View File

@ -1,56 +1,72 @@
# ---- Project Settings --------------------------------------------------------
B2_BUCKET =
PROJECT_NAME =
SSH_LOCATION =
CELLAR_BOTTLE =
PROJECT_ID =
INSTALL_DIR =
INSTALL_DIR =
B2_TRACKS = $(B2_BUCKET)/$(PROJECT_NAME)/tracks
B2_ARTWORK = $(B2_BUCKET)/$(PROJECT_NAME)/artwork
CELLAR_TRACKS = $(CELLAR_BOTTLE)/$(PROJECT_ID)/tracks
CELLAR_METADATA = $(CELLAR_BOTTLE)/$(PROJECT_ID)/metadata.csv
CELLAR_ARTWORK = $(CELLAR_BOTTLE)/$(PROJECT_ID)/artwork.png
# ---- Makefile Settings -------------------------------------------------------
TRACK_LIST := $(notdir $(shell b2 ls $(B2_TRACKS)))
TRACK_LIST := $(shell ssh $(SSH_LOCATION) "ls $(CELLAR_TRACKS)")
FLAC_FILES := $(addprefix out/, $(addsuffix .flac, $(TRACK_LIST)))
GREEN = \e[32m
CYAN = \e[36m
END = \e[0m
.PHONY: all install
.PRECIOUS: out/%.flac
.PHONY: all install clean setup
# ---- Pipeline ----------------------------------------------------------------
all: $(FLAC_FILES)
all: setup install
install:
@mamba run -n Instrumental_Music_Collection python src/install.py \
-td out \
-m data/metadata.csv \
-d "$(INSTALL_DIR)"
setup:
@printf "%b %s\n" "$(CYAN)[ > ]$(END) Create working directory structure"
@mkdir -p data/tracks
@mkdir -p out/
@printf "%b %s\n" "$(GREEN)[ ✓ ]$(END) Create working directory structure"
data/tracks/%.track:
@printf "%b %s\n" "$(CYAN)[ > ]$(END) Download" "$(notdir $@)"
@b2 file download --no-progress \
$(B2_BUCKET)/$(PROJECT_NAME)/tracks/$(basename $(notdir $@)) \
$@ > /dev/null
@rsync -az -s "$(SSH_LOCATION):$(CELLAR_TRACKS)/$(basename $(notdir $@))" "$@"
@printf "%b %s\n" "$(GREEN)[ ✓ ]$(END) Download" "$(notdir $@)"
data/artwork:
@printf "%b\n" "$(CYAN)[ > ]$(END) Download Artwork"
@mkdir -p $@
@b2 sync --no-progress \
$(B2_ARTWORK) \
$@ > /dev/null
@printf "%b\n" "$(GREEN)[ ✓ ]$(END) Download Artwork"
data/metadata.csv:
@printf "%b %s\n" "$(CYAN)[ > ]$(END) Download" "$(notdir $@)"
@rsync -az -s "$(SSH_LOCATION):$(CELLAR_METADATA)" "$@"
@printf "%b %s\n" "$(GREEN)[ ✓ ]$(END) Download" "$(notdir $@)"
out/%.flac: data/tracks/%.track data/metadata.csv | data/artwork
data/artwork.png:
@printf "%b %s\n" "$(CYAN)[ > ]$(END) Download" "$(notdir $@)"
@rsync -az -s "$(SSH_LOCATION):$(CELLAR_ARTWORK)" "$@"
@printf "%b %s\n" "$(GREEN)[ ✓ ]$(END) Download" "$(notdir $@)"
out/%.flac: data/tracks/%.track data/metadata.csv data/artwork.png
@printf "%b %s\n" "$(CYAN)[ > ]$(END) Encode" "$(notdir $@)"
@mamba run -n Instrumental_Music_Collection python src/encode.py \
@python src/encode.py \
-t $< \
-id $(basename $(notdir $@)) \
-m data/metadata.csv \
-a data/artwork \
-a data/artwork.png \
-o $@
@printf "%b %s\n" "$(GREEN)[ ✓ ]$(END) Encode" "$(notdir $@)"
install: $(FLAC_FILES)
@printf "%b %s\n" "$(CYAN)[ > ]$(END) Copy files to target directory"
@python src/install.py \
-td out/ \
-m data/metadata.csv \
-d "$(INSTALL_DIR)"
@printf "%b %s\n" "$(GREEN)[ ✓ ]$(END) Copy files to target directory"
# ---- Cleanup -----------------------------------------------------------------
clean:
@printf "%b %s\n" "$(CYAN)[ > ]$(END) Clean working directories"
@rm -rf out/
@rm -rf data/
@printf "%b %s\n" "$(GREEN)[ ✓ ]$(END) Clean working directories"