Search subsysten


Typedefs

typedef void search_complete_cb (sp_search *result, void *userdata)

Functions

sp_searchsp_search_create (sp_session *session, const char *query, int offset, int count, search_complete_cb *callback, void *userdata)
bool sp_search_is_loaded (sp_search *search)
sp_error sp_search_error (sp_search *search)
int sp_search_num_tracks (sp_search *search)
sp_tracksp_search_track (sp_search *search, int index)
int sp_search_num_albums (sp_search *search)
sp_albumsp_search_album (sp_search *search, int index)
int sp_search_num_artists (sp_search *search)
sp_artistsp_search_artist (sp_search *search, int index)
const char * sp_search_query (sp_search *search)
const char * sp_search_did_you_mean (sp_search *search)
int sp_search_total_tracks (sp_search *search)
void sp_search_add_ref (sp_search *search)
void sp_search_release (sp_search *search)

Typedef Documentation

typedef void search_complete_cb(sp_search *result, void *userdata)

The type of a callback used in sp_search_create()

When this callback is called, the sp_track_is_loaded(), sp_album_is_loaded(), and sp_artist_is_loaded() functions will return non-zero for the objects contained in the search result.

Parameters:
[in] result The same pointer returned by sp_search_create()
[in] userdata The opaque pointer given to sp_search_create()


Function Documentation

void sp_search_add_ref ( sp_search search  ) 

Increase the reference count of a search result

Parameters:
[in] search The search result object

sp_album* sp_search_album ( sp_search search,
int  index 
)

Return the album at the given index in the given search object

Parameters:
[in] search Search object
[in] index Index of the wanted album. Should be in the interval [0, sp_search_num_albums() - 1]
Returns:
The album at the given index in the given search object
Examples:
search.c.

sp_artist* sp_search_artist ( sp_search search,
int  index 
)

Return the artist at the given index in the given search object

Parameters:
[in] search Search object
[in] index Index of the wanted artist. Should be in the interval [0, sp_search_num_artists() - 1]
Returns:
The artist at the given index in the given search object
Examples:
search.c.

sp_search* sp_search_create ( sp_session session,
const char *  query,
int  offset,
int  count,
search_complete_cb callback,
void *  userdata 
)

Create a search object from the given query

Here is a snippet from search.c:

    g_search = sp_search_create(session, "year:2003 never", 0, 10,
                                &search_complete, NULL);

    if (!g_search) {
        fprintf(stderr, "failed to start search\n");
        g_exit_code = 6;
        return;
    }

Parameters:
[in] session Session
[in] query Query search string, e.g. 'The Rolling Stones' or 'album:"The Black Album"'
[in] offset The offset in the total number of results available
[in] count The number of results to ask for
[in] callback Callback that will be called once the search operation is complete. Pass NULL if you are not interested in this event.
[in] userdata Opaque pointer passed to callback
Returns:
Pointer to a search object. To free the object, use sp_search_release()
Examples:
search.c.

const char* sp_search_did_you_mean ( sp_search search  ) 

Return the "Did you mean" query for the given search object

Parameters:
[in] search Search object
Returns:
The "Did you mean" query for the given search object, or the empty string if no such info is available
Examples:
search.c.

sp_error sp_search_error ( sp_search search  ) 

Check if search returned an error code.

Parameters:
[in] search Search object
Returns:
Error code
Examples:
search.c.

bool sp_search_is_loaded ( sp_search search  ) 

Get load status for the specified search. Before it is loaded, it will behave as an empty search result.

Parameters:
[in] search Search object
Returns:
True if search is loaded, otherwise false

int sp_search_num_albums ( sp_search search  ) 

Get the number of albums for the specified search

Parameters:
[in] search Search object
Returns:
The number of albums for the specified search
Examples:
search.c.

int sp_search_num_artists ( sp_search search  ) 

Get the number of artists for the specified search

Parameters:
[in] search Search object
Returns:
The number of artists for the specified search
Examples:
search.c.

int sp_search_num_tracks ( sp_search search  ) 

Get the number of tracks for the specified search

Parameters:
[in] search Search object
Returns:
The number of tracks for the specified search
Examples:
search.c.

const char* sp_search_query ( sp_search search  ) 

Return the search query for the given search object

Parameters:
[in] search Search object
Returns:
The search query for the given search object
Examples:
search.c.

void sp_search_release ( sp_search search  ) 

Decrease the reference count of a search result

Parameters:
[in] search The search result object
Examples:
search.c.

int sp_search_total_tracks ( sp_search search  ) 

Return the total number of tracks for the search query - regardless of the interval requested at creation. If this value is larger than the interval specified at creation of the search object, more search results are available. To fetch these, create a new search object with a new interval.

Parameters:
[in] search Search object
Returns:
The total number of tracks matching the original query
Examples:
search.c.

sp_track* sp_search_track ( sp_search search,
int  index 
)

Return the track at the given index in the given search object

Parameters:
[in] search Search object
[in] index Index of the wanted track. Should be in the interval [0, sp_search_num_tracks() - 1]
Returns:
The track at the given index in the given search object
Examples:
search.c.


Generated on Tue Apr 7 15:21:55 2009.
Copyright © 2006–2009 Spotify Ltd