♻️ refactor(scripts): avoid harcoding values in downloadSpotify

This commit is contained in:
Sergio Laín 2024-05-12 18:00:20 +02:00
parent b6cff14661
commit 7b92d12d42
No known key found for this signature in database
GPG key ID: FB00AF7015FFE76B

View file

@ -9,23 +9,19 @@ if ! command -v spotdl &>/dev/null; then
exit 1
fi
FOLDERS=(
"EDM-House"
"Metal-Rock"
"Synth-Chill"
"Lofi-Sleppy"
"Space-Cyberpunk"
"Cyberpunk-Darksynth"
)
MUSIC_FOLDER="$HOME/Musica/Listen-To"
notify "Started syncing..."
for FOLDER in "${FOLDERS[@]}"; do
cd "$HOME/Musica/Listen-To/$FOLDER" || continue
while IFS= read -r -d '' FOLDER; do
FOLDER_NAME=$(basename "$FOLDER")
spotdl sync "${FOLDER,,}.spotdl"
notify "$FOLDER synced"
done
SPOTDL_FILE=$(find "$FOLDER" -maxdepth 1 -type f -name '*.spotdl' -print -quit)
if [ -n "$SPOTDL_FILE" ]; then
cd "$(dirname "$SPOTDL_FILE")" || continue
spotdl sync "$(basename "$SPOTDL_FILE")"
notify "Synced $FOLDER_NAME"
fi
done < <(find "$MUSIC_FOLDER" -mindepth 1 -maxdepth 1 -type d -print0)
notify "Spotdl Sync Complete"