Search Chains
Note
This is a made up term, I just picked it because I wrote the search functions so they can be chained in a pretty way.
Info
Result := Spotify.Search.For(TYPES).By(KEYWORD [, CRITERIA])
is the basic structure of these searches, and the chained search functions like above return a Spotify.Search.SearchResult object.
The .For() function takes a list of types to return, stores them in an object, sets the key By on the object to Spotify.Search._By, and returns the object
This allows for us to chain .For().By() in a nice way, which is also why I call this a chain.
It also reminds me of jQuery's return this thing, which I like much more than I like jQuery.
.By() takes a plain query as text for the first parameter, and optional pairs of query criteria keys/values as the second.
Examples
This example will search for the track Homebound by DROELOE and play the first found track result
Result := Spotify.Search.For("tracks").By("Homebound", {"artist": "DROELOE"})
Result.Tracks[1].Play()
The criteria {"artist": "DROELOE"} limits the search to where
Artist.Name ~= "DROELOE", and "Homebound" limits the search to results Anything.Name ~= "Homebound"
An important thing to remember is that you will only get results of the types you specify, so if you don't get any search results for some query, make sure you are searching for the right types
Another example:
Result := Spotify.Search.For("tracks", "albums", "playlists").By("Gamer")
MsgBox, % Result.Tracks[1].Name "`n" Result.Albums[1].Name "`n" Result.Playlists[1].Name
To pass a limit/offset for the search, pass it as a standard criteria, like:
Result := Spotify.Search.For("tracks", "albums", "playlists").By("Gamer", {"limit": 10, "offset": 5})
To include a NOT in your search, pass it like
Result := Spotify.Search.For("tracks", "albums", "playlists").By("Gamer", {"artist": " NOT Whoever"})