From 1d37f9ad0e8281a612580c438f0130c5796ff8c4 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 16 Aug 2016 14:45:57 -0400 Subject: [PATCH 1/5] fix music brainz album search results --- .../Music/MusicBrainzAlbumProvider.cs | 100 +++++++++--------- 1 file changed, 51 insertions(+), 49 deletions(-) diff --git a/MediaBrowser.Providers/Music/MusicBrainzAlbumProvider.cs b/MediaBrowser.Providers/Music/MusicBrainzAlbumProvider.cs index 1710ec2b0f..a0ce806105 100644 --- a/MediaBrowser.Providers/Music/MusicBrainzAlbumProvider.cs +++ b/MediaBrowser.Providers/Music/MusicBrainzAlbumProvider.cs @@ -81,46 +81,24 @@ namespace MediaBrowser.Providers.Music private IEnumerable GetResultsFromResponse(XmlDocument doc) { - var ns = new XmlNamespaceManager(doc.NameTable); - ns.AddNamespace("mb", MusicBrainzBaseUrl + "/ns/mmd-2.0#"); - - var list = new List(); - - var nodes = doc.SelectNodes("//mb:release-list/mb:release", ns); - - if (nodes != null) + return ReleaseResult.Parse(doc).Select(i => { - foreach (var node in nodes.Cast()) + var result = new RemoteSearchResult { - if (node.Attributes != null) - { - string name = null; + Name = i.Title + }; - string mbzId = node.Attributes["id"].Value; - - var nameNode = node.SelectSingleNode("//mb:title", ns); - - if (nameNode != null) - { - name = nameNode.InnerText; - } - - if (!string.IsNullOrWhiteSpace(mbzId) && !string.IsNullOrWhiteSpace(name)) - { - var result = new RemoteSearchResult - { - Name = name - }; - - result.SetProviderId(MetadataProviders.MusicBrainzAlbum, mbzId); - - list.Add(result); - } - } + if (!string.IsNullOrWhiteSpace(i.ReleaseId)) + { + result.SetProviderId(MetadataProviders.MusicBrainzAlbum, i.ReleaseId); + } + if (!string.IsNullOrWhiteSpace(i.ReleaseGroupId)) + { + result.SetProviderId(MetadataProviders.MusicBrainzAlbum, i.ReleaseGroupId); } - } - return list; + return result; + }); } public async Task> GetMetadata(AlbumInfo id, CancellationToken cancellationToken) @@ -208,7 +186,7 @@ namespace MediaBrowser.Providers.Music var doc = await GetMusicBrainzResponse(url, true, cancellationToken).ConfigureAwait(false); - return ReleaseResult.Parse(doc); + return ReleaseResult.Parse(doc, 1).FirstOrDefault(); } private async Task GetReleaseResultByArtistName(string albumName, string artistName, CancellationToken cancellationToken) @@ -219,32 +197,32 @@ namespace MediaBrowser.Providers.Music var doc = await GetMusicBrainzResponse(url, true, cancellationToken).ConfigureAwait(false); - return ReleaseResult.Parse(doc); + return ReleaseResult.Parse(doc, 1).FirstOrDefault(); } private class ReleaseResult { public string ReleaseId; public string ReleaseGroupId; + public string Title; - public static ReleaseResult Parse(XmlDocument doc) + public static List Parse(XmlDocument doc, int? limit = null) { var docElem = doc.DocumentElement; + var list = new List(); if (docElem == null) { - return new ReleaseResult(); + return list; } var releaseList = docElem.FirstChild; if (releaseList == null) { - return new ReleaseResult(); + return list; } var nodes = releaseList.ChildNodes; - string releaseId = null; - string releaseGroupId = null; if (nodes != null) { @@ -252,18 +230,42 @@ namespace MediaBrowser.Providers.Music { if (string.Equals(node.Name, "release", StringComparison.OrdinalIgnoreCase)) { - releaseId = node.Attributes["id"].Value; - releaseGroupId = GetReleaseGroupIdFromReleaseNode(node); - break; + var releaseId = node.Attributes["id"].Value; + var releaseGroupId = GetReleaseGroupIdFromReleaseNode(node); + + list.Add(new ReleaseResult + { + ReleaseId = releaseId, + ReleaseGroupId = releaseGroupId, + Title = GetTitleFromReleaseNode(node) + }); + + if (limit.HasValue && list.Count >= limit.Value) + { + break; + } } } } - return new ReleaseResult + return list; + } + + private static string GetTitleFromReleaseNode(XmlNode node) + { + var subNodes = node.ChildNodes; + if (subNodes != null) { - ReleaseId = releaseId, - ReleaseGroupId = releaseGroupId - }; + foreach (var subNode in subNodes.Cast()) + { + if (string.Equals(subNode.Name, "title", StringComparison.OrdinalIgnoreCase)) + { + return subNode.InnerText; + } + } + } + + return null; } private static string GetReleaseGroupIdFromReleaseNode(XmlNode node) From ae887d9157335db66bf569ab31f274fc24503146 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 16 Aug 2016 14:46:12 -0400 Subject: [PATCH 2/5] remove readinputatnativeframerate --- .../LiveTv/TunerHosts/M3UTunerHost.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs b/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs index 5b83e7cbe8..5c508aacd3 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs @@ -136,7 +136,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts RequiresOpening = false, RequiresClosing = false, - ReadAtNativeFramerate = true + ReadAtNativeFramerate = false }; return new List { mediaSource }; From 1dc5911f068e2c3a7035081ee3fdbbedc4f09225 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 16 Aug 2016 16:54:13 -0400 Subject: [PATCH 3/5] update multi-select --- MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj | 3 +++ 1 file changed, 3 insertions(+) diff --git a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj index 50e1cfbbea..61facf8ec4 100644 --- a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj +++ b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj @@ -173,6 +173,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest From 1c815d2e720b95e93cc993fbbdba71551f7bd214 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 17 Aug 2016 01:29:05 -0400 Subject: [PATCH 4/5] update sync display --- MediaBrowser.Server.Implementations/IO/LibraryMonitor.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MediaBrowser.Server.Implementations/IO/LibraryMonitor.cs b/MediaBrowser.Server.Implementations/IO/LibraryMonitor.cs index dea0a978bf..ea9e58ee47 100644 --- a/MediaBrowser.Server.Implementations/IO/LibraryMonitor.cs +++ b/MediaBrowser.Server.Implementations/IO/LibraryMonitor.cs @@ -52,7 +52,8 @@ namespace MediaBrowser.Server.Implementations.IO ".db", // bts sync files - ".bts" + ".bts", + ".sync" }; /// From a69f8ecb3dd9267d9b94d8b6ab60e7193c21cf7c Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 17 Aug 2016 01:33:30 -0400 Subject: [PATCH 5/5] update logging --- MediaBrowser.Controller/Entities/TV/Season.cs | 3 +++ MediaBrowser.Controller/Entities/TV/Series.cs | 10 ++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/MediaBrowser.Controller/Entities/TV/Season.cs b/MediaBrowser.Controller/Entities/TV/Season.cs index 66fe1cc756..78a974bf76 100644 --- a/MediaBrowser.Controller/Entities/TV/Season.cs +++ b/MediaBrowser.Controller/Entities/TV/Season.cs @@ -170,10 +170,13 @@ namespace MediaBrowser.Controller.Entities.TV Func filter = i => UserViewBuilder.Filter(i, user, query, UserDataManager, LibraryManager); + Logger.Debug("Season.GetItemsInternal entering GetEpisodes"); var items = GetEpisodes(user).Where(filter); + Logger.Debug("Season.GetItemsInternal entering PostFilterAndSort"); var result = PostFilterAndSort(items, query); + Logger.Debug("Season.GetItemsInternal complete"); return Task.FromResult(result); } diff --git a/MediaBrowser.Controller/Entities/TV/Series.cs b/MediaBrowser.Controller/Entities/TV/Series.cs index 02ac42b2af..30c06b2442 100644 --- a/MediaBrowser.Controller/Entities/TV/Series.cs +++ b/MediaBrowser.Controller/Entities/TV/Series.cs @@ -379,13 +379,19 @@ namespace MediaBrowser.Controller.Entities.TV private IEnumerable GetAllEpisodes(User user) { - return LibraryManager.GetItemList(new InternalItemsQuery(user) + Logger.Debug("Series.GetAllEpisodes entering GetItemList"); + + var result = LibraryManager.GetItemList(new InternalItemsQuery(user) { AncestorWithPresentationUniqueKey = GetUniqueSeriesKey(this), IncludeItemTypes = new[] { typeof(Episode).Name }, SortBy = new[] { ItemSortBy.SortName } - }).Cast(); + }).Cast().ToList(); + + Logger.Debug("Series.GetAllEpisodes returning {0} episodes", result.Count); + + return result; } public IEnumerable GetSeasonEpisodes(User user, Season parentSeason, bool includeMissingEpisodes, bool includeVirtualUnairedEpisodes)