From 8109d0ab759287dec0dfb06e378e4fb8695e0a0e Mon Sep 17 00:00:00 2001 From: Hari Sekhon Date: Fri, 26 Jun 2020 13:15:07 +0100 Subject: [PATCH] updated spotify_backup_playlists.sh --- spotify_backup_playlists.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/spotify_backup_playlists.sh b/spotify_backup_playlists.sh index df911925..11beb33f 100755 --- a/spotify_backup_playlists.sh +++ b/spotify_backup_playlists.sh @@ -28,9 +28,7 @@ Backs up all public spotify playlists for a given user to text files contains Sp Requires \$SPOTIFY_USER be set in the environment or else given as the second arg -Requires \$SPOTIFY_ACCESS_TOKEN in the environment (can generate from spotify_api_token.sh) or will auto generate from \$SPOTIFY_CLIENT_ID and \$SPOTIFY_CLIENT_SECRET if found in the environment - -export SPOTIFY_ACCESS_TOKEN=\"\$('$srcdir/spotify_api_token.sh')\" +Requires \$SPOTIFY_CLIENT_ID and \$SPOTIFY_CLIENT_SECRET to be defined in the environment " # shellcheck disable=SC1090 @@ -52,6 +50,10 @@ timestamp "Backing up Spotify playlists to $backup_dir" echo >&2 mkdir -vp "$backup_dir" +if [ -z "${SPOTIFY_ACCESS_TOKEN:-}" ]; then + export SPOTIFY_ACCESS_TOKEN="$("$srcdir/spotify_api_token.sh")" +fi + "$srcdir"/spotify_foreach_playlist.sh "./spotify_playlist_tracks_uri.sh '{playlist_id}' > '$backup_dir'/\"\$(tr -d / <<< \"{playlist}.txt\")\" $*" "$spotify_user" "$@" echo >&2 timestamp "Backups finished in $SECONDS seconds"