18 lines
503 B
Bash
Executable File
18 lines
503 B
Bash
Executable File
#!/bin/bash
|
|
|
|
[[ ! $1 ]] && echo "Please give a playlist ID" && exit 1
|
|
playlist_id="$1"
|
|
|
|
sp_token=$(./lib/get_token.sh)
|
|
json=$(curl -s https://api.spotify.com/v1/playlists/$playlist_id?access_token=$sp_token)
|
|
name=$(echo "$json" | jq -r .name)
|
|
links=$(echo "$json" | jq -r .tracks.items[].track.external_urls.spotify)
|
|
|
|
mapfile -t links <<< "$links"
|
|
for link in "${links[@]}"; do
|
|
links_format+="\"$link\","
|
|
done
|
|
links_format=${links_format::-1}
|
|
|
|
echo "{\"name\": \"$name\", \"tracks\": [$links_format]}"
|