/// <summary> /// Get a list of Album Release Groups for a given artist. /// </summary> /// <param name="artistId">The artist Id to search for</param> /// <returns>ReleaseGroupWrapper object which contains a list of Release Groups</returns> public async Task <ReleaseGroupsWrapper> GetAlbumReleaseGroups(string artistId) { ReleaseGroupsWrapper releaseGroup = null; string endpoint = String.Format("artist/{0}?inc=release-groups&type=album", artistId); string responseData = await _clientManager.GetJsonResponse(endpoint); if (responseData != null) { releaseGroup = JsonConvert.DeserializeObject <ReleaseGroupsWrapper>(responseData); } return(releaseGroup); }
/// <summary> /// Go through the discovery procedure of a new artist. /// </summary> /// <param name="artistName">The name of the artist to discover</param> /// <returns></returns> public static async Task <Artist> Discover(string artistName) { Artist artist = null; MusicBrainzManager musicBrainzManager = new MusicBrainzManager(); LyricApiManager lyricApiManager = new LyricApiManager(); // get the artist ID and check that it is not null. string artistId = await musicBrainzManager.GetArtistId(artistName); if (artistId != null) { ReleaseGroupsWrapper rgw = await musicBrainzManager.GetAlbumReleaseGroups(artistId); // some variables to give the user some feedback. int progress = 0; int total = rgw.ReleaseGroups.Count; // go through all release group objects foreach (ReleaseGroup rg in rgw.ReleaseGroups) { progress++; // for a release group find the UK or US version. Release release = await musicBrainzManager.GetGBUSVersion(rg.Id); // if we have a UK or US version if (release != null) { WriteInformation(String.Format("Album {0}/{1}...", progress, total)); WriteInformation(String.Format("Artist {0} has Album {1}", artistName, rg.Title)); // Get all tracks for the release List <Track> tracks = await musicBrainzManager.FindTracksOnRelease(release.Id); foreach (Track track in tracks) { track.Lyrics = await lyricApiManager.GetSongLyrics(artistName, track.Title); WriteInformation(String.Format("\t Track {0} with {1} Words", track.Title, StringHelper.WordCount(track.Lyrics))); } // Create the Artist object artist = new Artist() { Name = artistName }; artist.Albums.Add(new Album(rg.Title, tracks)); } else { WriteInformation(String.Format("Artist {0} Album {1} does not have a UK or US Version", artistName, rg.Title)); } } } if (artist != null) { StatisticManager manager = new StatisticManager(artist); double average = manager.CalculateAverageNumberOfWordsInSong(); double standardDev = manager.CalculateStandardDeviation(); WriteResult(String.Format("Average Number of words = {0}\nStandard Deviation = {1}", average, standardDev)); } WriteResult("*********************************DONE*********************************"); return(artist); }
public async Task TestGetReleaseGroups(string artistId) { ReleaseGroupsWrapper releaseGroupWrapper = await _clientManager.GetAlbumReleaseGroups(artistId); Assert.NotNull(releaseGroupWrapper); }