Skip to content

Commit

Permalink
Merge pull request #116 from dmofot/playlist_fix
Browse files Browse the repository at this point in the history
Fix play list functionality
  • Loading branch information
hnarayanan authored Apr 26, 2019
2 parents 8802098 + cde49f9 commit 3708735
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions spotify
Original file line number Diff line number Diff line change
Expand Up @@ -234,18 +234,18 @@ while [ $# -gt 0 ]; do

results=$( \
curl -s -G $SPOTIFY_SEARCH_API --data-urlencode "q=$Q" -d "type=playlist&limit=10&offset=0" -H "Accept: application/json" -H "Authorization: Bearer ${SPOTIFY_ACCESS_TOKEN}" \
| grep -E -o "spotify:user:[a-zA-Z0-9_]+:playlist:[a-zA-Z0-9]+" -m 10 \
| grep -E -o "spotify:playlist:[a-zA-Z0-9]+" -m 10 \
)

count=$( \
echo "$results" | grep -c "spotify:user" \
echo "$results" | grep -c "spotify:playlist" \
)

if [ "$count" -gt 0 ]; then
random=$(( $RANDOM % $count));

SPOTIFY_PLAY_URI=$( \
echo "$results" | awk -v random="$random" '/spotify:user:[a-zA-Z0-9]+:playlist:[a-zA-Z0-9]+/{i++}i==random{print; exit}' \
echo "$results" | awk -v random="$random" '/spotify:playlist:[a-zA-Z0-9]+/{i++}i==random{print; exit}' \
)
fi;;

Expand Down

0 comments on commit 3708735

Please sign in to comment.