From c44911e6a4566b33c2a9d666273418d4d42e2e44 Mon Sep 17 00:00:00 2001 From: diegantobass Date: Mon, 23 Jun 2025 22:23:52 +0200 Subject: [PATCH] ITS ALL DONE --- .gitignore | 1 + bandcamp_format_utility.sh | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 .gitignore create mode 100755 bandcamp_format_utility.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9a1a6a2 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +test_files/ diff --git a/bandcamp_format_utility.sh b/bandcamp_format_utility.sh new file mode 100755 index 0000000..0fcd999 --- /dev/null +++ b/bandcamp_format_utility.sh @@ -0,0 +1,25 @@ +#!/usr/bin/bash + +# This script helped me download back my own albums from deab.bandcamp.com +# It takes the first positional argument : a folder with youtube-dl downloaded audio only tracks from bandcamp with their associated pictures and json metadata +# And it parses the json to extract track name and number, album name, cover and number of tracks, and uses eyeD3 to updates the ID3 tags, rename and move the files +# +# WATCHOUT for bash version because the -v (to variable) option in printf is a newish thing at the time of writing... + +files="$1*.mp3" + +for f in $files; + do + track=$(jq ".track" "${f%.*}.info.json" | tr -d '"'); + track_number=$(jq ".track_number" "${f%.*}.info.json" | tr -d '"'); + n_entries=$(jq ".n_entries" "${f%.*}.info.json" | tr -d '"'); + artist=$(jq ".artist" "${f%.*}.info.json" | tr -d '"'); + album=$(jq ".album" "${f%.*}.info.json" | tr -d '"'); + cover="${f%.*}.jpg"; + + eyeD3 -N "$n_entries" -n "$track_number" --title "$track" --album "$album" --artist "$artist" --add-image "$cover":FRONT_COVER: "$f" + printf -v file_name '%02d - %s.mp3' "$track_number" "$track" + mkdir -p "$artist" + mkdir -p "$artist/$album" + mv "$f" "$artist/$album/$file_name" + done