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); }
public static AlbumIdentification GetEmpty(int numberOfTracks) { var album = new AlbumIdentification { Id = null, AlbumArtist = "Unknown Artist", AlbumTitle = "Unknown Album", NumberOfTracks = numberOfTracks }; foreach (var trackNumber in Enumerable.Range(1, numberOfTracks)) { album.AddTrack(TrackIdentification.GetEmpty(album, trackNumber)); } return(album); }
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); } }