Compare commits
3 commits
354b0fbda2
...
b900166ae7
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b900166ae7 | ||
|
|
5dc924f6b3 | ||
|
|
86ecc7278d |
1 changed files with 39 additions and 32 deletions
|
|
@ -1,41 +1,48 @@
|
|||
#!/usr/bin/bash
|
||||
#!/bin/bash
|
||||
|
||||
# This script helped me download back my own albums from deab.bandcamp.com
|
||||
# This script helps 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
|
||||
# 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;
|
||||
for d in "/mnt/user/downloads/youtube-dl/audio/*/";
|
||||
do
|
||||
# collects metadata from json file
|
||||
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 '"');
|
||||
year=$(jq ".release_year" "${f%.*}.info.json" | tr -d '"');
|
||||
cover="${f%.*}.jpg";
|
||||
echo "Processing " "$d"
|
||||
echo "..."
|
||||
|
||||
# updates the ID3 tags on the mp3 file
|
||||
eyeD3 --title "$track" \
|
||||
--track "$track_number" \
|
||||
--track-total "$n_entries" \
|
||||
--artist "$artist" \
|
||||
--album "$album" \
|
||||
--release-year "$year" \
|
||||
--add-image "$cover":FRONT_COVER: \
|
||||
"$f"
|
||||
files="$d*.mp3"
|
||||
|
||||
# moves the files to a correct name into an artist/album/ folder
|
||||
new_name=$(printf '%02d - %s.mp3' "$track_number" "$track")
|
||||
mkdir -p "$artist"
|
||||
mkdir -p "$artist/$album"
|
||||
mv "$f" "$artist/$album/$new_name"
|
||||
for f in $files;
|
||||
do
|
||||
# collects metadata from json file
|
||||
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 '"');
|
||||
year=$(jq ".release_year" "${f%.*}.info.json" | tr -d '"');
|
||||
cover="${f%.*}.jpg";
|
||||
|
||||
# updates the ID3 tags on the mp3 file
|
||||
eyeD3 --title "$track" \
|
||||
--track "$track_number" \
|
||||
--track-total "$n_entries" \
|
||||
--artist "$artist" \
|
||||
--album "$album" \
|
||||
--release-year "$year" \
|
||||
--add-image "$cover":FRONT_COVER: \
|
||||
"$f";
|
||||
|
||||
# moves the files into an path/to/music/folder/artist/album/
|
||||
new_name=$(printf '%02d - %s.mp3' "$track_number" "$track");
|
||||
mkdir -p "/mnt/user/music/nettoyage/youtubedl/$artist";
|
||||
mkdir -p "/mnt/user/music/nettoyage/youtubedl/$artist/$album";
|
||||
mv "$f" "/mnt/user/music/nettoyage/youtubedl/$artist/$album/$new_name";
|
||||
done
|
||||
|
||||
# removes the original folder
|
||||
rm -R "$d"
|
||||
|
||||
echo "Done with" "$d"
|
||||
echo "---"
|
||||
done
|
||||
|
||||
# removes the original folder asking confirmation
|
||||
rm -R "$1"
|
||||
|
|
|
|||
Loading…
Reference in a new issue