From f54a0da88e12b8b86c70c7de51d6d8fa24366b31 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 20 May 2016 11:57:07 -0400 Subject: [PATCH 1/4] better cleanup of recording libraries --- MediaBrowser.Model/LiveTv/LiveTvOptions.cs | 3 ++ .../LiveTv/EmbyTV/EmbyTV.cs | 30 +++++++++++++++---- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/MediaBrowser.Model/LiveTv/LiveTvOptions.cs b/MediaBrowser.Model/LiveTv/LiveTvOptions.cs index 4211fbd59f..e00443d191 100644 --- a/MediaBrowser.Model/LiveTv/LiveTvOptions.cs +++ b/MediaBrowser.Model/LiveTv/LiveTvOptions.cs @@ -20,12 +20,15 @@ namespace MediaBrowser.Model.LiveTv public int PrePaddingSeconds { get; set; } public int PostPaddingSeconds { get; set; } + public string[] MediaLocationsCreated { get; set; } + public LiveTvOptions() { EnableMovieProviders = true; EnableRecordingSubfolders = true; TunerHosts = new List(); ListingProviders = new List(); + MediaLocationsCreated = new string[] { }; } } diff --git a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs index 2de51479f2..de75aac9cd 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs @@ -115,17 +115,13 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV { var recordingFolders = GetRecordingFolders(); - var defaultRecordingPath = DefaultRecordingPath; - if (!recordingFolders.Any(i => i.Locations.Contains(defaultRecordingPath, StringComparer.OrdinalIgnoreCase))) - { - RemovePathFromLibrary(defaultRecordingPath); - } - var virtualFolders = _libraryManager.GetVirtualFolders() .ToList(); var allExistingPaths = virtualFolders.SelectMany(i => i.Locations).ToList(); + var pathsAdded = new List(); + foreach (var recordingFolder in recordingFolders) { var pathsToCreate = recordingFolder.Locations @@ -145,11 +141,33 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV { _logger.ErrorException("Error creating virtual folder", ex); } + + pathsAdded.AddRange(pathsToCreate); + } + + var config = GetConfiguration(); + + var pathsToRemove = config.MediaLocationsCreated + .Except(recordingFolders.SelectMany(i => i.Locations)) + .ToList(); + + if (pathsAdded.Count > 0 || pathsToRemove.Count > 0) + { + pathsAdded.InsertRange(0, config.MediaLocationsCreated); + config.MediaLocationsCreated = pathsAdded.Except(pathsToRemove).Distinct(StringComparer.OrdinalIgnoreCase).ToArray(); + _config.SaveConfiguration("livetv", config); + } + + foreach (var path in pathsToRemove) + { + RemovePathFromLibrary(path); } } private void RemovePathFromLibrary(string path) { + _logger.Debug("Removing path from library: {0}", path); + var requiresRefresh = false; var virtualFolders = _libraryManager.GetVirtualFolders() .ToList(); From 8cdd8a6bca77fd77458d8730b0b3d69a68968c14 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 20 May 2016 12:49:21 -0400 Subject: [PATCH 2/4] updated nuget --- Nuget/MediaBrowser.Common.Internal.nuspec | 4 ++-- Nuget/MediaBrowser.Common.nuspec | 2 +- Nuget/MediaBrowser.Model.Signed.nuspec | 20 -------------------- Nuget/MediaBrowser.Server.Core.nuspec | 4 ++-- 4 files changed, 5 insertions(+), 25 deletions(-) delete mode 100644 Nuget/MediaBrowser.Model.Signed.nuspec diff --git a/Nuget/MediaBrowser.Common.Internal.nuspec b/Nuget/MediaBrowser.Common.Internal.nuspec index bfb4bcc80d..56429c6a6b 100644 --- a/Nuget/MediaBrowser.Common.Internal.nuspec +++ b/Nuget/MediaBrowser.Common.Internal.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common.Internal - 3.0.647 + 3.0.648 MediaBrowser.Common.Internal Luke ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains common components shared by Emby Theater and Emby Server. Not intended for plugin developer consumption. Copyright © Emby 2013 - + diff --git a/Nuget/MediaBrowser.Common.nuspec b/Nuget/MediaBrowser.Common.nuspec index f0f6320f02..d129848697 100644 --- a/Nuget/MediaBrowser.Common.nuspec +++ b/Nuget/MediaBrowser.Common.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common - 3.0.647 + 3.0.648 MediaBrowser.Common Emby Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Model.Signed.nuspec b/Nuget/MediaBrowser.Model.Signed.nuspec deleted file mode 100644 index 6c47b62eb1..0000000000 --- a/Nuget/MediaBrowser.Model.Signed.nuspec +++ /dev/null @@ -1,20 +0,0 @@ - - - - MediaBrowser.Model.Signed - 3.0.647 - MediaBrowser.Model - Signed Edition - Emby Team - ebr,Luke,scottisafool - https://github.com/MediaBrowser/MediaBrowser - http://www.mb3admin.com/images/mb3icons1-1.png - false - Contains common model objects and interfaces used by all Emby solutions. - Copyright © Emby 2013 - - - - - - - \ No newline at end of file diff --git a/Nuget/MediaBrowser.Server.Core.nuspec b/Nuget/MediaBrowser.Server.Core.nuspec index 8060298caa..a9caab74cd 100644 --- a/Nuget/MediaBrowser.Server.Core.nuspec +++ b/Nuget/MediaBrowser.Server.Core.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Server.Core - 3.0.647 + 3.0.648 Media Browser.Server.Core Emby Team ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains core components required to build plugins for Emby Server. Copyright © Emby 2013 - + From da91a37f711ce13ca42eaecb94c266126318c15e Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 20 May 2016 13:15:07 -0400 Subject: [PATCH 3/4] update components --- MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj index 0061ec5de0..e85f5a27b1 100644 --- a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj +++ b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj @@ -107,9 +107,6 @@ PreserveNewest - - PreserveNewest - PreserveNewest @@ -1686,6 +1683,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest From 2daf91b3fe04d8fc189773e60d90cec61996b0f5 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 20 May 2016 15:45:04 -0400 Subject: [PATCH 4/4] update missing season creator --- .../Entities/CollectionFolder.cs | 13 ------------- MediaBrowser.Controller/Entities/Folder.cs | 13 ------------- MediaBrowser.Providers/TV/DummySeasonProvider.cs | 12 +++++------- MediaBrowser.Providers/TV/MissingEpisodeProvider.cs | 2 +- MediaBrowser.Providers/TV/SeasonMetadataService.cs | 2 +- .../LiveTv/LiveTvManager.cs | 3 ++- 6 files changed, 9 insertions(+), 36 deletions(-) diff --git a/MediaBrowser.Controller/Entities/CollectionFolder.cs b/MediaBrowser.Controller/Entities/CollectionFolder.cs index b81276ae71..35dfd52e9d 100644 --- a/MediaBrowser.Controller/Entities/CollectionFolder.cs +++ b/MediaBrowser.Controller/Entities/CollectionFolder.cs @@ -23,19 +23,6 @@ namespace MediaBrowser.Controller.Entities PhysicalLocationsList = new List(); } - /// - /// Gets a value indicating whether this instance is virtual folder. - /// - /// true if this instance is virtual folder; otherwise, false. - [IgnoreDataMember] - public override bool IsVirtualFolder - { - get - { - return true; - } - } - [IgnoreDataMember] protected override bool SupportsShortcutChildren { diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index 3e717862a9..c94c266262 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -126,19 +126,6 @@ namespace MediaBrowser.Controller.Entities /// true if this instance is root; otherwise, false. public bool IsRoot { get; set; } - /// - /// Gets a value indicating whether this instance is virtual folder. - /// - /// true if this instance is virtual folder; otherwise, false. - [IgnoreDataMember] - public virtual bool IsVirtualFolder - { - get - { - return false; - } - } - public virtual List LinkedChildren { get; set; } [IgnoreDataMember] diff --git a/MediaBrowser.Providers/TV/DummySeasonProvider.cs b/MediaBrowser.Providers/TV/DummySeasonProvider.cs index 2c6e27294d..8fb04b8520 100644 --- a/MediaBrowser.Providers/TV/DummySeasonProvider.cs +++ b/MediaBrowser.Providers/TV/DummySeasonProvider.cs @@ -69,7 +69,7 @@ namespace MediaBrowser.Providers.TV if (!hasSeason) { - await AddSeason(series, seasonNumber, cancellationToken).ConfigureAwait(false); + await AddSeason(series, seasonNumber, false, cancellationToken).ConfigureAwait(false); hasChanges = true; } @@ -83,7 +83,7 @@ namespace MediaBrowser.Providers.TV if (!hasSeason) { - await AddSeason(series, null, cancellationToken).ConfigureAwait(false); + await AddSeason(series, null, false, cancellationToken).ConfigureAwait(false); hasChanges = true; } @@ -95,12 +95,9 @@ namespace MediaBrowser.Providers.TV /// /// Adds the season. /// - /// The series. - /// The season number. - /// The cancellation token. - /// Task{Season}. public async Task AddSeason(Series series, int? seasonNumber, + bool isMissingSeason, CancellationToken cancellationToken) { var seasonName = seasonNumber == 0 ? @@ -113,7 +110,8 @@ namespace MediaBrowser.Providers.TV { Name = seasonName, IndexNumber = seasonNumber, - Id = _libraryManager.GetNewItemId((series.Id + (seasonNumber ?? -1).ToString(_usCulture) + seasonName), typeof(Season)) + Id = _libraryManager.GetNewItemId((series.Id + (seasonNumber ?? -1).ToString(_usCulture) + seasonName), typeof(Season)), + IsMissingSeason = isMissingSeason }; season.SetParent(series); diff --git a/MediaBrowser.Providers/TV/MissingEpisodeProvider.cs b/MediaBrowser.Providers/TV/MissingEpisodeProvider.cs index e79ad2dfbd..2a3150c78b 100644 --- a/MediaBrowser.Providers/TV/MissingEpisodeProvider.cs +++ b/MediaBrowser.Providers/TV/MissingEpisodeProvider.cs @@ -418,7 +418,7 @@ namespace MediaBrowser.Providers.TV if (season == null) { var provider = new DummySeasonProvider(_config, _logger, _localization, _libraryManager, _fileSystem); - season = await provider.AddSeason(series, seasonNumber, cancellationToken).ConfigureAwait(false); + season = await provider.AddSeason(series, seasonNumber, true, cancellationToken).ConfigureAwait(false); } var name = string.Format("Episode {0}", episodeNumber.ToString(_usCulture)); diff --git a/MediaBrowser.Providers/TV/SeasonMetadataService.cs b/MediaBrowser.Providers/TV/SeasonMetadataService.cs index 292923d824..fc072052a0 100644 --- a/MediaBrowser.Providers/TV/SeasonMetadataService.cs +++ b/MediaBrowser.Providers/TV/SeasonMetadataService.cs @@ -69,7 +69,7 @@ namespace MediaBrowser.Providers.TV private ItemUpdateType SaveIsMissing(Season item, List episodes) { - var isMissing = item.LocationType == LocationType.Virtual && episodes.All(i => i.IsMissingEpisode); + var isMissing = item.LocationType == LocationType.Virtual && (episodes.Count == 0 || episodes.All(i => i.IsMissingEpisode)); if (item.IsMissingSeason != isMissing) { diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs index fdf6599daf..91f84e2fef 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs @@ -1420,8 +1420,9 @@ namespace MediaBrowser.Server.Implementations.LiveTv MediaTypes = new[] { MediaType.Video }, Recursive = true, AncestorIds = folders.Select(i => i.Id.ToString("N")).ToArray(), + IsFolder = false, ExcludeLocationTypes = new[] { LocationType.Virtual }, - Limit = Math.Min(10, query.Limit ?? int.MaxValue), + Limit = Math.Min(200, query.Limit ?? int.MaxValue), SortBy = new[] { ItemSortBy.DateCreated }, SortOrder = SortOrder.Descending });