Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
Oh My Zsh
Commits
b8085556
Commit
b8085556
authored
Aug 31, 2016
by
mahi97
Browse files
add search option for playlist
parent
3b2f827d
Changes
1
Show whitespace changes
Inline
Side-by-side
plugins/osx/osx.plugin.zsh
View file @
b8085556
...
...
@@ -350,6 +350,29 @@ function spotify() {
}
case
$2
in
"list"
)
_args
=
${
array
[*]
:2:
$len
}
;
Q
=
$_args
;
cecho
"Searching playlists for:
$Q
"
;
results
=
$(
\
curl
-s
-G
$SPOTIFY_SEARCH_API
--data-urlencode
"q=
$Q
"
-d
"type=playlist&limit=10&offset=0"
-H
"Accept: application/json"
\
|
grep
-E
-o
"spotify:user:[a-zA-Z0-9_]+:playlist:[a-zA-Z0-9]+"
-m
10
\
)
count
=
$(
\
echo
"
$results
"
|
grep
-c
"spotify:user"
\
)
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}'
\
)
fi
;;
"album"
|
"artist"
|
"track"
)
_args
=
${
array
[*]
:2:
$len
}
;
searchAndPlay
"
$2
"
"
$_args
"
;;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment