Handle new Source directories

This commit is contained in:
exu 2024-06-23 11:37:41 +02:00
parent 15d2ddf921
commit 7fec07f6c4

View File

@ -5,26 +5,52 @@ set -euo pipefail
rm -rf "$HOME/Musik/"*
# change into music raw folder
cd "$HOME/Nextcloud/MusikRaw"
pushd "$HOME/Nextcloud/MusikRaw"
# get directories
ls -d */ > artistdirectories
# disable expansion of empty globs
shopt -s nullglob
while read -r artdir; do
for artdir in */; do
# FIXME remove trailing slash
artdir="${artdir%/}"
# change into artist directory
cd "$artdir"
# get albums
ls -d */ > directories
while read -r dir; do
for dir in */; do
# FIXME remove trailing slash
dir="${dir%/}"
# change into directory
cd "$dir"
pushd "$dir"
for subdir in */; do
if [ "$subdir" != "normalized/" ]; then
# NOTE handle new paths with streaming services included
# FIXME remove trailing slash
subdir="${subdir%/}"
# go into subdirectory
pushd "$subdir"
# create directory in music
mkdir -p "$HOME/Musik/${artdir}/$subdir"
# link cover image (jpg or png)
if [ -f cover.jpg ]; then
ln -vf "$HOME/Nextcloud/MusikRaw/${artdir}/$dir/$subdir/cover.jpg" "$HOME/Musik/${artdir}/$subdir/"
elif [ -f cover.png ]; then
ln -vf "$HOME/Nextcloud/MusikRaw/${artdir}/$dir/$subdir/cover.png" "$HOME/Musik/${artdir}/$subdir/"
fi
# make symbolic link to music
# if the "normalized" directory exists, links are created
if [ -d "normalized" ]; then
ln -svf "$HOME/Nextcloud/MusikRaw/${artdir}/$dir/$subdir/normalized/"* "$HOME/Musik/${artdir}/$subdir/"
fi
popd
else
# NOTE this stays the same, without streaming services included
# create directory in music
mkdir -p "$HOME/Musik/${artdir}/$dir"
# link cover image (jpg or png)
if [ -f cover.jpg ]; then
ln -vf "$HOME/Nextcloud/MusikRaw/${artdir}/$dir/cover.jpg" "$HOME/Musik/${artdir}/$dir/"
@ -37,16 +63,18 @@ while read -r artdir; do
if [ -d "normalized" ]; then
ln -svf "$HOME/Nextcloud/MusikRaw/${artdir}/$dir/normalized/"* "$HOME/Musik/${artdir}/$dir/"
fi
fi
popd
done
# go back to music raw
cd "$HOME/Nextcloud/MusikRaw/$artdir"
done < directories
# cleanup
rm directories
done
cd "$HOME/Nextcloud/MusikRaw"
done < artistdirectories
# cleanup
rm artistdirectories
done
popd
echo Finished!