update view generation
This commit is contained in:
parent
2c52712c4e
commit
9a3bc0a2e7
|
@ -26,6 +26,8 @@ namespace MediaBrowser.Api.UserLibrary
|
||||||
|
|
||||||
[ApiMember(Name = "IncludeExternalContent", Description = "Whether or not to include external views such as channels or live tv", IsRequired = true, DataType = "boolean", ParameterType = "query", Verb = "POST")]
|
[ApiMember(Name = "IncludeExternalContent", Description = "Whether or not to include external views such as channels or live tv", IsRequired = true, DataType = "boolean", ParameterType = "query", Verb = "POST")]
|
||||||
public bool? IncludeExternalContent { get; set; }
|
public bool? IncludeExternalContent { get; set; }
|
||||||
|
|
||||||
|
public string PresetViews { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
[Route("/Users/{UserId}/SpecialViewOptions", "GET")]
|
[Route("/Users/{UserId}/SpecialViewOptions", "GET")]
|
||||||
|
@ -75,6 +77,18 @@ namespace MediaBrowser.Api.UserLibrary
|
||||||
query.IncludeExternalContent = request.IncludeExternalContent.Value;
|
query.IncludeExternalContent = request.IncludeExternalContent.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(request.PresetViews))
|
||||||
|
{
|
||||||
|
query.PresetViews = request.PresetViews.Split(',');
|
||||||
|
}
|
||||||
|
|
||||||
|
var app = AuthorizationContext.GetAuthorizationInfo(Request).Client ?? string.Empty;
|
||||||
|
if (app.IndexOf("emby rt", StringComparison.OrdinalIgnoreCase) != -1)
|
||||||
|
{
|
||||||
|
query.PresetViews = new[] { CollectionType.Music, CollectionType.Movies, CollectionType.TvShows };
|
||||||
|
}
|
||||||
|
//query.PresetViews = new[] { CollectionType.Music, CollectionType.Movies, CollectionType.TvShows };
|
||||||
|
|
||||||
var folders = await _userViewManager.GetUserViews(query, CancellationToken.None).ConfigureAwait(false);
|
var folders = await _userViewManager.GetUserViews(query, CancellationToken.None).ConfigureAwait(false);
|
||||||
|
|
||||||
var dtoOptions = GetDtoOptions(request);
|
var dtoOptions = GetDtoOptions(request);
|
||||||
|
|
|
@ -26,6 +26,7 @@ namespace MediaBrowser.Dlna.ContentDirectory
|
||||||
private readonly ILocalizationManager _localization;
|
private readonly ILocalizationManager _localization;
|
||||||
private readonly IChannelManager _channelManager;
|
private readonly IChannelManager _channelManager;
|
||||||
private readonly IMediaSourceManager _mediaSourceManager;
|
private readonly IMediaSourceManager _mediaSourceManager;
|
||||||
|
private readonly IUserViewManager _userViewManager;
|
||||||
|
|
||||||
public ContentDirectory(IDlnaManager dlna,
|
public ContentDirectory(IDlnaManager dlna,
|
||||||
IUserDataManager userDataManager,
|
IUserDataManager userDataManager,
|
||||||
|
@ -34,7 +35,7 @@ namespace MediaBrowser.Dlna.ContentDirectory
|
||||||
IServerConfigurationManager config,
|
IServerConfigurationManager config,
|
||||||
IUserManager userManager,
|
IUserManager userManager,
|
||||||
ILogger logger,
|
ILogger logger,
|
||||||
IHttpClient httpClient, ILocalizationManager localization, IChannelManager channelManager, IMediaSourceManager mediaSourceManager)
|
IHttpClient httpClient, ILocalizationManager localization, IChannelManager channelManager, IMediaSourceManager mediaSourceManager, IUserViewManager userViewManager)
|
||||||
: base(logger, httpClient)
|
: base(logger, httpClient)
|
||||||
{
|
{
|
||||||
_dlna = dlna;
|
_dlna = dlna;
|
||||||
|
@ -46,6 +47,7 @@ namespace MediaBrowser.Dlna.ContentDirectory
|
||||||
_localization = localization;
|
_localization = localization;
|
||||||
_channelManager = channelManager;
|
_channelManager = channelManager;
|
||||||
_mediaSourceManager = mediaSourceManager;
|
_mediaSourceManager = mediaSourceManager;
|
||||||
|
_userViewManager = userViewManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int SystemUpdateId
|
private int SystemUpdateId
|
||||||
|
@ -86,7 +88,8 @@ namespace MediaBrowser.Dlna.ContentDirectory
|
||||||
_config,
|
_config,
|
||||||
_localization,
|
_localization,
|
||||||
_channelManager,
|
_channelManager,
|
||||||
_mediaSourceManager)
|
_mediaSourceManager,
|
||||||
|
_userViewManager)
|
||||||
.ProcessControlRequest(request);
|
.ProcessControlRequest(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
|
using MediaBrowser.Model.Library;
|
||||||
|
|
||||||
namespace MediaBrowser.Dlna.ContentDirectory
|
namespace MediaBrowser.Dlna.ContentDirectory
|
||||||
{
|
{
|
||||||
|
@ -34,6 +35,7 @@ namespace MediaBrowser.Dlna.ContentDirectory
|
||||||
private readonly IUserDataManager _userDataManager;
|
private readonly IUserDataManager _userDataManager;
|
||||||
private readonly IServerConfigurationManager _config;
|
private readonly IServerConfigurationManager _config;
|
||||||
private readonly User _user;
|
private readonly User _user;
|
||||||
|
private readonly IUserViewManager _userViewManager;
|
||||||
|
|
||||||
private const string NS_DC = "http://purl.org/dc/elements/1.1/";
|
private const string NS_DC = "http://purl.org/dc/elements/1.1/";
|
||||||
private const string NS_DIDL = "urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/";
|
private const string NS_DIDL = "urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/";
|
||||||
|
@ -47,7 +49,7 @@ namespace MediaBrowser.Dlna.ContentDirectory
|
||||||
|
|
||||||
private readonly DeviceProfile _profile;
|
private readonly DeviceProfile _profile;
|
||||||
|
|
||||||
public ControlHandler(ILogger logger, ILibraryManager libraryManager, DeviceProfile profile, string serverAddress, string accessToken, IImageProcessor imageProcessor, IUserDataManager userDataManager, User user, int systemUpdateId, IServerConfigurationManager config, ILocalizationManager localization, IChannelManager channelManager, IMediaSourceManager mediaSourceManager)
|
public ControlHandler(ILogger logger, ILibraryManager libraryManager, DeviceProfile profile, string serverAddress, string accessToken, IImageProcessor imageProcessor, IUserDataManager userDataManager, User user, int systemUpdateId, IServerConfigurationManager config, ILocalizationManager localization, IChannelManager channelManager, IMediaSourceManager mediaSourceManager, IUserViewManager userViewManager)
|
||||||
: base(config, logger)
|
: base(config, logger)
|
||||||
{
|
{
|
||||||
_libraryManager = libraryManager;
|
_libraryManager = libraryManager;
|
||||||
|
@ -55,6 +57,7 @@ namespace MediaBrowser.Dlna.ContentDirectory
|
||||||
_user = user;
|
_user = user;
|
||||||
_systemUpdateId = systemUpdateId;
|
_systemUpdateId = systemUpdateId;
|
||||||
_channelManager = channelManager;
|
_channelManager = channelManager;
|
||||||
|
_userViewManager = userViewManager;
|
||||||
_profile = profile;
|
_profile = profile;
|
||||||
_config = config;
|
_config = config;
|
||||||
|
|
||||||
|
@ -450,16 +453,32 @@ namespace MediaBrowser.Dlna.ContentDirectory
|
||||||
sortOrders.Add(ItemSortBy.SortName);
|
sortOrders.Add(ItemSortBy.SortName);
|
||||||
}
|
}
|
||||||
|
|
||||||
var queryResult = await folder.GetItems(new InternalItemsQuery
|
QueryResult<BaseItem> queryResult;
|
||||||
{
|
|
||||||
Limit = limit,
|
|
||||||
StartIndex = startIndex,
|
|
||||||
SortBy = sortOrders.ToArray(),
|
|
||||||
SortOrder = sort.SortOrder,
|
|
||||||
User = user,
|
|
||||||
Filter = FilterUnsupportedContent
|
|
||||||
|
|
||||||
}).ConfigureAwait(false);
|
if (folder is UserRootFolder)
|
||||||
|
{
|
||||||
|
var views = await _userViewManager.GetUserViews(new UserViewQuery { UserId = user.Id.ToString("N"), PresetViews = new[] { CollectionType.Movies, CollectionType.TvShows, CollectionType.Music } }, CancellationToken.None)
|
||||||
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
|
queryResult = new QueryResult<BaseItem>
|
||||||
|
{
|
||||||
|
Items = views.Cast<BaseItem>().ToArray()
|
||||||
|
};
|
||||||
|
queryResult.TotalRecordCount = queryResult.Items.Length;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
queryResult = await folder.GetItems(new InternalItemsQuery
|
||||||
|
{
|
||||||
|
Limit = limit,
|
||||||
|
StartIndex = startIndex,
|
||||||
|
SortBy = sortOrders.ToArray(),
|
||||||
|
SortOrder = sort.SortOrder,
|
||||||
|
User = user,
|
||||||
|
Filter = FilterUnsupportedContent
|
||||||
|
|
||||||
|
}).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
|
||||||
var options = _config.GetDlnaConfiguration();
|
var options = _config.GetDlnaConfiguration();
|
||||||
|
|
||||||
|
|
|
@ -21,9 +21,12 @@ namespace MediaBrowser.Model.Library
|
||||||
/// <value><c>true</c> if [include hidden]; otherwise, <c>false</c>.</value>
|
/// <value><c>true</c> if [include hidden]; otherwise, <c>false</c>.</value>
|
||||||
public bool IncludeHidden { get; set; }
|
public bool IncludeHidden { get; set; }
|
||||||
|
|
||||||
|
public string[] PresetViews { get; set; }
|
||||||
|
|
||||||
public UserViewQuery()
|
public UserViewQuery()
|
||||||
{
|
{
|
||||||
IncludeExternalContent = true;
|
IncludeExternalContent = true;
|
||||||
|
PresetViews = new string[] { };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,14 +82,18 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||||
{
|
{
|
||||||
list.Add(await GetUserView(folder.Id, folder.Name, folderViewType, true, string.Empty, user, cancellationToken).ConfigureAwait(false));
|
list.Add(await GetUserView(folder.Id, folder.Name, folderViewType, true, string.Empty, user, cancellationToken).ConfigureAwait(false));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (enableUserViews)
|
if (enableUserViews)
|
||||||
{
|
{
|
||||||
if (plainFolderIds.Contains(folder.Id) && UserView.IsEligibleForEnhancedView(folderViewType))
|
if (plainFolderIds.Contains(folder.Id) && UserView.IsEligibleForEnhancedView(folderViewType))
|
||||||
{
|
{
|
||||||
list.Add(await GetUserView(folder, folderViewType, false, string.Empty, cancellationToken).ConfigureAwait(false));
|
list.Add(await GetUserView(folder, folderViewType, false, string.Empty, cancellationToken).ConfigureAwait(false));
|
||||||
}
|
}
|
||||||
|
else if (query.PresetViews.Contains(folderViewType ?? string.Empty, StringComparer.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
list.Add(await GetUserView(folder, folderViewType, true, string.Empty, cancellationToken).ConfigureAwait(false));
|
||||||
|
}
|
||||||
else if (_config.Configuration.EnableSharedCollectionViewImage || UserView.EnableOriginalFolder(folderViewType))
|
else if (_config.Configuration.EnableSharedCollectionViewImage || UserView.EnableOriginalFolder(folderViewType))
|
||||||
{
|
{
|
||||||
list.Add(folder);
|
list.Add(folder);
|
||||||
|
@ -110,6 +114,10 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||||
{
|
{
|
||||||
list.Add(await GetUserView(folder.Id, folder.Name, folderViewType, false, string.Empty, user, cancellationToken).ConfigureAwait(false));
|
list.Add(await GetUserView(folder.Id, folder.Name, folderViewType, false, string.Empty, user, cancellationToken).ConfigureAwait(false));
|
||||||
}
|
}
|
||||||
|
else if (query.PresetViews.Contains(folderViewType ?? string.Empty, StringComparer.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
list.Add(await GetUserView(folder, folderViewType, true, string.Empty, cancellationToken).ConfigureAwait(false));
|
||||||
|
}
|
||||||
else if (_config.Configuration.EnableSharedCollectionViewImage || UserView.EnableOriginalFolder(folderViewType))
|
else if (_config.Configuration.EnableSharedCollectionViewImage || UserView.EnableOriginalFolder(folderViewType))
|
||||||
{
|
{
|
||||||
list.Add(folder);
|
list.Add(folder);
|
||||||
|
@ -130,7 +138,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||||
|
|
||||||
if (parents.Count > 0)
|
if (parents.Count > 0)
|
||||||
{
|
{
|
||||||
list.Add(await GetUserView(parents, CollectionType.TvShows, string.Empty, user, enableUserViews, cancellationToken).ConfigureAwait(false));
|
list.Add(await GetUserView(parents, CollectionType.TvShows, string.Empty, user, query.PresetViews, cancellationToken).ConfigureAwait(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
parents = foldersWithViewTypes.Where(i => string.Equals(i.GetViewType(user), CollectionType.Movies, StringComparison.OrdinalIgnoreCase) || string.IsNullOrWhiteSpace(i.GetViewType(user)))
|
parents = foldersWithViewTypes.Where(i => string.Equals(i.GetViewType(user), CollectionType.Movies, StringComparison.OrdinalIgnoreCase) || string.IsNullOrWhiteSpace(i.GetViewType(user)))
|
||||||
|
@ -138,7 +146,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||||
|
|
||||||
if (parents.Count > 0)
|
if (parents.Count > 0)
|
||||||
{
|
{
|
||||||
list.Add(await GetUserView(parents, CollectionType.Movies, string.Empty, user, enableUserViews, cancellationToken).ConfigureAwait(false));
|
list.Add(await GetUserView(parents, CollectionType.Movies, string.Empty, user, query.PresetViews, cancellationToken).ConfigureAwait(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user.Configuration.DisplayFoldersView)
|
if (user.Configuration.DisplayFoldersView)
|
||||||
|
@ -183,6 +191,18 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||||
{
|
{
|
||||||
var index = orders.IndexOf(i.Id.ToString("N"));
|
var index = orders.IndexOf(i.Id.ToString("N"));
|
||||||
|
|
||||||
|
if (index == -1)
|
||||||
|
{
|
||||||
|
var view = i as UserView;
|
||||||
|
if (view != null)
|
||||||
|
{
|
||||||
|
if (view.DisplayParentId != Guid.Empty)
|
||||||
|
{
|
||||||
|
index = orders.IndexOf(view.DisplayParentId.ToString("N"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return index == -1 ? int.MaxValue : index;
|
return index == -1 ? int.MaxValue : index;
|
||||||
})
|
})
|
||||||
.ThenBy(sorted.IndexOf)
|
.ThenBy(sorted.IndexOf)
|
||||||
|
@ -203,11 +223,11 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||||
return GetUserSubView(name, parentId, type, sortName, cancellationToken);
|
return GetUserSubView(name, parentId, type, sortName, cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<Folder> GetUserView(List<ICollectionFolder> parents, string viewType, string sortName, User user, bool enableUserViews, CancellationToken cancellationToken)
|
private async Task<Folder> GetUserView(List<ICollectionFolder> parents, string viewType, string sortName, User user, string[] presetViews, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
if (parents.Count == 1 && parents.All(i => string.Equals((enableUserViews ? i.GetViewType(user) : i.CollectionType), viewType, StringComparison.OrdinalIgnoreCase)))
|
if (parents.Count == 1 && parents.All(i => string.Equals(i.GetViewType(user), viewType, StringComparison.OrdinalIgnoreCase)))
|
||||||
{
|
{
|
||||||
if (enableUserViews || _config.Configuration.EnableSharedCollectionViewImage)
|
if (!presetViews.Contains(viewType, StringComparer.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
return (Folder)parents[0];
|
return (Folder)parents[0];
|
||||||
}
|
}
|
||||||
|
|
|
@ -503,7 +503,7 @@ namespace MediaBrowser.Server.Startup.Common
|
||||||
UserViewManager = new UserViewManager(LibraryManager, LocalizationManager, UserManager, ChannelManager, LiveTvManager, ServerConfigurationManager);
|
UserViewManager = new UserViewManager(LibraryManager, LocalizationManager, UserManager, ChannelManager, LiveTvManager, ServerConfigurationManager);
|
||||||
RegisterSingleInstance(UserViewManager);
|
RegisterSingleInstance(UserViewManager);
|
||||||
|
|
||||||
var contentDirectory = new ContentDirectory(dlnaManager, UserDataManager, ImageProcessor, LibraryManager, ServerConfigurationManager, UserManager, LogManager.GetLogger("UpnpContentDirectory"), HttpClient, LocalizationManager, ChannelManager, MediaSourceManager);
|
var contentDirectory = new ContentDirectory(dlnaManager, UserDataManager, ImageProcessor, LibraryManager, ServerConfigurationManager, UserManager, LogManager.GetLogger("UpnpContentDirectory"), HttpClient, LocalizationManager, ChannelManager, MediaSourceManager, UserViewManager);
|
||||||
RegisterSingleInstance<IContentDirectory>(contentDirectory);
|
RegisterSingleInstance<IContentDirectory>(contentDirectory);
|
||||||
|
|
||||||
var mediaRegistrar = new MediaReceiverRegistrar(LogManager.GetLogger("MediaReceiverRegistrar"), HttpClient, ServerConfigurationManager);
|
var mediaRegistrar = new MediaReceiverRegistrar(LogManager.GetLogger("MediaReceiverRegistrar"), HttpClient, ServerConfigurationManager);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user