adapts to the unraid env

This commit is contained in:
diegantobass 2025-06-24 09:07:06 +02:00
parent 86ecc7278d
commit 5dc924f6b3

View file

@ -1,13 +1,14 @@
#!/usr/bin/bash #!/usr/bin/bash
# This script helped me download back my own albums from deab.bandcamp.com # This script helped me download back my own albums from deab.bandcamp.com from my unraid server
# #
# It takes the first positional argument : a folder with youtube-dl downloaded audio-only tracks from bandcamp with their associated pictures and json metadata # 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 # 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
files="$1*.mp3" for d in /mnt/user/downloads/youtube-dl/audio/*/;
do
for f in $files; echo "Processing " "$d"
for f in $files;
do do
# collects metadata from json file # collects metadata from json file
track=$(jq ".track" "${f%.*}.info.json" | tr -d '"'); track=$(jq ".track" "${f%.*}.info.json" | tr -d '"');
@ -18,22 +19,25 @@ for f in $files;
year=$(jq ".release_year" "${f%.*}.info.json" | tr -d '"'); year=$(jq ".release_year" "${f%.*}.info.json" | tr -d '"');
cover="${f%.*}.jpg"; cover="${f%.*}.jpg";
echo "$track" "$artist"
# updates the ID3 tags on the mp3 file # updates the ID3 tags on the mp3 file
eyeD3 --title "$track" \ # eyeD3 --title "$track" \
--track "$track_number" \ # --track "$track_number" \
--track-total "$n_entries" \ # --track-total "$n_entries" \
--artist "$artist" \ # --artist "$artist" \
--album "$album" \ # --album "$album" \
--release-year "$year" \ # --release-year "$year" \
--add-image "$cover":FRONT_COVER: \ # --add-image "$cover":FRONT_COVER: \
"$f" # "$f";
# moves the files to a correct name into an artist/album/ folder # moves the files to a correct name into an artist/album/ folder
new_name=$(printf '%02d - %s.mp3' "$track_number" "$track") new_name=$(printf '%02d - %s.mp3' "$track_number" "$track");
mkdir -p "$artist" mkdir -p "$artist";
mkdir -p "$artist/$album" mkdir -p "$artist/$album";
mv "$f" "$artist/$album/$new_name" # mv "$f" "$artist/$album/$new_name";
echo "$new_name"
done
# removes the original folder
# rm -R "$d"
done done
# removes the original folder asking confirmation
rm -R "$1"