Question

I'm trying to use the Spotify objective-c library to search for a specific song that belongs to an artist, album. I don't want to use the searchWithSearchQuery method (which works ok) because I want to be more specific. There is a method called searchWithURL shown below. I don't see any documentation as to how to structure these URLs. All it says is that it must start with spotify:search. What comes after that? How do I specify a artist, album, song? Thanks!

/** Creates a new SPSearch with the default page size from the given Spotify search URL. 

 This convenience method is simply returns a new, autoreleased SPSearch
 object. No caching is performed.

 @warning If you pass in an invalid search URL (i.e., any URL not
 starting `spotify:search:`, this method will return `nil`.

 @warning The search query will be sent to the Spotify search service
 immediately. Be sure you want to perform the search before creating the object!

 @param searchURL The search URL to create an SPSearch for.
 @param aSession The SPSession the track should exist in.
 @return Returns the created SPSearch object. 
 */
+(SPSearch *)searchWithURL:(NSURL *)searchURL inSession:(SPSession *)aSession;
Was it helpful?

Solution

Search URLs are created by SPSearch instances after you create them, and they basically encode the query you passed the first time. So, searchWithURL: isn't going to be more useful to you than creating a search with a query.

However, to answer your wider question, you can use the Spotify Advanced Search Syntax with SPSearch to do a more accurate search.

For example, to find tracks exactly named "Roar":

[SPSearch searchWithSearchQuery:@"track:Roar"
                      inSession:[SPSession sharedSession]];

To find tracks exactly named "Roar" by Katy Perry:

[SPSearch searchWithSearchQuery:@"track:Roar artist:\"Katy Perry\""
                      inSession:[SPSession sharedSession]]; 

...and so on. Check out the linked page for more details.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top