2014-08-02 02:34:45 +00:00
|
|
|
|
using MediaBrowser.Controller.Entities;
|
2014-08-03 02:16:37 +00:00
|
|
|
|
using MediaBrowser.Model.Entities;
|
|
|
|
|
using MediaBrowser.Model.Querying;
|
|
|
|
|
using System;
|
2014-08-02 02:34:45 +00:00
|
|
|
|
using System.Collections.Generic;
|
2014-08-03 02:16:37 +00:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Runtime.Serialization;
|
2014-08-02 02:34:45 +00:00
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Controller.Playlists
|
|
|
|
|
{
|
|
|
|
|
public class Playlist : Folder
|
|
|
|
|
{
|
2014-08-03 02:16:37 +00:00
|
|
|
|
public string OwnerUserId { get; set; }
|
2014-08-02 02:34:45 +00:00
|
|
|
|
|
2014-08-03 02:16:37 +00:00
|
|
|
|
public override IEnumerable<BaseItem> GetChildren(User user, bool includeLinkedChildren)
|
2014-08-02 02:34:45 +00:00
|
|
|
|
{
|
2014-08-03 02:16:37 +00:00
|
|
|
|
return GetPlayableItems(user);
|
2014-08-02 02:34:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-08-03 02:16:37 +00:00
|
|
|
|
public override IEnumerable<BaseItem> GetRecursiveChildren(User user, bool includeLinkedChildren = true)
|
|
|
|
|
{
|
|
|
|
|
return GetPlayableItems(user);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IEnumerable<BaseItem> GetManageableItems()
|
|
|
|
|
{
|
2014-08-07 02:51:09 +00:00
|
|
|
|
return GetPlaylistItems(MediaType, GetLinkedChildren(), null);
|
2014-08-03 02:16:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private IEnumerable<BaseItem> GetPlayableItems(User user)
|
|
|
|
|
{
|
|
|
|
|
return GetPlaylistItems(MediaType, base.GetChildren(user, true), user);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static IEnumerable<BaseItem> GetPlaylistItems(string playlistMediaType, IEnumerable<BaseItem> inputItems, User user)
|
|
|
|
|
{
|
|
|
|
|
return inputItems.SelectMany(i =>
|
|
|
|
|
{
|
|
|
|
|
var folder = i as Folder;
|
|
|
|
|
|
|
|
|
|
if (folder != null)
|
|
|
|
|
{
|
2014-08-07 02:51:09 +00:00
|
|
|
|
var items = user == null
|
|
|
|
|
? folder.GetRecursiveChildren()
|
|
|
|
|
: folder.GetRecursiveChildren(user, true);
|
|
|
|
|
|
|
|
|
|
items = items
|
|
|
|
|
.Where(m => !m.IsFolder);
|
2014-08-03 02:16:37 +00:00
|
|
|
|
|
|
|
|
|
if (!folder.IsPreSorted)
|
|
|
|
|
{
|
|
|
|
|
items = LibraryManager.Sort(items, user, new[] { ItemSortBy.SortName }, SortOrder.Ascending);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return items;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new[] { i };
|
2014-08-07 02:51:09 +00:00
|
|
|
|
|
|
|
|
|
}).Where(m => string.Equals(m.MediaType, playlistMediaType, StringComparison.OrdinalIgnoreCase));
|
2014-08-03 02:16:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[IgnoreDataMember]
|
|
|
|
|
public override bool IsPreSorted
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string PlaylistMediaType { get; set; }
|
|
|
|
|
|
|
|
|
|
public override string MediaType
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return PlaylistMediaType;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetMediaType(string value)
|
|
|
|
|
{
|
|
|
|
|
PlaylistMediaType = value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool IsVisible(User user)
|
2014-08-02 02:34:45 +00:00
|
|
|
|
{
|
2014-08-03 02:16:37 +00:00
|
|
|
|
return base.IsVisible(user) && string.Equals(user.Id.ToString("N"), OwnerUserId);
|
2014-08-02 02:34:45 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|