2021-01-22 14:46:18 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -euo pipefail
|
|
|
|
|
2021-01-22 15:12:38 +01:00
|
|
|
# remove content of music directory
|
|
|
|
rm -rf "$HOME/Musik/"*
|
|
|
|
|
2021-01-22 14:46:18 +01:00
|
|
|
# change into music raw folder
|
2024-06-23 11:37:41 +02:00
|
|
|
pushd "$HOME/Nextcloud/MusikRaw"
|
2021-01-22 14:46:18 +01:00
|
|
|
|
2024-06-23 11:37:41 +02:00
|
|
|
# disable expansion of empty globs
|
|
|
|
shopt -s nullglob
|
2021-02-12 14:30:17 +01:00
|
|
|
|
2024-06-23 11:37:41 +02:00
|
|
|
for artdir in */; do
|
2024-01-27 21:42:10 +01:00
|
|
|
# FIXME remove trailing slash
|
|
|
|
artdir="${artdir%/}"
|
|
|
|
# change into artist directory
|
2024-06-23 12:03:06 +02:00
|
|
|
pushd "$artdir"
|
2024-06-23 11:37:41 +02:00
|
|
|
|
|
|
|
for dir in */; do
|
2024-01-27 21:42:10 +01:00
|
|
|
# FIXME remove trailing slash
|
|
|
|
dir="${dir%/}"
|
2021-02-12 14:30:17 +01:00
|
|
|
# change into directory
|
2024-06-23 11:37:41 +02:00
|
|
|
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/"
|
|
|
|
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
|
|
|
|
done
|
2024-06-23 12:03:06 +02:00
|
|
|
popd
|
2024-06-23 11:37:41 +02:00
|
|
|
done
|
2024-06-23 12:03:06 +02:00
|
|
|
popd
|
2024-06-23 11:37:41 +02:00
|
|
|
done
|
|
|
|
popd
|
2021-01-22 14:46:18 +01:00
|
|
|
|
|
|
|
echo Finished!
|
|
|
|
|
|
|
|
exit
|