public SimpleAlbum(Client client, string id) { client.Depth = 4; id = client.GetID(id); if(!client.Query(Rdf.MBQ_GetAlbumById, id) || !client.Select(Rdf.MBS_SelectAlbum, 1)) { throw new ApplicationException("Could not fetch album with ID: " + id); } this.id = client.GetID(client.GetResultData(Rdf.MBE_AlbumGetAlbumId)); asin = client.GetResultData(Rdf.MBE_AlbumGetAmazonAsin); cover_art_url = client.GetResultData(Rdf.MBE_AlbumGetAmazonCoverartURL); string artist_name = client.GetResultData(Rdf.MBE_AlbumGetArtistName); Console.WriteLine(artist_name); title = client.GetResultData(Rdf.MBE_AlbumGetAlbumName); int track_count = client.GetResultInt(Rdf.MBE_AlbumGetNumTracks, 1); if(track_count <= 0) { throw new ApplicationException("Invalid track count from album query"); } tracks = new SimpleTrack[track_count]; for(int i = 1; i <= tracks.Length; i++) { client.Select(Rdf.MBS_SelectTrack, i); tracks[i - 1] = new SimpleTrack(i, 0); tracks[i - 1].Artist = client.GetResultData(Rdf.MBE_TrackGetArtistName); tracks[i - 1].Title = client.GetResultData(Rdf.MBE_TrackGetTrackName); int length = client.GetResultInt(Rdf.MBE_TrackGetTrackDuration); tracks[i - 1].Length = length / 1000; client.Select(Rdf.MBS_Back); } if(client.GetResultInt(Rdf.MBE_AlbumGetNumReleaseDates) > 0) { client.Select(Rdf.MBS_SelectReleaseDate, 1); release_date = Utilities.StringToDateTime( client.GetResultData(Rdf.MBE_ReleaseGetDate)); client.Select(Rdf.MBS_Back); } client.Select(Rdf.MBS_Back); }