The Free Software Media System - Server Backend & API
update notification styles
Luke Pulverentib4016ae07efa
diff --git a/MediaBrowser.Model/ApiClient/IApiClient.cs b/MediaBrowser.Model/ApiClient/IApiClient.csindex 02dce0f6b7..f30bb5dafb 100644--- a/MediaBrowser.Model/ApiClient/IApiClient.cs+++ b/MediaBrowser.Model/ApiClient/IApiClient.cs@@ -212,6 +212,13 @@ namespace MediaBrowser.Model.ApiClient/// <exception cref="ArgumentNullException">userId</exception>Task<BaseItemDto> GetRootFolderAsync(string userId);+ /// <summary>+ /// Gets the additional parts.+ /// </summary>+ /// <param name="itemId">The item identifier.</param>+ /// <returns>Task{BaseItemDto[]}.</returns>+ Task<BaseItemDto[]> GetAdditionalParts(string itemId);+/// <summary>/// Gets the users async./// </summary>diff --git a/MediaBrowser.Model/Channels/ChannelFeatures.cs b/MediaBrowser.Model/Channels/ChannelFeatures.csindex cec40d7f25..494ebe3a3c 100644--- a/MediaBrowser.Model/Channels/ChannelFeatures.cs+++ b/MediaBrowser.Model/Channels/ChannelFeatures.cs@@ -57,10 +57,10 @@ namespace MediaBrowser.Model.Channels{Name = 0,CommunityRating = 1,- ContentReleaseDate = 2,- DateAdded = 3,+ PremiereDate = 2,+ DateCreated = 3,Runtime = 4,- CommunityMostWatched = 5,- UserPlayCount = 6+ PlayCount = 5,+ CommunityPlayCount = 6}}diff --git a/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs b/MediaBrowser.Server.Implementations/Channels/ChannelManager.csindex acfc5228e8..335366077c 100644--- a/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs+++ b/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs@@ -1,4 +1,5 @@-using MediaBrowser.Common.Extensions;+using System.Globalization;+using MediaBrowser.Common.Extensions;using MediaBrowser.Common.IO;using MediaBrowser.Controller.Channels;using MediaBrowser.Controller.Configuration;@@ -299,8 +300,25 @@ namespace MediaBrowser.Server.Implementations.Channels? null: _userManager.GetUserById(new Guid(query.UserId));- var itemsResult = await GetChannelItems(channelProvider, user, query.FolderId, providerStartIndex, providerLimit, cancellationToken)- .ConfigureAwait(false);+ ChannelItemSortField? sortField = null;+ ChannelItemSortField parsedField;+ if (query.SortBy.Length == 1 &&+ Enum.TryParse(query.SortBy[0], true, out parsedField))+ {+ sortField = parsedField;+ }++ var sortDescending = query.SortOrder.HasValue && query.SortOrder.Value == SortOrder.Descending;++ var itemsResult = await GetChannelItems(channelProvider,+ user,+ query.FolderId,+ providerStartIndex,+ providerLimit,+ sortField,+ sortDescending,+ cancellationToken)+ .ConfigureAwait(false);var providerTotalRecordCount = providerLimit.HasValue ? itemsResult.TotalRecordCount : null;@@ -322,9 +340,16 @@ namespace MediaBrowser.Server.Implementations.Channels}private readonly SemaphoreSlim _resourcePool = new SemaphoreSlim(1, 1);- private async Task<ChannelItemResult> GetChannelItems(IChannel channel, User user, string folderId, int? startIndex, int? limit, CancellationToken cancellationToken)+ private async Task<ChannelItemResult> GetChannelItems(IChannel channel,+ User user,+ string folderId,+ int? startIndex,+ int? limit,+ ChannelItemSortField? sortField,+ bool sortDescending,+ CancellationToken cancellationToken){- var cachePath = GetChannelDataCachePath(channel, user, folderId);+ var cachePath = GetChannelDataCachePath(channel, user, folderId, sortField, sortDescending);try{@@ -376,7 +401,9 @@ namespace MediaBrowser.Server.Implementations.Channels{User = user,StartIndex = startIndex,- Limit = limit+ Limit = limit,+ SortBy = sortField,+ SortDescending = sortDescending};if (!string.IsNullOrWhiteSpace(folderId))@@ -415,7 +442,11 @@ namespace MediaBrowser.Server.Implementations.Channels}}- private string GetChannelDataCachePath(IChannel channel, User user, string folderId)+ private string GetChannelDataCachePath(IChannel channel,+ User user,+ string folderId,+ ChannelItemSortField? sortField,+ bool sortDescending){var channelId = GetInternalChannelId(channel.Name).ToString("N");@@ -423,7 +454,26 @@ namespace MediaBrowser.Server.Implementations.Channelsvar version = string.IsNullOrWhiteSpace(channel.DataVersion) ? "0" : channel.DataVersion;- return Path.Combine(_config.ApplicationPaths.CachePath, "channels", channelId, version, folderKey, user.Id.ToString("N") + ".json");+ var filename = user.Id.ToString("N");+ var hashfilename = false;++ if (sortField.HasValue)+ {+ filename += "-sortField-" + sortField.Value;+ hashfilename = true;+ }+ if (sortDescending)+ {+ filename += "-sortDescending";+ hashfilename = true;+ }++ if (hashfilename)+ {+ filename = filename.GetMD5().ToString("N");+ }++ return Path.Combine(_config.ApplicationPaths.CachePath, "channels", channelId, version, folderKey, filename + ".json");}private async Task<QueryResult<BaseItemDto>> GetReturnItems(IEnumerable<BaseItem> items, int? totalCountFromProvider, User user, ChannelItemQuery query, CancellationToken cancellationToken)diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.csindex caa058b96e..bc22c531c5 100644--- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs+++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs@@ -21,6 +21,7 @@ using System.IO;using System.Linq;using System.Threading;using System.Threading.Tasks;+using MediaBrowser.Model.Serialization;namespace MediaBrowser.Server.Implementations.LiveTv{@@ -37,6 +38,7 @@ namespace MediaBrowser.Server.Implementations.LiveTvprivate readonly IUserDataManager _userDataManager;private readonly ILibraryManager _libraryManager;private readonly ITaskManager _taskManager;+ private readonly IJsonSerializer _json;private readonly LiveTvDtoService _tvDtoService;@@ -51,7 +53,7 @@ namespace MediaBrowser.Server.Implementations.LiveTvprivate readonly SemaphoreSlim _refreshSemaphore = new SemaphoreSlim(1, 1);- public LiveTvManager(IServerConfigurationManager config, IFileSystem fileSystem, ILogger logger, IItemRepository itemRepo, IImageProcessor imageProcessor, IUserDataManager userDataManager, IDtoService dtoService, IUserManager userManager, ILibraryManager libraryManager, ITaskManager taskManager)+ public LiveTvManager(IServerConfigurationManager config, IFileSystem fileSystem, ILogger logger, IItemRepository itemRepo, IImageProcessor imageProcessor, IUserDataManager userDataManager, IDtoService dtoService, IUserManager userManager, ILibraryManager libraryManager, ITaskManager taskManager, IJsonSerializer json){_config = config;_fileSystem = fileSystem;@@ -60,6 +62,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv_userManager = userManager;_libraryManager = libraryManager;_taskManager = taskManager;+ _json = json;_userDataManager = userDataManager;_tvDtoService = new LiveTvDtoService(dtoService, userDataManager, imageProcessor, logger, _itemRepo);@@ -294,6 +297,8 @@ namespace MediaBrowser.Server.Implementations.LiveTvvar result = await service.GetRecordingStream(recording.Id, cancellationToken).ConfigureAwait(false);+ _logger.Debug("Live stream info: " + _json.SerializeToString(result));+if (!string.IsNullOrEmpty(result.Id)){_openStreams.AddOrUpdate(result.Id, result, (key, info) => result);@@ -327,6 +332,8 @@ namespace MediaBrowser.Server.Implementations.LiveTvvar result = await service.GetChannelStream(channel.ExternalId, cancellationToken).ConfigureAwait(false);+ _logger.Debug("Live stream info: " + _json.SerializeToString(result));+if (!string.IsNullOrEmpty(result.Id)){_openStreams.AddOrUpdate(result.Id, result, (key, info) => result);@@ -1525,6 +1532,9 @@ namespace MediaBrowser.Server.Implementations.LiveTvtry{await service.CloseLiveStream(id, cancellationToken).ConfigureAwait(false);++ LiveStreamInfo removed;+ _openStreams.TryRemove(id, out removed);}catch (Exception ex){diff --git a/MediaBrowser.ServerApplication/ApplicationHost.cs b/MediaBrowser.ServerApplication/ApplicationHost.csindex d6c3a7e9f9..5797ecc977 100644--- a/MediaBrowser.ServerApplication/ApplicationHost.cs+++ b/MediaBrowser.ServerApplication/ApplicationHost.cs@@ -531,7 +531,7 @@ namespace MediaBrowser.ServerApplicationvar collectionManager = new CollectionManager(LibraryManager, FileSystemManager, LibraryMonitor);RegisterSingleInstance<ICollectionManager>(collectionManager);- LiveTvManager = new LiveTvManager(ServerConfigurationManager, FileSystemManager, Logger, ItemRepository, ImageProcessor, UserDataManager, DtoService, UserManager, LibraryManager, TaskManager);+ LiveTvManager = new LiveTvManager(ServerConfigurationManager, FileSystemManager, Logger, ItemRepository, ImageProcessor, UserDataManager, DtoService, UserManager, LibraryManager, TaskManager, JsonSerializer);RegisterSingleInstance(LiveTvManager);NotificationManager = new NotificationManager(LogManager, UserManager, ServerConfigurationManager);diff --git a/Nuget/MediaBrowser.Common.Internal.nuspec b/Nuget/MediaBrowser.Common.Internal.nuspecindex e401d699d0..b4d2dbdc53 100644--- a/Nuget/MediaBrowser.Common.Internal.nuspec+++ b/Nuget/MediaBrowser.Common.Internal.nuspec@@ -2,7 +2,7 @@<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd"><metadata><id>MediaBrowser.Common.Internal</id>- <version>3.0.384</version>+ <version>3.0.386</version><title>MediaBrowser.Common.Internal</title><authors>Luke</authors><owners>ebr,Luke,scottisafool</owners>@@ -12,7 +12,7 @@<description>Contains common components shared by Media Browser Theater and Media Browser Server. Not intended for plugin developer consumption.</description><copyright>Copyright © Media Browser 2013</copyright><dependencies>- <dependency id="MediaBrowser.Common" version="3.0.384" />+ <dependency id="MediaBrowser.Common" version="3.0.386" /><dependency id="NLog" version="2.1.0" /><dependency id="SimpleInjector" version="2.5.0" /><dependency id="sharpcompress" version="0.10.2" />diff --git a/Nuget/MediaBrowser.Common.nuspec b/Nuget/MediaBrowser.Common.nuspecindex 4ea543d85c..fa5c667514 100644--- a/Nuget/MediaBrowser.Common.nuspec+++ b/Nuget/MediaBrowser.Common.nuspec@@ -2,7 +2,7 @@<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd"><metadata><id>MediaBrowser.Common</id>- <version>3.0.384</version>+ <version>3.0.386</version><title>MediaBrowser.Common</title><authors>Media Browser Team</authors><owners>ebr,Luke,scottisafool</owners>diff --git a/Nuget/MediaBrowser.Server.Core.nuspec b/Nuget/MediaBrowser.Server.Core.nuspecindex 60ed34067b..3c025207a2 100644--- a/Nuget/MediaBrowser.Server.Core.nuspec+++ b/Nuget/MediaBrowser.Server.Core.nuspec@@ -2,7 +2,7 @@<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"><metadata><id>MediaBrowser.Server.Core</id>- <version>3.0.384</version>+ <version>3.0.386</version><title>Media Browser.Server.Core</title><authors>Media Browser Team</authors><owners>ebr,Luke,scottisafool</owners>@@ -12,7 +12,7 @@<description>Contains core components required to build plugins for Media Browser Server.</description><copyright>Copyright © Media Browser 2013</copyright><dependencies>- <dependency id="MediaBrowser.Common" version="3.0.384" />+ <dependency id="MediaBrowser.Common" version="3.0.386" /></dependencies></metadata><files>