public static ParseDataQuality ( string dataQuality ) : DataQuality | ||
dataQuality | string | |
return | DataQuality |
public Label ReadLabel(JObject source) { Label label = new Label(); foreach (var item in source) { var v = item.Value; switch (item.Key) { case "id": label.Id = v.Value <int>(); break; case "profile": label.Profile = v.Value <string>(); break; case "releases_url": break; case "name": label.Name = v.Value <string>(); break; case "contact_info": label.ContactInfo = v.Value <string>(); break; case "uri": label.Uri = v.Value <string>(); break; case "sublabels": label.Sublabels = v.Value <JArray>().Cast <JObject>().Select(t => this.ReadSublabel(t)).ToArray(); break; case "urls": label.Urls = v.ValueAsStringArray(); break; case "images": label.Images = this.ReadImages(v.Value <JArray>()); break; case "resource_url": break; case "data_quality": label.DataQuality = DataReader.ParseDataQuality(v.Value <string>()); break; default: this.ThrowIfStrict("Unknown key: " + item.Key); break; } } return(label); }
public Artist ReadArtist() { this.XmlReader.AssertElementStart("artist"); Artist artist = new Artist(); while (true) { this.XmlReader.AssertRead(); if (this.XmlReader.IsElementEnd("artist")) { break; } if (this.XmlReader.IsElementStart("images")) { artist.Images = this.ReadImages(); } else if (this.XmlReader.IsElementStart("id")) { this.XmlReader.AssertNonEmptyElement(); this.XmlReader.AssertRead(); artist.Id = int.Parse(this.XmlReader.ReadContentAsString()); } else if (this.XmlReader.IsElementStart("name")) { if (!this.XmlReader.IsEmptyElement) { this.XmlReader.AssertRead(); artist.Name = this.XmlReader.ReadContentAsString(); } } else if (this.XmlReader.IsElementStart("realname")) { this.XmlReader.AssertNonEmptyElement(); this.XmlReader.AssertRead(); artist.RealName = this.XmlReader.ReadContentAsString(); } else if (this.XmlReader.IsElementStart("realname")) { this.XmlReader.AssertNonEmptyElement(); this.XmlReader.AssertRead(); artist.RealName = this.XmlReader.ReadContentAsString(); } else if (this.XmlReader.IsElementStart("profile")) { this.XmlReader.AssertNonEmptyElement(); this.XmlReader.AssertRead(); artist.Profile = this.XmlReader.ReadContentAsString().Trim(); } else if (this.XmlReader.IsElementStart("data_quality")) { this.XmlReader.AssertNonEmptyElement(); this.XmlReader.AssertRead(); artist.DataQuality = DataReader.ParseDataQuality(this.XmlReader.ReadContentAsString()); } else if (this.XmlReader.IsElementStart("urls")) { artist.Urls = this.ReadUrls(); } else if (this.XmlReader.IsElementStart("namevariations")) { artist.NameVariations = this.ReadNameVariations(); } else if (this.XmlReader.IsElementStart("aliases")) { artist.Aliases = this.ReadAliases(); } else if (this.XmlReader.IsElementStart("groups")) { artist.Groups = this.ReadGroups(); } //else if (this.XmlReader.IsElementStart("members")) //{ // artist.Members = this.ReadMembers(); //} else { this.ThrowInvalidFormatException(); } } return(artist); }
public MasterRelease ReadMasterRelease() { this.XmlReader.AssertElementStart("master"); MasterRelease master = new MasterRelease(); master.Id = int.Parse(this.XmlReader.GetAttribute("id")); while (true) { this.XmlReader.AssertRead(); if (this.XmlReader.IsElementEnd("master")) { break; } if (this.XmlReader.IsElementStart("main_release")) { this.XmlReader.AssertNonEmptyElement(); this.XmlReader.AssertRead(); master.MainRelease = int.Parse(this.XmlReader.ReadContentAsString()); } else if (this.XmlReader.IsElementStart("images")) { master.Images = this.ReadImages(); } else if (this.XmlReader.IsElementStart("artists")) { master.Artists = this.ReadReleaseArtists(); } else if (this.XmlReader.IsElementStart("genres")) { master.Genres = this.ReadGenres(); } else if (this.XmlReader.IsElementStart("styles")) { master.Styles = this.ReadStyles(); } else if (this.XmlReader.IsElementStart("year")) { this.XmlReader.AssertNonEmptyElement(); this.XmlReader.AssertRead(); master.Year = int.Parse(this.XmlReader.ReadContentAsString()); } else if (this.XmlReader.IsElementStart("title")) { if (!this.XmlReader.IsEmptyElement) { this.XmlReader.AssertRead(); master.Title = this.XmlReader.ReadContentAsString(); } } else if (this.XmlReader.IsElementStart("data_quality")) { this.XmlReader.AssertNonEmptyElement(); this.XmlReader.AssertRead(); master.DataQuality = DataReader.ParseDataQuality(this.XmlReader.ReadContentAsString()); } else if (this.XmlReader.IsElementStart("tracklist")) { master.Tracklist = this.ReadTracklist(); } else if (this.XmlReader.IsElementStart("videos")) { master.Videos = this.ReadVideos(); } else if (this.XmlReader.IsElementStart("versions")) { master.Versions = this.ReadReleaseVersions(); } else if (this.XmlReader.IsElementStart("notes")) { this.XmlReader.AssertNonEmptyElement(); this.XmlReader.AssertRead(); master.Notes = this.XmlReader.ReadContentAsString(); } else { this.ThrowInvalidFormatException(); } } return(master); }
public Release ReadRelease() { this.XmlReader.AssertElementStart("release"); Release release = new Release(); release.Id = int.Parse(this.XmlReader.GetAttribute("id")); release.Status = DataReader.ParseReleaseStatus(this.XmlReader.GetAttribute("status")); while (true) { this.XmlReader.AssertRead(); if (this.XmlReader.IsElementEnd("release")) { break; } if (this.XmlReader.IsElementStart("images")) { release.Images = this.ReadImages(); } else if (this.XmlReader.IsElementStart("artists")) { release.Artists = this.ReadReleaseArtists(); } else if (this.XmlReader.IsElementStart("title")) { this.XmlReader.AssertNonEmptyElement(); this.XmlReader.AssertRead(); release.Title = this.XmlReader.ReadContentAsString(); } else if (this.XmlReader.IsElementStart("labels")) { release.Labels = this.ReadReleaseLabels(); } else if (this.XmlReader.IsElementStart("extraartists")) { release.ExtraArtists = this.ReadExtraArtists(); } else if (this.XmlReader.IsElementStart("formats")) { release.Formats = this.ReadFormats(); } else if (this.XmlReader.IsElementStart("genres")) { release.Genres = this.ReadGenres(); } else if (this.XmlReader.IsElementStart("styles")) { release.Styles = this.ReadStyles(); } else if (this.XmlReader.IsElementStart("country")) { this.XmlReader.AssertNonEmptyElement(); this.XmlReader.AssertRead(); release.Country = this.XmlReader.ReadContentAsString(); } else if (this.XmlReader.IsElementStart("released")) { this.XmlReader.AssertNonEmptyElement(); this.XmlReader.AssertRead(); release.ReleaseDate = this.XmlReader.ReadContentAsString(); } else if (this.XmlReader.IsElementStart("notes")) { this.XmlReader.AssertNonEmptyElement(); this.XmlReader.AssertRead(); release.Notes = this.XmlReader.ReadContentAsString(); } else if (this.XmlReader.IsElementStart("master_id")) { this.XmlReader.AssertNonEmptyElement(); this.XmlReader.AssertRead(); release.MasterId = int.Parse(this.XmlReader.ReadContentAsString()); } else if (this.XmlReader.IsElementStart("data_quality")) { this.XmlReader.AssertNonEmptyElement(); this.XmlReader.AssertRead(); release.DataQuality = DataReader.ParseDataQuality(this.XmlReader.ReadContentAsString()); } else if (this.XmlReader.IsElementStart("tracklist")) { release.Tracklist = this.ReadTracklist(); } else if (this.XmlReader.IsElementStart("videos")) { release.Videos = this.ReadVideos(); } else if (this.XmlReader.IsElementStart("identifiers")) { release.Identifiers = this.ReadReleaseIdentifiers(); } else { this.ThrowInvalidFormatException(); } } return(release); }
public Label ReadLabel() { this.XmlReader.AssertElementStart("label"); Label label = new Label(); while (true) { this.XmlReader.AssertRead(); if (this.XmlReader.IsElementEnd("label")) { break; } if (this.XmlReader.IsElementStart("images")) { label.Images = this.ReadImages(); } else if (this.XmlReader.IsElementStart("id")) { if (!this.XmlReader.IsEmptyElement) { this.XmlReader.AssertRead(); label.Id = int.Parse(this.XmlReader.ReadContentAsString()); } } else if (this.XmlReader.IsElementStart("name")) { if (!this.XmlReader.IsEmptyElement) { this.XmlReader.AssertRead(); label.Name = this.XmlReader.ReadContentAsString(); } } else if (this.XmlReader.IsElementStart("contactinfo")) { if (!this.XmlReader.IsEmptyElement) { this.XmlReader.AssertRead(); label.ContactInfo = this.XmlReader.ReadContentAsString(); } } else if (this.XmlReader.IsElementStart("profile")) { if (!this.XmlReader.IsEmptyElement) { this.XmlReader.AssertRead(); label.Profile = this.XmlReader.ReadContentAsString(); } } else if (this.XmlReader.IsElementStart("data_quality")) { if (!this.XmlReader.IsEmptyElement) { this.XmlReader.AssertRead(); label.DataQuality = DataReader.ParseDataQuality(this.XmlReader.ReadContentAsString()); } } else if (this.XmlReader.IsElementStart("urls")) { label.Urls = this.ReadUrls(); } else if (this.XmlReader.IsElementStart("sublabels")) { label.Sublabels = this.ReadSublabels(); } else if (this.XmlReader.IsElementStart("parentLabel")) { if (!this.XmlReader.IsEmptyElement) { this.XmlReader.AssertRead(); label.ParentLabel = this.XmlReader.ReadContentAsString(); } } else { this.ThrowInvalidFormatException(); } } return(label); }
public MasterRelease ReadMasterRelease(JObject source) { MasterRelease master = new MasterRelease(); foreach (var item in source) { var v = item.Value; switch (item.Key) { case "id": master.Id = v.Value <int>(); break; case "videos": master.Videos = this.ReadReleaseVideos(v.Value <JArray>()); break; case "series": if (((JArray)v).Count != 0) { this.ThrowIfStrict("Unable to process \"series\" item."); } break; case "year": // We skip year. Can extract it from release date. break; case "images": master.Images = this.ReadImages(v.Value <JArray>()); break; case "genres": master.Genres = v.ValueAsStringArray(); break; case "thumb": // We skip thumb. Can extract it from images. break; case "title": master.Title = v.Value <string>(); break; case "artists": master.Artists = this.ReadReleaseArtists(v.Value <JArray>()); break; case "tracklist": master.Tracklist = this.ReadReleaseTracklist(v.Value <JArray>()); break; case "styles": master.Styles = v.ValueAsStringArray(); break; case "released_formatted": // We skip released_formatted. Can extract it from released. break; case "master_url": // We skip master_url. Can extract it from master_id. break; case "notes": master.Notes = v.Value <string>(); break; case "companies": // TODO: implement model for this break; case "uri": // TODO: implement model for this break; case "resource_url": break; case "data_quality": master.DataQuality = DataReader.ParseDataQuality(v.Value <string>()); break; case "main_release": master.MainRelease = v.Value <int>(); break; case "main_release_url": break; case "versions_url": break; default: this.ThrowIfStrict("Unknown key: " + item.Key); break; } } return(master); }
public Artist ReadArtist(JObject source) { Artist artist = new Artist(); foreach (var item in source) { var v = item.Value; switch (item.Key) { case "id": artist.Id = v.Value <int>(); break; case "name": artist.Name = v.Value <string>(); break; case "profile": artist.Profile = v.Value <string>(); break; case "realname": artist.RealName = v.Value <string>(); break; case "releases_url": break; case "urls": artist.Urls = v.ValueAsStringArray(); break; case "images": artist.Images = this.ReadImages(v.Value <JArray>()); break; case "aliases": artist.Aliases = v.Value <JArray>().Cast <JObject>().Select(t => this.ReadArtistAlias(t)).ToArray(); break; case "members": artist.Members = v.Value <JArray>().Cast <JObject>().Select(t => this.ReadMembers(t)).ToArray(); break; case "uri": break; case "resource_url": break; case "data_quality": artist.DataQuality = DataReader.ParseDataQuality(v.Value <string>()); break; case "namevariations": artist.NameVariations = v.ValueAsStringArray(); break; default: this.ThrowIfStrict("Unknown key: " + item.Key); break; } } return(artist); }
public Release ReadRelease(JObject source) { Release release = new Release(); foreach (var item in source) { var v = item.Value; switch (item.Key) { case "id": release.Id = v.Value <int>(); break; case "status": release.Status = DataReader.ParseReleaseStatus(v.Value <string>()); break; case "videos": release.Videos = this.ReadReleaseVideos(v.Value <JArray>()); break; case "series": if (((JArray)v).Count != 0) { this.ThrowIfStrict("Unable to process \"series\" item."); } break; case "labels": release.Labels = this.ReadReleaseLabels(v.Value <JArray>()); break; case "year": // We skip year. Can extract it from release date. break; case "images": release.Images = this.ReadImages(v.Value <JArray>()); break; case "genres": release.Genres = v.ValueAsStringArray(); break; case "thumb": // We skip thumb. Can extract it from images. break; case "extraartists": release.ExtraArtists = this.ReadExtraArtists(v.Value <JArray>()); break; case "title": release.Title = v.Value <string>(); break; case "artists": release.Artists = this.ReadReleaseArtists(v.Value <JArray>()); break; case "master_id": release.MasterId = v.Value <int>(); break; case "tracklist": release.Tracklist = this.ReadReleaseTracklist(v.Value <JArray>()); break; case "styles": release.Styles = v.ValueAsStringArray(); break; case "released_formatted": // We skip released_formatted. Can extract it from released. break; case "released": release.ReleaseDate = v.Value <string>(); break; case "master_url": // We skip master_url. Can extract it from master_id. break; case "country": release.Country = v.Value <string>(); break; case "notes": release.Notes = v.Value <string>(); break; case "companies": release.Compaines = this.ReadCompanies(v.Value <JArray>()); break; case "uri": // TODO: implement model for this break; case "formats": release.Formats = this.ReadReleaseFormats(v.Value <JArray>()); break; case "resource_url": break; case "data_quality": release.DataQuality = DataReader.ParseDataQuality(v.Value <string>()); break; case "identifiers": release.Identifiers = this.ReadReleaseIdentifiers(v.Value <JArray>()); break; default: this.ThrowIfStrict("Unknown key: " + item.Key); break; } } return(release); }