diff --git a/MediaBrowser.Api/PlaylistService.cs b/MediaBrowser.Api/PlaylistService.cs index 2e3d38f46..bc289f9f7 100644 --- a/MediaBrowser.Api/PlaylistService.cs +++ b/MediaBrowser.Api/PlaylistService.cs @@ -134,6 +134,7 @@ namespace MediaBrowser.Api { var playlist = (Playlist)_libraryManager.GetItemById(request.Id); var user = request.UserId.HasValue ? _userManager.GetUserById(request.UserId.Value) : null; + var items = playlist.GetManageableItems().ToArray(); var count = items.Length; @@ -149,9 +150,16 @@ namespace MediaBrowser.Api } var dtos = items - .Select(i => _dtoService.GetBaseItemDto(i, request.GetItemFields().ToList(), user)) + .Select(i => _dtoService.GetBaseItemDto(i.Item2, request.GetItemFields().ToList(), user)) .ToArray(); + var index = 0; + foreach (var item in dtos) + { + item.PlaylistItemId = items[index].Item1.Id; + index++; + } + var result = new ItemsResult { Items = dtos, diff --git a/MediaBrowser.Common.Implementations/ScheduledTasks/Tasks/DeleteCacheFileTask.cs b/MediaBrowser.Common.Implementations/ScheduledTasks/Tasks/DeleteCacheFileTask.cs index ddaa8df7d..fcb7b159b 100644 --- a/MediaBrowser.Common.Implementations/ScheduledTasks/Tasks/DeleteCacheFileTask.cs +++ b/MediaBrowser.Common.Implementations/ScheduledTasks/Tasks/DeleteCacheFileTask.cs @@ -46,7 +46,7 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks.Tasks return new ITaskTrigger[] { // At startup - new StartupTrigger (), + new StartupTrigger {DelayMs = 60000}, // Every so often new IntervalTrigger { Interval = TimeSpan.FromHours(24)} diff --git a/MediaBrowser.Common.Implementations/ScheduledTasks/Tasks/DeleteLogFileTask.cs b/MediaBrowser.Common.Implementations/ScheduledTasks/Tasks/DeleteLogFileTask.cs index e5c5638c0..3b0c02dc6 100644 --- a/MediaBrowser.Common.Implementations/ScheduledTasks/Tasks/DeleteLogFileTask.cs +++ b/MediaBrowser.Common.Implementations/ScheduledTasks/Tasks/DeleteLogFileTask.cs @@ -43,7 +43,7 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks.Tasks return new ITaskTrigger[] { // At startup - new StartupTrigger (), + new StartupTrigger {DelayMs = 30000}, // Every so often new IntervalTrigger { Interval = TimeSpan.FromHours(24)} diff --git a/MediaBrowser.Common.Implementations/ScheduledTasks/Tasks/PluginUpdateTask.cs b/MediaBrowser.Common.Implementations/ScheduledTasks/Tasks/PluginUpdateTask.cs index f70b849ee..e31fc4abe 100644 --- a/MediaBrowser.Common.Implementations/ScheduledTasks/Tasks/PluginUpdateTask.cs +++ b/MediaBrowser.Common.Implementations/ScheduledTasks/Tasks/PluginUpdateTask.cs @@ -41,7 +41,7 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks.Tasks return new ITaskTrigger[] { // At startup - new StartupTrigger (), + new StartupTrigger(), // Every so often new IntervalTrigger { Interval = TimeSpan.FromHours(24)} diff --git a/MediaBrowser.Common.Implementations/ScheduledTasks/Tasks/SystemUpdateTask.cs b/MediaBrowser.Common.Implementations/ScheduledTasks/Tasks/SystemUpdateTask.cs index 641d402bd..6a9443ad7 100644 --- a/MediaBrowser.Common.Implementations/ScheduledTasks/Tasks/SystemUpdateTask.cs +++ b/MediaBrowser.Common.Implementations/ScheduledTasks/Tasks/SystemUpdateTask.cs @@ -52,7 +52,7 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks.Tasks return new ITaskTrigger[] { // At startup - new StartupTrigger (), + new StartupTrigger(), // Every so often new IntervalTrigger { Interval = TimeSpan.FromHours(24)} diff --git a/MediaBrowser.Common/ScheduledTasks/StartupTrigger.cs b/MediaBrowser.Common/ScheduledTasks/StartupTrigger.cs index 6dc5c6b38..17e4628d0 100644 --- a/MediaBrowser.Common/ScheduledTasks/StartupTrigger.cs +++ b/MediaBrowser.Common/ScheduledTasks/StartupTrigger.cs @@ -8,6 +8,13 @@ namespace MediaBrowser.Common.ScheduledTasks /// public class StartupTrigger : ITaskTrigger { + public int DelayMs { get; set; } + + public StartupTrigger() + { + DelayMs = 3000; + } + /// /// Stars waiting for the trigger action /// @@ -16,7 +23,7 @@ namespace MediaBrowser.Common.ScheduledTasks { if (isApplicationStartup) { - await Task.Delay(3000).ConfigureAwait(false); + await Task.Delay(DelayMs).ConfigureAwait(false); OnTriggered(); } diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index 2013b926c..243d7fd2d 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -924,6 +924,18 @@ namespace MediaBrowser.Controller.Entities .Where(i => i != null); } + + /// + /// Gets the linked children. + /// + /// IEnumerable{BaseItem}. + public IEnumerable> GetLinkedChildrenInfos() + { + return LinkedChildren + .Select(i => new Tuple(i, GetLinkedChild(i))) + .Where(i => i.Item2 != null); + } + protected override async Task RefreshedOwnedItems(MetadataRefreshOptions options, List fileSystemChildren, CancellationToken cancellationToken) { var changesFound = false; diff --git a/MediaBrowser.Controller/Playlists/Playlist.cs b/MediaBrowser.Controller/Playlists/Playlist.cs index a2335b4bc..ec3e03339 100644 --- a/MediaBrowser.Controller/Playlists/Playlist.cs +++ b/MediaBrowser.Controller/Playlists/Playlist.cs @@ -22,9 +22,9 @@ namespace MediaBrowser.Controller.Playlists return GetPlayableItems(user); } - public IEnumerable GetManageableItems() + public IEnumerable> GetManageableItems() { - return GetPlaylistItems(MediaType, GetLinkedChildren(), null); + return GetLinkedChildrenInfos(); } private IEnumerable GetPlayableItems(User user) diff --git a/MediaBrowser.Model/Dto/BaseItemDto.cs b/MediaBrowser.Model/Dto/BaseItemDto.cs index 32bf4b816..fbe9664c0 100644 --- a/MediaBrowser.Model/Dto/BaseItemDto.cs +++ b/MediaBrowser.Model/Dto/BaseItemDto.cs @@ -29,6 +29,12 @@ namespace MediaBrowser.Model.Dto /// The id. public string Id { get; set; } + /// + /// Gets or sets the playlist item identifier. + /// + /// The playlist item identifier. + public string PlaylistItemId { get; set; } + /// /// Gets or sets the date created. /// diff --git a/MediaBrowser.Server.Implementations/Channels/RefreshChannelsScheduledTask.cs b/MediaBrowser.Server.Implementations/Channels/RefreshChannelsScheduledTask.cs index ee75e4d05..c6ecfc250 100644 --- a/MediaBrowser.Server.Implementations/Channels/RefreshChannelsScheduledTask.cs +++ b/MediaBrowser.Server.Implementations/Channels/RefreshChannelsScheduledTask.cs @@ -42,7 +42,7 @@ namespace MediaBrowser.Server.Implementations.Channels { return new ITaskTrigger[] { - new StartupTrigger(), + new StartupTrigger{DelayMs = 10000}, new SystemEventTrigger{ SystemEvent = SystemEvent.WakeFromSleep}, diff --git a/MediaBrowser.Server.Implementations/EntryPoints/ActivityLogEntryPoint.cs b/MediaBrowser.Server.Implementations/EntryPoints/ActivityLogEntryPoint.cs index 0e18fa465..b8290fda7 100644 --- a/MediaBrowser.Server.Implementations/EntryPoints/ActivityLogEntryPoint.cs +++ b/MediaBrowser.Server.Implementations/EntryPoints/ActivityLogEntryPoint.cs @@ -195,7 +195,8 @@ namespace MediaBrowser.Server.Implementations.EntryPoints { Name = string.Format(_localization.GetLocalizedString("FailedLoginAttemptWithUserName"), e.Argument.Username), Type = "AuthenticationFailed", - ShortOverview = string.Format(_localization.GetLocalizedString("LabelIpAddressValue"), e.Argument.RemoteEndPoint) + ShortOverview = string.Format(_localization.GetLocalizedString("LabelIpAddressValue"), e.Argument.RemoteEndPoint), + Severity = LogSeverity.Error }); } @@ -427,7 +428,8 @@ namespace MediaBrowser.Server.Implementations.EntryPoints Name = string.Format(_localization.GetLocalizedString("ScheduledTaskFailedWithName"), task.Name), Type = "ScheduledTaskFailed", Overview = string.Join(Environment.NewLine, vals.ToArray()), - ShortOverview = runningTime + ShortOverview = runningTime, + Severity = LogSeverity.Error }); } } diff --git a/MediaBrowser.Server.Implementations/Playlists/ManualPlaylistsFolder.cs b/MediaBrowser.Server.Implementations/Playlists/ManualPlaylistsFolder.cs index a87edde7b..e7e53181c 100644 --- a/MediaBrowser.Server.Implementations/Playlists/ManualPlaylistsFolder.cs +++ b/MediaBrowser.Server.Implementations/Playlists/ManualPlaylistsFolder.cs @@ -1,7 +1,7 @@ -using System.Collections.Generic; -using MediaBrowser.Common.Configuration; +using MediaBrowser.Common.Configuration; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Playlists; +using System.Collections.Generic; using System.IO; using System.Linq; diff --git a/MediaBrowser.Server.Implementations/Playlists/PlaylistManager.cs b/MediaBrowser.Server.Implementations/Playlists/PlaylistManager.cs index d46177352..3cdea0793 100644 --- a/MediaBrowser.Server.Implementations/Playlists/PlaylistManager.cs +++ b/MediaBrowser.Server.Implementations/Playlists/PlaylistManager.cs @@ -193,13 +193,14 @@ namespace MediaBrowser.Server.Implementations.Playlists throw new ArgumentException("No Playlist exists with the supplied Id"); } - var children = playlist.LinkedChildren.ToList(); + var children = playlist.GetManageableItems().ToList(); var idList = entryIds.ToList(); - var removals = children.Where(i => idList.Contains(i.Id)); + var removals = children.Where(i => idList.Contains(i.Item1.Id)); playlist.LinkedChildren = children.Except(removals) + .Select(i => i.Item1) .ToList(); await playlist.UpdateToRepository(ItemUpdateType.MetadataEdit, CancellationToken.None).ConfigureAwait(false);