implement removing from playlists

This commit is contained in:
Luke Pulverenti 2014-08-11 19:41:11 -04:00
parent 7bff666136
commit 9b92cc20f2
13 changed files with 51 additions and 15 deletions

View File

@ -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,

View File

@ -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)}

View File

@ -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)}

View File

@ -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)}

View File

@ -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)}

View File

@ -8,6 +8,13 @@ namespace MediaBrowser.Common.ScheduledTasks
/// </summary>
public class StartupTrigger : ITaskTrigger
{
public int DelayMs { get; set; }
public StartupTrigger()
{
DelayMs = 3000;
}
/// <summary>
/// Stars waiting for the trigger action
/// </summary>
@ -16,7 +23,7 @@ namespace MediaBrowser.Common.ScheduledTasks
{
if (isApplicationStartup)
{
await Task.Delay(3000).ConfigureAwait(false);
await Task.Delay(DelayMs).ConfigureAwait(false);
OnTriggered();
}

View File

@ -924,6 +924,18 @@ namespace MediaBrowser.Controller.Entities
.Where(i => i != null);
}
/// <summary>
/// Gets the linked children.
/// </summary>
/// <returns>IEnumerable{BaseItem}.</returns>
public IEnumerable<Tuple<LinkedChild,BaseItem>> GetLinkedChildrenInfos()
{
return LinkedChildren
.Select(i => new Tuple<LinkedChild,BaseItem>(i, GetLinkedChild(i)))
.Where(i => i.Item2 != null);
}
protected override async Task<bool> RefreshedOwnedItems(MetadataRefreshOptions options, List<FileSystemInfo> fileSystemChildren, CancellationToken cancellationToken)
{
var changesFound = false;

View File

@ -22,9 +22,9 @@ namespace MediaBrowser.Controller.Playlists
return GetPlayableItems(user);
}
public IEnumerable<BaseItem> GetManageableItems()
public IEnumerable<Tuple<LinkedChild, BaseItem>> GetManageableItems()
{
return GetPlaylistItems(MediaType, GetLinkedChildren(), null);
return GetLinkedChildrenInfos();
}
private IEnumerable<BaseItem> GetPlayableItems(User user)

View File

@ -29,6 +29,12 @@ namespace MediaBrowser.Model.Dto
/// <value>The id.</value>
public string Id { get; set; }
/// <summary>
/// Gets or sets the playlist item identifier.
/// </summary>
/// <value>The playlist item identifier.</value>
public string PlaylistItemId { get; set; }
/// <summary>
/// Gets or sets the date created.
/// </summary>

View File

@ -42,7 +42,7 @@ namespace MediaBrowser.Server.Implementations.Channels
{
return new ITaskTrigger[]
{
new StartupTrigger(),
new StartupTrigger{DelayMs = 10000},
new SystemEventTrigger{ SystemEvent = SystemEvent.WakeFromSleep},

View File

@ -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
});
}
}

View File

@ -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;

View File

@ -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);