From 0690b4f2e09608b9f25ebb8ef9a325b57135e529 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 1 Oct 2014 20:28:16 -0400 Subject: Add user cinema mode setting --- .../Activity/ActivityManager.cs | 21 +- .../Channels/ChannelManager.cs | 51 ++- .../Configuration/ServerConfigurationManager.cs | 1 - .../Dto/DtoService.cs | 1 - .../EntryPoints/ActivityLogEntryPoint.cs | 29 +- .../Intros/DefaultIntroProvider.cs | 2 +- .../Library/Resolvers/Movies/MovieResolver.cs | 4 +- .../Localization/JavaScript/ar.json | 16 +- .../Localization/JavaScript/hr.json | 20 +- .../Localization/JavaScript/it.json | 28 +- .../Localization/JavaScript/nb.json | 24 +- .../Localization/Server/ar.json | 25 +- .../Localization/Server/ca.json | 7 +- .../Localization/Server/cs.json | 7 +- .../Localization/Server/da.json | 7 +- .../Localization/Server/de.json | 7 +- .../Localization/Server/el.json | 7 +- .../Localization/Server/en_GB.json | 7 +- .../Localization/Server/en_US.json | 7 +- .../Localization/Server/es.json | 7 +- .../Localization/Server/es_MX.json | 7 +- .../Localization/Server/fr.json | 7 +- .../Localization/Server/he.json | 7 +- .../Localization/Server/hr.json | 395 +++++++++++---------- .../Localization/Server/it.json | 11 +- .../Localization/Server/kk.json | 11 +- .../Localization/Server/ko.json | 7 +- .../Localization/Server/ms.json | 7 +- .../Localization/Server/nb.json | 39 +- .../Localization/Server/nl.json | 7 +- .../Localization/Server/pl.json | 7 +- .../Localization/Server/pt_BR.json | 7 +- .../Localization/Server/pt_PT.json | 7 +- .../Localization/Server/ru.json | 11 +- .../Localization/Server/server.json | 5 +- .../Localization/Server/sv.json | 7 +- .../Localization/Server/tr.json | 7 +- .../Localization/Server/vi.json | 7 +- .../Localization/Server/zh_TW.json | 7 +- 39 files changed, 525 insertions(+), 316 deletions(-) (limited to 'MediaBrowser.Server.Implementations') diff --git a/MediaBrowser.Server.Implementations/Activity/ActivityManager.cs b/MediaBrowser.Server.Implementations/Activity/ActivityManager.cs index 7b123bad2d..0904c92f1c 100644 --- a/MediaBrowser.Server.Implementations/Activity/ActivityManager.cs +++ b/MediaBrowser.Server.Implementations/Activity/ActivityManager.cs @@ -1,10 +1,12 @@ using MediaBrowser.Common.Events; using MediaBrowser.Controller.Activity; +using MediaBrowser.Controller.Library; using MediaBrowser.Model.Activity; using MediaBrowser.Model.Events; using MediaBrowser.Model.Logging; using MediaBrowser.Model.Querying; using System; +using System.Linq; using System.Threading.Tasks; namespace MediaBrowser.Server.Implementations.Activity @@ -15,11 +17,13 @@ namespace MediaBrowser.Server.Implementations.Activity private readonly IActivityRepository _repo; private readonly ILogger _logger; + private readonly IUserManager _userManager; - public ActivityManager(ILogger logger, IActivityRepository repo) + public ActivityManager(ILogger logger, IActivityRepository repo, IUserManager userManager) { _logger = logger; _repo = repo; + _userManager = userManager; } public async Task Create(ActivityLogEntry entry) @@ -34,7 +38,20 @@ namespace MediaBrowser.Server.Implementations.Activity public QueryResult GetActivityLogEntries(DateTime? minDate, int? startIndex, int? limit) { - return _repo.GetActivityLogEntries(minDate, startIndex, limit); + var result = _repo.GetActivityLogEntries(minDate, startIndex, limit); + + foreach (var item in result.Items.Where(i => !string.IsNullOrWhiteSpace(i.UserId))) + { + var user = _userManager.GetUserById(item.UserId); + + if (user != null) + { + var dto = _userManager.GetUserDto(user); + item.UserPrimaryImageTag = dto.PrimaryImageTag; + } + } + + return result; } } } diff --git a/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs b/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs index d3b5fc0c37..8fb6bb4343 100644 --- a/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs +++ b/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs @@ -869,7 +869,56 @@ namespace MediaBrowser.Server.Implementations.Channels private async Task GetAllItems(IIndexableChannel indexable, IChannel channel, InternalAllChannelMediaQuery query, CancellationToken cancellationToken) { - return await indexable.GetAllMedia(query, cancellationToken).ConfigureAwait(false); + var cacheLength = CacheLength; + var folderId = _jsonSerializer.SerializeToString(query).GetMD5().ToString("N"); + var cachePath = GetChannelDataCachePath(channel, query.UserId, folderId, null, false); + + try + { + if (_fileSystem.GetLastWriteTimeUtc(cachePath).Add(cacheLength) > DateTime.UtcNow) + { + return _jsonSerializer.DeserializeFromFile(cachePath); + } + } + catch (FileNotFoundException) + { + + } + catch (DirectoryNotFoundException) + { + + } + + await _resourcePool.WaitAsync(cancellationToken).ConfigureAwait(false); + + try + { + try + { + if (_fileSystem.GetLastWriteTimeUtc(cachePath).Add(cacheLength) > DateTime.UtcNow) + { + return _jsonSerializer.DeserializeFromFile(cachePath); + } + } + catch (FileNotFoundException) + { + + } + catch (DirectoryNotFoundException) + { + + } + + var result = await indexable.GetAllMedia(query, cancellationToken).ConfigureAwait(false); + + CacheResponse(result, cachePath); + + return result; + } + finally + { + _resourcePool.Release(); + } } public async Task> GetChannelItemsInternal(ChannelItemQuery query, IProgress progress, CancellationToken cancellationToken) diff --git a/MediaBrowser.Server.Implementations/Configuration/ServerConfigurationManager.cs b/MediaBrowser.Server.Implementations/Configuration/ServerConfigurationManager.cs index 031ca85f99..ce97b89076 100644 --- a/MediaBrowser.Server.Implementations/Configuration/ServerConfigurationManager.cs +++ b/MediaBrowser.Server.Implementations/Configuration/ServerConfigurationManager.cs @@ -221,7 +221,6 @@ namespace MediaBrowser.Server.Implementations.Configuration DisableMetadataService(typeof(Series), Configuration, service); DisableMetadataService(typeof(MusicVideo), Configuration, service); DisableMetadataService(typeof(Trailer), Configuration, service); - DisableMetadataService(typeof(AdultVideo), Configuration, service); DisableMetadataService(typeof(Video), Configuration, service); } diff --git a/MediaBrowser.Server.Implementations/Dto/DtoService.cs b/MediaBrowser.Server.Implementations/Dto/DtoService.cs index 4d4aa24843..0c06d1b18e 100644 --- a/MediaBrowser.Server.Implementations/Dto/DtoService.cs +++ b/MediaBrowser.Server.Implementations/Dto/DtoService.cs @@ -215,7 +215,6 @@ namespace MediaBrowser.Server.Implementations.Dto { // This populates them all and covers Genre, Person, Studio, Year - dto.AdultVideoCount = taggedItems.Count(i => i is AdultVideo); dto.AlbumCount = taggedItems.Count(i => i is MusicAlbum); dto.EpisodeCount = taggedItems.Count(i => i is Episode); dto.GameCount = taggedItems.Count(i => i is Game); diff --git a/MediaBrowser.Server.Implementations/EntryPoints/ActivityLogEntryPoint.cs b/MediaBrowser.Server.Implementations/EntryPoints/ActivityLogEntryPoint.cs index fb1010f1b4..06b07a90e5 100644 --- a/MediaBrowser.Server.Implementations/EntryPoints/ActivityLogEntryPoint.cs +++ b/MediaBrowser.Server.Implementations/EntryPoints/ActivityLogEntryPoint.cs @@ -129,13 +129,14 @@ namespace MediaBrowser.Server.Implementations.EntryPoints return; } - var username = e.Users.First().Name; + var user = e.Users.First(); CreateLogEntry(new ActivityLogEntry { - Name = string.Format(_localization.GetLocalizedString("UserStoppedPlayingItemWithValues"), username, item.Name), + Name = string.Format(_localization.GetLocalizedString("UserStoppedPlayingItemWithValues"), user.Name, item.Name), Type = "PlaybackStopped", - ShortOverview = string.Format(_localization.GetLocalizedString("AppDeviceValues"), e.ClientName, e.DeviceName) + ShortOverview = string.Format(_localization.GetLocalizedString("AppDeviceValues"), e.ClientName, e.DeviceName), + UserId = user.Id.ToString("N") }); } @@ -161,13 +162,14 @@ namespace MediaBrowser.Server.Implementations.EntryPoints return; } - var username = e.Users.First().Name; + var user = e.Users.First(); CreateLogEntry(new ActivityLogEntry { - Name = string.Format(_localization.GetLocalizedString("UserStartedPlayingItemWithValues"), username, item.Name), + Name = string.Format(_localization.GetLocalizedString("UserStartedPlayingItemWithValues"), user.Name, item.Name), Type = "PlaybackStart", - ShortOverview = string.Format(_localization.GetLocalizedString("AppDeviceValues"), e.ClientName, e.DeviceName) + ShortOverview = string.Format(_localization.GetLocalizedString("AppDeviceValues"), e.ClientName, e.DeviceName), + UserId = user.Id.ToString("N") }); } @@ -192,7 +194,8 @@ namespace MediaBrowser.Server.Implementations.EntryPoints { Name = name, Type = "SessionEnded", - ShortOverview = string.Format(_localization.GetLocalizedString("LabelIpAddressValue"), session.RemoteEndPoint) + ShortOverview = string.Format(_localization.GetLocalizedString("LabelIpAddressValue"), session.RemoteEndPoint), + UserId = (session.UserId.HasValue ? session.UserId.Value.ToString("N") : null) }); } @@ -255,7 +258,8 @@ namespace MediaBrowser.Server.Implementations.EntryPoints CreateLogEntry(new ActivityLogEntry { Name = string.Format(_localization.GetLocalizedString("UserConfigurationUpdatedWithName"), e.Argument.Name), - Type = "UserConfigurationUpdated" + Type = "UserConfigurationUpdated", + UserId = e.Argument.Id.ToString("N") }); } @@ -273,7 +277,8 @@ namespace MediaBrowser.Server.Implementations.EntryPoints CreateLogEntry(new ActivityLogEntry { Name = string.Format(_localization.GetLocalizedString("UserPasswordChangedWithName"), e.Argument.Name), - Type = "UserPasswordChanged" + Type = "UserPasswordChanged", + UserId = e.Argument.Id.ToString("N") }); } @@ -282,7 +287,8 @@ namespace MediaBrowser.Server.Implementations.EntryPoints CreateLogEntry(new ActivityLogEntry { Name = string.Format(_localization.GetLocalizedString("UserCreatedWithName"), e.Argument.Name), - Type = "UserCreated" + Type = "UserCreated", + UserId = e.Argument.Id.ToString("N") }); } @@ -318,7 +324,8 @@ namespace MediaBrowser.Server.Implementations.EntryPoints { Name = name, Type = "SessionStarted", - ShortOverview = string.Format(_localization.GetLocalizedString("LabelIpAddressValue"), session.RemoteEndPoint) + ShortOverview = string.Format(_localization.GetLocalizedString("LabelIpAddressValue"), session.RemoteEndPoint), + UserId = (session.UserId.HasValue ? session.UserId.Value.ToString("N") : null) }); } diff --git a/MediaBrowser.Server.Implementations/Intros/DefaultIntroProvider.cs b/MediaBrowser.Server.Implementations/Intros/DefaultIntroProvider.cs index 4060bec3d2..d8d26a9bc4 100644 --- a/MediaBrowser.Server.Implementations/Intros/DefaultIntroProvider.cs +++ b/MediaBrowser.Server.Implementations/Intros/DefaultIntroProvider.cs @@ -140,7 +140,7 @@ namespace MediaBrowser.Server.Implementations.Intros })); } - var customIntros = config.EnableCustomIntro ? + var customIntros = !string.IsNullOrWhiteSpace(config.CustomIntroPath) ? GetCustomIntros(item) : new List(); diff --git a/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs b/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs index 51835c1ba6..7f15dce2d1 100644 --- a/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs +++ b/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs @@ -92,7 +92,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies if (string.Equals(collectionType, CollectionType.AdultVideos, StringComparison.OrdinalIgnoreCase)) { - return FindMovie(args.Path, args.Parent, args.FileSystemChildren.ToList(), args.DirectoryService, true, false); + return FindMovie