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