Browse Source

update notification styles

Luke Pulverenti 11 years ago
parent
commit
b4016ae07e

+ 7 - 0
MediaBrowser.Model/ApiClient/IApiClient.cs

@@ -212,6 +212,13 @@ namespace MediaBrowser.Model.ApiClient
         /// <exception cref="ArgumentNullException">userId</exception>
         /// <exception cref="ArgumentNullException">userId</exception>
         Task<BaseItemDto> GetRootFolderAsync(string userId);
         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>
         /// <summary>
         /// Gets the users async.
         /// Gets the users async.
         /// </summary>
         /// </summary>

+ 4 - 4
MediaBrowser.Model/Channels/ChannelFeatures.cs

@@ -57,10 +57,10 @@ namespace MediaBrowser.Model.Channels
     {
     {
         Name = 0,
         Name = 0,
         CommunityRating = 1,
         CommunityRating = 1,
-        ContentReleaseDate = 2,
-        DateAdded = 3,
+        PremiereDate = 2,
+        DateCreated = 3,
         Runtime = 4,
         Runtime = 4,
-        CommunityMostWatched = 5,
-        UserPlayCount = 6
+        PlayCount = 5,
+        CommunityPlayCount = 6
     }
     }
 }
 }

+ 58 - 8
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.Common.IO;
 using MediaBrowser.Controller.Channels;
 using MediaBrowser.Controller.Channels;
 using MediaBrowser.Controller.Configuration;
 using MediaBrowser.Controller.Configuration;
@@ -299,8 +300,25 @@ namespace MediaBrowser.Server.Implementations.Channels
                 ? null
                 ? null
                 : _userManager.GetUserById(new Guid(query.UserId));
                 : _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;
             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 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
             try
             {
             {
@@ -376,7 +401,9 @@ namespace MediaBrowser.Server.Implementations.Channels
                 {
                 {
                     User = user,
                     User = user,
                     StartIndex = startIndex,
                     StartIndex = startIndex,
-                    Limit = limit
+                    Limit = limit,
+                    SortBy = sortField,
+                    SortDescending = sortDescending
                 };
                 };
 
 
                 if (!string.IsNullOrWhiteSpace(folderId))
                 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");
             var channelId = GetInternalChannelId(channel.Name).ToString("N");
 
 
@@ -423,7 +454,26 @@ namespace MediaBrowser.Server.Implementations.Channels
 
 
             var version = string.IsNullOrWhiteSpace(channel.DataVersion) ? "0" : channel.DataVersion;
             var 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)
         private async Task<QueryResult<BaseItemDto>> GetReturnItems(IEnumerable<BaseItem> items, int? totalCountFromProvider, User user, ChannelItemQuery query, CancellationToken cancellationToken)

+ 11 - 1
MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs

@@ -21,6 +21,7 @@ using System.IO;
 using System.Linq;
 using System.Linq;
 using System.Threading;
 using System.Threading;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
+using MediaBrowser.Model.Serialization;
 
 
 namespace MediaBrowser.Server.Implementations.LiveTv
 namespace MediaBrowser.Server.Implementations.LiveTv
 {
 {
@@ -37,6 +38,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
         private readonly IUserDataManager _userDataManager;
         private readonly IUserDataManager _userDataManager;
         private readonly ILibraryManager _libraryManager;
         private readonly ILibraryManager _libraryManager;
         private readonly ITaskManager _taskManager;
         private readonly ITaskManager _taskManager;
+        private readonly IJsonSerializer _json;
 
 
         private readonly LiveTvDtoService _tvDtoService;
         private readonly LiveTvDtoService _tvDtoService;
 
 
@@ -51,7 +53,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
 
 
         private readonly SemaphoreSlim _refreshSemaphore = new SemaphoreSlim(1, 1);
         private 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;
             _config = config;
             _fileSystem = fileSystem;
             _fileSystem = fileSystem;
@@ -60,6 +62,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
             _userManager = userManager;
             _userManager = userManager;
             _libraryManager = libraryManager;
             _libraryManager = libraryManager;
             _taskManager = taskManager;
             _taskManager = taskManager;
+            _json = json;
             _userDataManager = userDataManager;
             _userDataManager = userDataManager;
 
 
             _tvDtoService = new LiveTvDtoService(dtoService, userDataManager, imageProcessor, logger, _itemRepo);
             _tvDtoService = new LiveTvDtoService(dtoService, userDataManager, imageProcessor, logger, _itemRepo);
@@ -294,6 +297,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv
 
 
                 var result = await service.GetRecordingStream(recording.Id, cancellationToken).ConfigureAwait(false);
                 var result = await service.GetRecordingStream(recording.Id, cancellationToken).ConfigureAwait(false);
 
 
+                _logger.Debug("Live stream info: " + _json.SerializeToString(result));
+                
                 if (!string.IsNullOrEmpty(result.Id))
                 if (!string.IsNullOrEmpty(result.Id))
                 {
                 {
                     _openStreams.AddOrUpdate(result.Id, result, (key, info) => result);
                     _openStreams.AddOrUpdate(result.Id, result, (key, info) => result);
@@ -327,6 +332,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv
 
 
                 var result = await service.GetChannelStream(channel.ExternalId, cancellationToken).ConfigureAwait(false);
                 var result = await service.GetChannelStream(channel.ExternalId, cancellationToken).ConfigureAwait(false);
 
 
+                _logger.Debug("Live stream info: " + _json.SerializeToString(result));
+
                 if (!string.IsNullOrEmpty(result.Id))
                 if (!string.IsNullOrEmpty(result.Id))
                 {
                 {
                     _openStreams.AddOrUpdate(result.Id, result, (key, info) => result);
                     _openStreams.AddOrUpdate(result.Id, result, (key, info) => result);
@@ -1525,6 +1532,9 @@ namespace MediaBrowser.Server.Implementations.LiveTv
             try
             try
             {
             {
                 await service.CloseLiveStream(id, cancellationToken).ConfigureAwait(false);
                 await service.CloseLiveStream(id, cancellationToken).ConfigureAwait(false);
+
+                LiveStreamInfo removed;
+                _openStreams.TryRemove(id, out removed);
             }
             }
             catch (Exception ex)
             catch (Exception ex)
             {
             {

+ 1 - 1
MediaBrowser.ServerApplication/ApplicationHost.cs

@@ -531,7 +531,7 @@ namespace MediaBrowser.ServerApplication
             var collectionManager = new CollectionManager(LibraryManager, FileSystemManager, LibraryMonitor);
             var collectionManager = new CollectionManager(LibraryManager, FileSystemManager, LibraryMonitor);
             RegisterSingleInstance<ICollectionManager>(collectionManager);
             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);
             RegisterSingleInstance(LiveTvManager);
 
 
             NotificationManager = new NotificationManager(LogManager, UserManager, ServerConfigurationManager);
             NotificationManager = new NotificationManager(LogManager, UserManager, ServerConfigurationManager);

+ 2 - 2
Nuget/MediaBrowser.Common.Internal.nuspec

@@ -2,7 +2,7 @@
 <package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
 <package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
     <metadata>
     <metadata>
         <id>MediaBrowser.Common.Internal</id>
         <id>MediaBrowser.Common.Internal</id>
-        <version>3.0.384</version>
+        <version>3.0.386</version>
         <title>MediaBrowser.Common.Internal</title>
         <title>MediaBrowser.Common.Internal</title>
         <authors>Luke</authors>
         <authors>Luke</authors>
         <owners>ebr,Luke,scottisafool</owners>
         <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>
         <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>
         <copyright>Copyright © Media Browser 2013</copyright>
         <dependencies>
         <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="NLog" version="2.1.0" />
             <dependency id="SimpleInjector" version="2.5.0" />
             <dependency id="SimpleInjector" version="2.5.0" />
             <dependency id="sharpcompress" version="0.10.2" />
             <dependency id="sharpcompress" version="0.10.2" />

+ 1 - 1
Nuget/MediaBrowser.Common.nuspec

@@ -2,7 +2,7 @@
 <package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
 <package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
     <metadata>
     <metadata>
         <id>MediaBrowser.Common</id>
         <id>MediaBrowser.Common</id>
-        <version>3.0.384</version>
+        <version>3.0.386</version>
         <title>MediaBrowser.Common</title>
         <title>MediaBrowser.Common</title>
         <authors>Media Browser Team</authors>
         <authors>Media Browser Team</authors>
         <owners>ebr,Luke,scottisafool</owners>
         <owners>ebr,Luke,scottisafool</owners>

+ 2 - 2
Nuget/MediaBrowser.Server.Core.nuspec

@@ -2,7 +2,7 @@
 <package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
 <package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
     <metadata>
     <metadata>
         <id>MediaBrowser.Server.Core</id>
         <id>MediaBrowser.Server.Core</id>
-        <version>3.0.384</version>
+        <version>3.0.386</version>
         <title>Media Browser.Server.Core</title>
         <title>Media Browser.Server.Core</title>
         <authors>Media Browser Team</authors>
         <authors>Media Browser Team</authors>
         <owners>ebr,Luke,scottisafool</owners>
         <owners>ebr,Luke,scottisafool</owners>
@@ -12,7 +12,7 @@
         <description>Contains core components required to build plugins for Media Browser Server.</description>
         <description>Contains core components required to build plugins for Media Browser Server.</description>
         <copyright>Copyright © Media Browser 2013</copyright>
         <copyright>Copyright © Media Browser 2013</copyright>
         <dependencies>
         <dependencies>
-            <dependency id="MediaBrowser.Common" version="3.0.384" />
+            <dependency id="MediaBrowser.Common" version="3.0.386" />
         </dependencies>
         </dependencies>
     </metadata>
     </metadata>
     <files>
     <files>