private AlbumIdentification ParseCdStub(ApiRespose response)
        {
            var stub = JObject.Parse(response.Json);

            var tag = new AlbumIdentification
            {
                Id             = (string)stub["id"],
                AlbumTitle     = (string)stub["title"],
                AlbumArtist    = (string)stub["artist"],
                NumberOfTracks = (int?)stub["track-count"] ?? stub["tracks"].Count(),
            };

            for (int index = 0; index < stub["tracks"].Count(); index++)
            {
                var t = stub["tracks"][index];
                tag.AddTrack(new TrackIdentification()
                {
                    Artist      = (string)t["artist"],
                    Title       = (string)t["title"],
                    TrackNumber = index + 1
                });
            }

            return(tag);
        }
        private Uri ParseAlbumArt(ApiRespose response)
        {
            var art      = JObject.Parse(response.Json);
            var imageUrl = (from image in art["images"]
                            where image.Value <bool>("front")
                            select image.Value <string>("image")).FirstOrDefault();

            return(imageUrl == null ? null : new Uri(imageUrl));
        }
        private IEnumerable <AlbumIdentification> ParseReleases(ApiRespose response, string discId)
        {
            foreach (var r in JObject.Parse(response.Json)["releases"])
            {
                var releaseResponse = _api.GetRelease((string)r["id"]);
                if (!releaseResponse.IsFound)
                {
                    //TODO: I should probably log this somewhere..
                    continue;
                }

                var release = JObject.Parse(releaseResponse.Json);
                var disc    = release["media"].First(m => m["discs"].Any(d => (string)d["id"] == discId));
                var tag     = new AlbumIdentification
                {
                    Id             = (string)release["id"],
                    AlbumArtist    = ComposeArtistName(release["artist-credit"]),
                    AlbumTitle     = (string)release["title"],
                    NumberOfTracks = (int)disc["track-count"],
                    Year           = (string)release["date"]
                };

                foreach (var t in disc["tracks"])
                {
                    tag.AddTrack(new TrackIdentification()
                    {
                        Title       = (string)t["title"],
                        Artist      = ComposeArtistName(release["artist-credit"]),
                        TrackNumber = (int)t["number"],
                        //Genre = (string)t[""], //MusicBrainz doesn't implement genres yet: https://musicbrainz.org/doc/General_FAQ#Why_does_MusicBrainz_not_support_genre_information.3F
                    });
                }

                yield return(tag);
            }
        }
 private bool IsCdStub(ApiRespose response)
 {
     return(!response.Json.Contains("releases"));
 }