updated spotify_playlist_tracks_uri.sh

pull/2/head
Hari Sekhon 4 years ago
parent 897f3d7e64
commit 007634f356

@ -70,17 +70,25 @@ url_path="/v1/playlists/$playlist_id/tracks?limit=$limit&offset=$offset"
output(){
#jq -r '.' <<< "$output"
jq -r '.items[] | [.track.uri] | @tsv' <<< "$output"
jq -r '.items[] | select(.track.uri) | [.track.uri] | @tsv' <<< "$output"
}
get_next(){
jq -r '.next' <<< "$output"
}
while [ -n "$url_path" ] && [ "$url_path" != null ]; do
output="$("$srcdir/spotify_api.sh" "$url_path" "$@")"
has_next_url(){
[ -n "$url_path" ] && [ "$url_path" != null ]
}
has_jq_error(){
# shellcheck disable=SC2181
if [ $? != 0 ] || [ "$(jq -r '.error' <<< "$output")" != null ]; then
[ $? != 0 ] || [ "$(jq -r '.error' <<< "$output")" != null ]
}
while has_next_url; do
output="$("$srcdir/spotify_api.sh" "$url_path" "$@")"
if has_jq_error; then
echo "$output" >&2
exit 1
fi

Loading…
Cancel
Save