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/"* 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"
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 # create directory in music
mkdir -p "$HOME/Musik/${artdir}/$dir" mkdir -p "$HOME/Musik/${artdir}/$dir"
# link cover image (jpg or png) # link cover image (jpg or png)
if [ -f cover.jpg ]; then if [ -f cover.jpg ]; then
ln -vf "$HOME/Nextcloud/MusikRaw/${artdir}/$dir/cover.jpg" "$HOME/Musik/${artdir}/$dir/" 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 if [ -d "normalized" ]; then
ln -svf "$HOME/Nextcloud/MusikRaw/${artdir}/$dir/normalized/"* "$HOME/Musik/${artdir}/$dir/" ln -svf "$HOME/Nextcloud/MusikRaw/${artdir}/$dir/normalized/"* "$HOME/Musik/${artdir}/$dir/"
fi 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!