From b3bb6cf150a33e46987b247847a84574efe72c04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20La=C3=ADn?= Date: Sun, 12 May 2024 18:59:29 +0200 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor(script):=20downlo?= =?UTF-8?q?adSpotify=20filters=20subdirectories=20as=20well=20as=20base=20?= =?UTF-8?q?folders?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .local/bin/downloadSpotify | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.local/bin/downloadSpotify b/.local/bin/downloadSpotify index ec695908..44e00962 100755 --- a/.local/bin/downloadSpotify +++ b/.local/bin/downloadSpotify @@ -13,15 +13,13 @@ MUSIC_FOLDER="$HOME/Musica/Listen-To" notify "Started syncing..." -while IFS= read -r -d '' FOLDER; do - FOLDER_NAME=$(basename "$FOLDER") - - SPOTDL_FILE=$(find "$FOLDER" -maxdepth 1 -type f -name '*.spotdl' -print -quit) - if [ -n "$SPOTDL_FILE" ]; then +while IFS= read -r -d '' SPOTDL_FILE; do + if [[ -f "$SPOTDL_FILE" && "$SPOTDL_FILE" == *.spotdl ]]; then + FOLDER_NAME=$(basename "$(dirname "$SPOTDL_FILE")") 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) +done < <(find "$MUSIC_FOLDER" -mindepth 1 -maxdepth 3 -type f -name '*.spotdl' -print0) notify "Spotdl Sync Complete"