public Song(XMLNodeG recordNode) : base(MBEntityType.recording) { if (recordNode.node.Name == "recording") { this.Name = recordNode.GetChild("title").InnerText; this.MBID = recordNode.GetAttributeVal("id"); //-------------- Get duration --------------------- string dur = recordNode.GetChild("length").InnerText; if (dur != "") //if duration exists { this.duration = int.Parse(dur); } //-------------- Get artists --------------------- foreach (XMLNodeG ArtistNode in recordNode.GetChildren("artist-credit")) { foreach (XMLNodeG ArtistNameNode in ArtistNode.GetChildren("name-credit")) { Artists.Add(new Artist(ArtistNameNode)); Artists.Reverse(); //featured artists are always shown first for some reason, make them come last } } //-------------- Get releases --------------------- foreach (XMLNodeG releaseListNode in recordNode.GetChildren("release-list")) { foreach (XMLNodeG releaseNode in releaseListNode.GetChildren("release")) { Releases.Add(new Release(releaseNode)); } } } }
public Artist(XMLNodeG artistNode) : base(MBEntityType.artist) { if (artistNode.node.Name == "name-credit") //case when artist is part of a recording query tag { this.JoinPhrase = artistNode.GetAttributeVal("joinphrase"); artistNode = artistNode.GetChild("artist"); } else if (artistNode.node.Name == "artist") //case when search was done for an artist { this.Country = artistNode.GetChild("country").InnerText; this.Location = artistNode.GetChild("area").GetChild("name").InnerText; this.StartDate = artistNode.GetChild("life-span").GetChild("begin").InnerText; } this.MBID = artistNode.GetAttributeVal("id"); this.Name = artistNode.GetChild("name").InnerText; //--------------- Get releases if available ---------------- var releaseGroupListNode = artistNode.GetChild("release-group-list"); if (releaseGroupListNode != null) { foreach (XMLNodeG releaseGroupNode in releaseGroupListNode.GetChildren("release-group")) { ReleaseGroups.Add(new ReleaseGroup(releaseGroupNode)); } } }
public async Task PopulateReleaseGroups() { //search the database for this artist specifically var doc = await MBServer.Lookup(MBEntityType.artist, this.MBID, new string[] { "release-groups" }); //create a new artist object - the new function will grab the release list this time var artistNode = new XMLNodeG(XMLFns.GetChildren(doc.DocumentElement, "artist").First()); var tmpArtist = new Artist(artistNode); //copy the release groups from the temporary arist to this one this.ReleaseGroups = tmpArtist.ReleaseGroups; } //requires a server search
public async Task PopulateReleases() { //search the database for this artist specifically var doc = await MBServer.Lookup(MBEntityType.releaseGroup, this.MBID, new string[] { "releases" }); //create a new releaseGroupobject - the new function will grab the release list this time var releaseGroupNode = new XMLNodeG(XMLFns.GetChildren(doc.DocumentElement, "release-group").First()); var tmpGroup = new ReleaseGroup(releaseGroupNode); //copy the releases from the temporary group to this one this.Releases = tmpGroup.Releases; }
public Release(XMLNodeG releaseNode) : base(MBEntityType.release) { if (releaseNode.node.Name == "release") { this.MBID = releaseNode.GetAttributeVal("id"); this.Name = releaseNode.GetChild("title").InnerText; this.Date = releaseNode.GetChild("date").InnerText; this.Country = releaseNode.GetChild("country").InnerText; this.TrackCount = releaseNode.GetChild("medium-list").GetChild("track-count").InnerText; this.SongTrackNum = releaseNode.GetChild("medium-list").GetChild("medium").GetChild("track-list").GetChild("track").GetChild("number").InnerText; this.ReleaseTypeString = releaseNode.GetChild("release-group").GetAttributeVal("type"); if (this.ReleaseType == ReleaseTypes.Unknown) //handle all random strings that don't match { this.ReleaseTypeString = "Unkown"; } } }
public ReleaseGroup(XMLNodeG releaseGroupNode) : base(MBEntityType.releaseGroup) { if (releaseGroupNode.node.Name == "release-group") { this.MBID = releaseGroupNode.GetAttributeVal("id"); this.Name = releaseGroupNode.GetChild("title").InnerText; this.Date = releaseGroupNode.GetChild("first-release-date").InnerText; this.ReleaseType = releaseGroupNode.GetAttributeVal("type"); //--------------- Get releases if available ---------------- var releaseListNode = releaseGroupNode.GetChild("release-list"); if (releaseListNode != null) { foreach (XMLNodeG releaseNode in releaseListNode.GetChildren("release")) { Releases.Add(new Release(releaseNode)); } } } }