Search code examples
c#gracenote

Setting detail levels in the C# wrapper for the Gracenote Web API


I am currently working with the Gracenote Web API using the C# wrapper made by Park Square and I don't know how to set the detail levels.

Currently the Search() method only returns one level of detail for genre, mood, tempo etc. but I would like to get as much detail as possible.

Currently my code looks like this:

var gnRes = gnClient.Search(new SearchCriteria {
    AlbumTitle = albumName,
    Artist = artistName,
    TrackTitle = trackTitle,
    SearchMode = SearchMode.BestMatchWithCoverArt,
    SearchOptions = SearchOptions.Mood | SearchOptions.Tempo | SearchOptions.ArtistOriginEraType
});

I have discovered that the SearchCriteria object has a ResponseDetail class indicating that it is indeed possible to set the detail level but I don't know how to use it correctly. The doumentation posted for the wrapper doesn't mention it.


Solution

  • I found out how to do this and get the type of response I want.

            SearchCriteria searchCriteria = new SearchCriteria();
            ResponseDetail detail = new ResponseDetail();
    
            detail.GenreLevels = ResponseDetail.Level.Three;
            detail.MoodLevels = ResponseDetail.Level.Two;
            detail.TempoLevels = ResponseDetail.Level.Three;
            detail.ArtistEraLevels = ResponseDetail.Level.Two;
            detail.ArtistOriginLevels = ResponseDetail.Level.Four;
            detail.ArtistTypeLevels = ResponseDetail.Level.Two;
    
            searchCriteria.AlbumTitle = albumTitle;
            searchCriteria.Artist = artistName;
            searchCriteria.TrackTitle = trackTitle;
    
            searchCriteria.SearchMode = SearchMode.BestMatch;
            searchCriteria.SearchOptions = SearchOptions.Mood | SearchOptions.Tempo | SearchOptions.ArtistOriginEraType;
            searchCriteria.ResponseDetail = detail;
    
            SearchResult gnRes = gnClient.Search(searchCriteria);