From dbcbadbc3df7e3b8a3a4bb8182a3a0c7488dbd0f Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 12 Aug 2013 15:13:58 -0400 Subject: [PATCH] remove group filter from music brainz search --- .../Music/LastfmArtistProvider.cs | 60 +------------------ 1 file changed, 2 insertions(+), 58 deletions(-) diff --git a/MediaBrowser.Providers/Music/LastfmArtistProvider.cs b/MediaBrowser.Providers/Music/LastfmArtistProvider.cs index 526034d5a..d6fea14d5 100644 --- a/MediaBrowser.Providers/Music/LastfmArtistProvider.cs +++ b/MediaBrowser.Providers/Music/LastfmArtistProvider.cs @@ -87,17 +87,6 @@ namespace MediaBrowser.Providers.Music } } - //// Try to find the id using last fm - //var result = await FindIdFromLastFm(item, cancellationToken).ConfigureAwait(false); - - //if (result != null) - //{ - // if (!string.IsNullOrEmpty(result)) - // { - // return result; - // } - //} - try { // If we don't get anything, go directly to music brainz @@ -128,51 +117,6 @@ namespace MediaBrowser.Providers.Music return artist != null ? artist.GetProviderId(MetadataProviders.Musicbrainz) : null; } - /// - /// Finds the id from last fm. - /// - /// The item. - /// The cancellation token. - /// Task{System.String}. - private async Task FindIdFromLastFm(BaseItem item, CancellationToken cancellationToken) - { - //Execute the Artist search against our name and assume first one is the one we want - var url = RootUrl + string.Format("method=artist.search&artist={0}&api_key={1}&format=json", UrlEncode(item.Name), ApiKey); - - using (var json = await HttpClient.Get(new HttpRequestOptions - { - Url = url, - ResourcePool = LastfmResourcePool, - CancellationToken = cancellationToken, - EnableHttpCompression = false - - }).ConfigureAwait(false)) - { - using (var reader = new StreamReader(json, true)) - { - var jsonString = await reader.ReadToEndAsync().ConfigureAwait(false); - - // Sometimes they send back an empty response or just the text "null" - if (!jsonString.StartsWith("{", StringComparison.OrdinalIgnoreCase)) - { - return null; - } - - var searchResult = JsonSerializer.DeserializeFromString(jsonString); - - if (searchResult != null && searchResult.results != null && searchResult.results.artistmatches != null && searchResult.results.artistmatches.artist.Count > 0) - { - var artist = searchResult.results.artistmatches.artist - .FirstOrDefault(i => i.name != null && string.Compare(i.name, item.Name, CultureInfo.CurrentCulture, CompareOptions.IgnoreNonSpace | CompareOptions.IgnoreCase | CompareOptions.IgnoreSymbols) == 0); - - return artist == null ? null : artist.mbid; - } - } - } - - return null; - } - /// /// Finds the id from music brainz. /// @@ -190,7 +134,7 @@ namespace MediaBrowser.Providers.Music var ns = new XmlNamespaceManager(doc.NameTable); ns.AddNamespace("mb", "http://musicbrainz.org/ns/mmd-2.0#"); - var node = doc.SelectSingleNode("//mb:artist-list/mb:artist[@type='Group']/@id", ns); + var node = doc.SelectSingleNode("//mb:artist-list/mb:artist/@id", ns); if (node != null && node.Value != null) { @@ -206,7 +150,7 @@ namespace MediaBrowser.Providers.Music ns = new XmlNamespaceManager(doc.NameTable); ns.AddNamespace("mb", "http://musicbrainz.org/ns/mmd-2.0#"); - node = doc.SelectSingleNode("//mb:artist-list/mb:artist[@type='Group']/@id", ns); + node = doc.SelectSingleNode("//mb:artist-list/mb:artist/@id", ns); if (node != null && node.Value != null) {