From d8d5dd487326dd3fccf4e9f30cd8f7e3783fcfda Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 12 Jan 2015 22:46:44 -0500 Subject: make channel access opt-in rather than opt out --- MediaBrowser.Controller/Channels/Channel.cs | 2 +- MediaBrowser.Controller/Entities/BaseItem.cs | 11 +++++++++-- MediaBrowser.Controller/Entities/User.cs | 2 +- MediaBrowser.Controller/IServerApplicationPaths.cs | 6 ------ MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs | 7 ++++++- MediaBrowser.Controller/LiveTv/LiveTvChannel.cs | 5 +++++ MediaBrowser.Controller/LiveTv/LiveTvProgram.cs | 5 +++++ MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs | 5 +++++ MediaBrowser.Controller/MediaEncoding/MediaStreamSelector.cs | 12 +++++------- MediaBrowser.Controller/Session/ISessionController.cs | 10 ++++++++++ MediaBrowser.Controller/Session/ISessionManager.cs | 11 +++++++++++ MediaBrowser.Controller/Session/SessionInfo.cs | 5 +++++ 12 files changed, 63 insertions(+), 18 deletions(-) (limited to 'MediaBrowser.Controller') diff --git a/MediaBrowser.Controller/Channels/Channel.cs b/MediaBrowser.Controller/Channels/Channel.cs index 5a9fc33227..6ee6fe0062 100644 --- a/MediaBrowser.Controller/Channels/Channel.cs +++ b/MediaBrowser.Controller/Channels/Channel.cs @@ -14,7 +14,7 @@ namespace MediaBrowser.Controller.Channels public override bool IsVisible(User user) { - if (user.Policy.BlockedChannels.Contains(Id.ToString("N"), StringComparer.OrdinalIgnoreCase)) + if (!user.Policy.EnableAllChannels && !user.Policy.EnabledChannels.Contains(Id.ToString("N"), StringComparer.OrdinalIgnoreCase)) { return false; } diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index ee562d8b49..6a30df7fe8 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -379,7 +379,14 @@ namespace MediaBrowser.Controller.Entities public string GetInternalMetadataPath() { - return GetInternalMetadataPath(ConfigurationManager.ApplicationPaths.InternalMetadataPath); + var basePath = ConfigurationManager.ApplicationPaths.InternalMetadataPath; + + if (ConfigurationManager.Configuration.EnableLibraryMetadataSubFolder) + { + basePath = System.IO.Path.Combine(basePath, "library"); + } + + return GetInternalMetadataPath(basePath); } protected virtual string GetInternalMetadataPath(string basePath) @@ -1458,7 +1465,7 @@ namespace MediaBrowser.Controller.Entities currentFile.Attributes &= ~FileAttributes.Hidden; } - currentFile.Delete(); + FileSystem.DeleteFile(currentFile.FullName); } return UpdateToRepository(ItemUpdateType.ImageUpdate, CancellationToken.None); diff --git a/MediaBrowser.Controller/Entities/User.cs b/MediaBrowser.Controller/Entities/User.cs index 626afcfdfe..869c30ba88 100644 --- a/MediaBrowser.Controller/Entities/User.cs +++ b/MediaBrowser.Controller/Entities/User.cs @@ -177,7 +177,7 @@ namespace MediaBrowser.Controller.Entities // Exceptions will be thrown if these paths already exist if (Directory.Exists(newConfigDirectory)) { - Directory.Delete(newConfigDirectory, true); + FileSystem.DeleteDirectory(newConfigDirectory, true); } if (Directory.Exists(oldConfigurationDirectory)) diff --git a/MediaBrowser.Controller/IServerApplicationPaths.cs b/MediaBrowser.Controller/IServerApplicationPaths.cs index e3438c3d25..c07934d0b1 100644 --- a/MediaBrowser.Controller/IServerApplicationPaths.cs +++ b/MediaBrowser.Controller/IServerApplicationPaths.cs @@ -59,12 +59,6 @@ namespace MediaBrowser.Controller /// The game genre path. string GameGenrePath { get; } - /// - /// Gets the artists path. - /// - /// The artists path. - string ArtistsPath { get; } - /// /// Gets the path to the Studio directory /// diff --git a/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs b/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs index b95d67ad82..f29204689f 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs +++ b/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs @@ -1,8 +1,8 @@ using MediaBrowser.Controller.Entities.Audio; using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Entities; -using System.Linq; using MediaBrowser.Model.Users; +using System.Linq; namespace MediaBrowser.Controller.LiveTv { @@ -83,5 +83,10 @@ namespace MediaBrowser.Controller.LiveTv { return config.BlockUnratedItems.Contains(UnratedItem.LiveTvProgram); } + + protected override string GetInternalMetadataPath(string basePath) + { + return System.IO.Path.Combine(basePath, "livetv", Id.ToString("N")); + } } } diff --git a/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs b/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs index de72accff8..459ead16cb 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs +++ b/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs @@ -145,5 +145,10 @@ namespace MediaBrowser.Controller.LiveTv return list; } + + protected override string GetInternalMetadataPath(string basePath) + { + return System.IO.Path.Combine(basePath, "livetv", Id.ToString("N"), "metadata"); + } } } diff --git a/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs b/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs index 29b23a551e..74cf950d42 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs +++ b/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs @@ -204,5 +204,10 @@ namespace MediaBrowser.Controller.LiveTv { return config.BlockUnratedItems.Contains(UnratedItem.LiveTvProgram); } + + protected override string GetInternalMetadataPath(string basePath) + { + return System.IO.Path.Combine(basePath, "livetv", Id.ToString("N")); + } } } diff --git a/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs b/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs index 6fc985643a..91edc06c11 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs +++ b/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs @@ -83,5 +83,10 @@ namespace MediaBrowser.Controller.LiveTv { return config.BlockUnratedItems.Contains(UnratedItem.LiveTvProgram); } + + protected override string GetInternalMetadataPath(string basePath) + { + return System.IO.Path.Combine(basePath, "livetv", Id.ToString("N")); + } } } diff --git a/MediaBrowser.Controller/MediaEncoding/MediaStreamSelector.cs b/MediaBrowser.Controller/MediaEncoding/MediaStreamSelector.cs index 4a807df7ac..b18651a68f 100644 --- a/MediaBrowser.Controller/MediaEncoding/MediaStreamSelector.cs +++ b/MediaBrowser.Controller/MediaEncoding/MediaStreamSelector.cs @@ -38,7 +38,8 @@ namespace MediaBrowser.Controller.MediaEncoding SubtitlePlaybackMode mode, string audioTrackLanguage) { - streams = GetSortedStreams(streams, MediaStreamType.Subtitle, preferredLanguages).ToList(); + streams = GetSortedStreams(streams, MediaStreamType.Subtitle, preferredLanguages) + .ToList(); var full = streams.Where(s => !s.IsForced); @@ -81,11 +82,9 @@ namespace MediaBrowser.Controller.MediaEncoding private static IEnumerable GetSortedStreams(IEnumerable streams, MediaStreamType type, List languagePreferences) { - var orderStreams = streams - .Where(i => i.Type == type); - // Give some preferance to external text subs for better performance - return orderStreams.OrderBy(i => + return streams.Where(i => i.Type == type) + .OrderBy(i => { var index = languagePreferences.FindIndex(l => string.Equals(i.Language, l, StringComparison.OrdinalIgnoreCase)); @@ -94,8 +93,7 @@ namespace MediaBrowser.Controller.MediaEncoding .ThenBy(i => i.IsDefault) .ThenBy(i => i.IsTextSubtitleStream) .ThenBy(i => i.IsExternal) - .ThenBy(i => i.Index) - .ToList(); + .ThenBy(i => i.Index); } } } diff --git a/MediaBrowser.Controller/Session/ISessionController.cs b/MediaBrowser.Controller/Session/ISessionController.cs index d6dd7698e6..a4badee473 100644 --- a/MediaBrowser.Controller/Session/ISessionController.cs +++ b/MediaBrowser.Controller/Session/ISessionController.cs @@ -105,5 +105,15 @@ namespace MediaBrowser.Controller.Session /// The cancellation token. /// Task. Task SendServerRestartNotification(CancellationToken cancellationToken); + + /// + /// Sends the message. + /// + /// + /// The name. + /// The data. + /// The cancellation token. + /// Task. + Task SendMessage(string name, T data, CancellationToken cancellationToken); } } diff --git a/MediaBrowser.Controller/Session/ISessionManager.cs b/MediaBrowser.Controller/Session/ISessionManager.cs index f0272b3350..1f273a3ee0 100644 --- a/MediaBrowser.Controller/Session/ISessionManager.cs +++ b/MediaBrowser.Controller/Session/ISessionManager.cs @@ -170,6 +170,17 @@ namespace MediaBrowser.Controller.Session /// Task. Task SendPlaystateCommand(string controllingSessionId, string sessionId, PlaystateRequest command, CancellationToken cancellationToken); + /// + /// Sends the message to user sessions. + /// + /// + /// The user identifier. + /// The name. + /// The data. + /// The cancellation token. + /// Task. + Task SendMessageToUserSessions(string userId, string name, T data, CancellationToken cancellationToken); + /// /// Sends the restart required message. /// diff --git a/MediaBrowser.Controller/Session/SessionInfo.cs b/MediaBrowser.Controller/Session/SessionInfo.cs index d8a2464d64..078d4d70ff 100644 --- a/MediaBrowser.Controller/Session/SessionInfo.cs +++ b/MediaBrowser.Controller/Session/SessionInfo.cs @@ -160,6 +160,11 @@ namespace MediaBrowser.Controller.Session } } + public bool ContainsUser(string userId) + { + return ContainsUser(new Guid(userId)); + } + public bool ContainsUser(Guid userId) { return (UserId ?? Guid.Empty) == userId || AdditionalUsers.Any(i => userId == new Guid(i.UserId)); -- cgit v1.2.3 From 0e02e0559d3873a35ca2ec911b3c0b714a7611ea Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 16 Jan 2015 23:29:53 -0500 Subject: sync updates --- MediaBrowser.Api/ApiEntryPoint.cs | 3 +- MediaBrowser.Api/Playback/BaseStreamingService.cs | 2 +- MediaBrowser.Api/Playback/Hls/HlsSegmentService.cs | 8 +- MediaBrowser.Api/Playback/Hls/VideoHlsService.cs | 3 +- MediaBrowser.Api/Sync/SyncService.cs | 30 ++- MediaBrowser.Controller/IServerApplicationHost.cs | 4 +- .../MediaEncoding/EncodingJobOptions.cs | 1 + MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs | 7 +- .../MediaBrowser.Model.Portable.csproj | 3 + .../MediaBrowser.Model.net35.csproj | 3 + MediaBrowser.Model/ApiClient/IApiClient.cs | 9 + MediaBrowser.Model/Dlna/StreamInfo.cs | 3 +- MediaBrowser.Model/Dlna/SubtitleStreamInfo.cs | 1 + MediaBrowser.Model/MediaBrowser.Model.csproj | 1 + MediaBrowser.Model/Sync/ItemFIleInfo.cs | 7 +- MediaBrowser.Model/Sync/SyncDialogOptions.cs | 4 +- MediaBrowser.Model/Sync/SyncHelper.cs | 36 ++-- MediaBrowser.Model/Sync/SyncJobItem.cs | 22 ++- MediaBrowser.Model/Sync/SyncOptions.cs | 8 +- MediaBrowser.Model/Sync/SyncParameter.cs | 12 ++ MediaBrowser.Model/Sync/SyncedItem.cs | 11 ++ .../MediaBrowser.Server.Implementations.csproj | 1 + .../Session/SessionManager.cs | 18 +- .../Sync/SyncConfig.cs | 29 +++ .../Sync/SyncJobProcessor.cs | 207 ++++++++++++++++++--- .../Sync/SyncManager.cs | 44 +++-- .../Sync/SyncRepository.cs | 48 ++++- .../Sync/SyncScheduledTask.cs | 12 +- .../ApplicationHost.cs | 4 +- Nuget/MediaBrowser.Common.Internal.nuspec | 4 +- Nuget/MediaBrowser.Common.nuspec | 2 +- Nuget/MediaBrowser.Model.Signed.nuspec | 2 +- Nuget/MediaBrowser.Server.Core.nuspec | 4 +- 33 files changed, 437 insertions(+), 116 deletions(-) create mode 100644 MediaBrowser.Model/Sync/SyncParameter.cs create mode 100644 MediaBrowser.Server.Implementations/Sync/SyncConfig.cs (limited to 'MediaBrowser.Controller') diff --git a/MediaBrowser.Api/ApiEntryPoint.cs b/MediaBrowser.Api/ApiEntryPoint.cs index a9b43090a2..ef415ec57c 100644 --- a/MediaBrowser.Api/ApiEntryPoint.cs +++ b/MediaBrowser.Api/ApiEntryPoint.cs @@ -5,7 +5,6 @@ using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Plugins; using MediaBrowser.Controller.Session; using MediaBrowser.Model.Configuration; -using MediaBrowser.Model.Dlna; using MediaBrowser.Model.Logging; using MediaBrowser.Model.Session; using System; @@ -89,7 +88,7 @@ namespace MediaBrowser.Api /// private void DeleteEncodedMediaCache() { - var path = Path.Combine(_config.ApplicationPaths.TranscodingTempPath, EncodingContext.Streaming.ToString().ToLower()); + var path = _config.ApplicationPaths.TranscodingTempPath; foreach (var file in Directory.EnumerateFiles(path, "*", SearchOption.AllDirectories) .ToList()) diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index 2a0c5e01f3..84dd0c1e8d 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -119,7 +119,7 @@ namespace MediaBrowser.Api.Playback /// System.String. private string GetOutputFilePath(StreamState state) { - var folder = Path.Combine(ServerConfigurationManager.ApplicationPaths.TranscodingTempPath, EncodingContext.Streaming.ToString().ToLower()); + var folder = ServerConfigurationManager.ApplicationPaths.TranscodingTempPath; var outputFileExtension = GetOutputFileExtension(state); diff --git a/MediaBrowser.Api/Playback/Hls/HlsSegmentService.cs b/MediaBrowser.Api/Playback/Hls/HlsSegmentService.cs index 14045b3a56..9f80fcd0ad 100644 --- a/MediaBrowser.Api/Playback/Hls/HlsSegmentService.cs +++ b/MediaBrowser.Api/Playback/Hls/HlsSegmentService.cs @@ -1,10 +1,6 @@ using MediaBrowser.Controller; -using MediaBrowser.Model.Dlna; using ServiceStack; -using System; using System.IO; -using System.Linq; -using System.Threading.Tasks; namespace MediaBrowser.Api.Playback.Hls { @@ -66,7 +62,7 @@ namespace MediaBrowser.Api.Playback.Hls { var file = request.PlaylistId + Path.GetExtension(Request.PathInfo); - file = Path.Combine(_appPaths.TranscodingTempPath, EncodingContext.Streaming.ToString().ToLower(), file); + file = Path.Combine(_appPaths.TranscodingTempPath, file); return ResultFactory.GetStaticFileResult(Request, file, FileShare.ReadWrite); } @@ -85,7 +81,7 @@ namespace MediaBrowser.Api.Playback.Hls { var file = request.SegmentId + Path.GetExtension(Request.PathInfo); - file = Path.Combine(_appPaths.TranscodingTempPath, EncodingContext.Streaming.ToString().ToLower(), file); + file = Path.Combine(_appPaths.TranscodingTempPath, file); return ResultFactory.GetStaticFileResult(Request, file, FileShare.ReadWrite); } diff --git a/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs b/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs index d786b51b3a..de845c88d8 100644 --- a/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs +++ b/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs @@ -5,7 +5,6 @@ using MediaBrowser.Controller.Dlna; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.LiveTv; using MediaBrowser.Controller.MediaEncoding; -using MediaBrowser.Model.Dlna; using MediaBrowser.Model.IO; using ServiceStack; using System; @@ -71,7 +70,7 @@ namespace MediaBrowser.Api.Playback.Hls { var file = request.SegmentId + Path.GetExtension(Request.PathInfo); - file = Path.Combine(ServerConfigurationManager.ApplicationPaths.TranscodingTempPath, EncodingContext.Streaming.ToString().ToLower(), file); + file = Path.Combine(ServerConfigurationManager.ApplicationPaths.TranscodingTempPath, file); return ResultFactory.GetStaticFileResult(Request, file); } diff --git a/MediaBrowser.Api/Sync/SyncService.cs b/MediaBrowser.Api/Sync/SyncService.cs index a7467c12f1..8d5ec824f8 100644 --- a/MediaBrowser.Api/Sync/SyncService.cs +++ b/MediaBrowser.Api/Sync/SyncService.cs @@ -2,7 +2,6 @@ using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Net; using MediaBrowser.Controller.Sync; -using MediaBrowser.Model.Dto; using MediaBrowser.Model.Querying; using MediaBrowser.Model.Sync; using MediaBrowser.Model.Users; @@ -85,6 +84,16 @@ namespace MediaBrowser.Api.Sync public string Id { get; set; } } + [Route("/Sync/JobItems/{Id}/AdditionalFiles", "GET", Summary = "Gets a sync job item file")] + public class GetSyncJobItemAdditionalFile + { + [ApiMember(Name = "Id", Description = "Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")] + public string Id { get; set; } + + [ApiMember(Name = "Name", Description = "Name", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "GET")] + public string Name { get; set; } + } + [Route("/Sync/OfflineActions", "POST", Summary = "Reports an action that occurred while offline.")] public class ReportOfflineActions : List, IReturnVoid { @@ -243,5 +252,24 @@ namespace MediaBrowser.Api.Sync Task.WaitAll(task); } + + public object Get(GetSyncJobItemAdditionalFile request) + { + var jobItem = _syncManager.GetJobItem(request.Id); + + if (jobItem.Status != SyncJobItemStatus.Transferring) + { + throw new ArgumentException("The job item is not yet ready for transfer."); + } + + var file = jobItem.AdditionalFiles.FirstOrDefault(i => string.Equals(i.Name, request.Name, StringComparison.OrdinalIgnoreCase)); + + if (file == null) + { + throw new ArgumentException("Sync job additional file not found."); + } + + return ToStaticFileResult(file.Path); + } } } diff --git a/MediaBrowser.Controller/IServerApplicationHost.cs b/MediaBrowser.Controller/IServerApplicationHost.cs index d1a9b386cc..76eb9fceb0 100644 --- a/MediaBrowser.Controller/IServerApplicationHost.cs +++ b/MediaBrowser.Controller/IServerApplicationHost.cs @@ -1,7 +1,7 @@ -using System.Collections.Generic; -using MediaBrowser.Common; +using MediaBrowser.Common; using MediaBrowser.Model.System; using System; +using System.Collections.Generic; namespace MediaBrowser.Controller { diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingJobOptions.cs b/MediaBrowser.Controller/MediaEncoding/EncodingJobOptions.cs index a988c2f974..ad9ab90a03 100644 --- a/MediaBrowser.Controller/MediaEncoding/EncodingJobOptions.cs +++ b/MediaBrowser.Controller/MediaEncoding/EncodingJobOptions.cs @@ -5,6 +5,7 @@ namespace MediaBrowser.Controller.MediaEncoding public class EncodingJobOptions { public string OutputContainer { get; set; } + public string OutputDirectory { get; set; } public long? StartTimeTicks { get; set; } public int? Width { get; set; } diff --git a/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs index 4db4cd4277..4dc522f05c 100644 --- a/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs +++ b/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs @@ -280,13 +280,14 @@ namespace MediaBrowser.MediaEncoding.Encoder private string GetOutputFilePath(EncodingJob state) { - var folder = ConfigurationManager.ApplicationPaths.TranscodingTempPath; + var folder = string.IsNullOrWhiteSpace(state.Options.OutputDirectory) ? + ConfigurationManager.ApplicationPaths.TranscodingTempPath : + state.Options.OutputDirectory; var outputFileExtension = GetOutputFileExtension(state); - var context = state.Options.Context; var filename = state.Id + (outputFileExtension ?? string.Empty).ToLower(); - return Path.Combine(folder, context.ToString().ToLower(), filename); + return Path.Combine(folder, filename); } protected virtual string GetOutputFileExtension(EncodingJob state) diff --git a/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj b/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj index c49e3e303f..de60a3e834 100644 --- a/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj +++ b/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj @@ -1094,6 +1094,9 @@ Sync\SyncOptions.cs + + Sync\SyncParameter.cs + Sync\SyncQuality.cs diff --git a/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj b/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj index d8a29e8da4..1cc1aac094 100644 --- a/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj +++ b/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj @@ -1053,6 +1053,9 @@ Sync\SyncOptions.cs + + Sync\SyncParameter.cs + Sync\SyncQuality.cs diff --git a/MediaBrowser.Model/ApiClient/IApiClient.cs b/MediaBrowser.Model/ApiClient/IApiClient.cs index bcba9230ff..e8535278bb 100644 --- a/MediaBrowser.Model/ApiClient/IApiClient.cs +++ b/MediaBrowser.Model/ApiClient/IApiClient.cs @@ -1413,6 +1413,15 @@ namespace MediaBrowser.Model.ApiClient /// Task<Stream>. Task GetSyncJobItemFile(string id, CancellationToken cancellationToken); + /// + /// Gets the synchronize job item additional file. + /// + /// The identifier. + /// The name. + /// The cancellation token. + /// Task<Stream>. + Task GetSyncJobItemAdditionalFile(string id, string name, CancellationToken cancellationToken); + /// /// Opens the web socket. /// diff --git a/MediaBrowser.Model/Dlna/StreamInfo.cs b/MediaBrowser.Model/Dlna/StreamInfo.cs index 22eb0cf6ce..acd2658a8c 100644 --- a/MediaBrowser.Model/Dlna/StreamInfo.cs +++ b/MediaBrowser.Model/Dlna/StreamInfo.cs @@ -212,7 +212,8 @@ namespace MediaBrowser.Model.Dlna IsForced = stream.IsForced, Language = stream.Language, Name = stream.Language ?? "Unknown", - Format = SubtitleFormat + Format = SubtitleFormat, + Index = stream.Index }); } diff --git a/MediaBrowser.Model/Dlna/SubtitleStreamInfo.cs b/MediaBrowser.Model/Dlna/SubtitleStreamInfo.cs index 1600408d60..a7a8da3ba2 100644 --- a/MediaBrowser.Model/Dlna/SubtitleStreamInfo.cs +++ b/MediaBrowser.Model/Dlna/SubtitleStreamInfo.cs @@ -7,5 +7,6 @@ namespace MediaBrowser.Model.Dlna public string Name { get; set; } public bool IsForced { get; set; } public string Format { get; set; } + public int Index { get; set; } } } \ No newline at end of file diff --git a/MediaBrowser.Model/MediaBrowser.Model.csproj b/MediaBrowser.Model/MediaBrowser.Model.csproj index 2a1b0b6593..599e4a9021 100644 --- a/MediaBrowser.Model/MediaBrowser.Model.csproj +++ b/MediaBrowser.Model/MediaBrowser.Model.csproj @@ -385,6 +385,7 @@ + diff --git a/MediaBrowser.Model/Sync/ItemFIleInfo.cs b/MediaBrowser.Model/Sync/ItemFIleInfo.cs index b110af6b5a..e023572fd2 100644 --- a/MediaBrowser.Model/Sync/ItemFIleInfo.cs +++ b/MediaBrowser.Model/Sync/ItemFIleInfo.cs @@ -23,6 +23,11 @@ namespace MediaBrowser.Model.Sync /// Gets or sets the type of the image. /// /// The type of the image. - public ImageType ImageType { get; set; } + public ImageType? ImageType { get; set; } + /// + /// Gets or sets the index. + /// + /// The index. + public int Index { get; set; } } } diff --git a/MediaBrowser.Model/Sync/SyncDialogOptions.cs b/MediaBrowser.Model/Sync/SyncDialogOptions.cs index 0154b16ec1..304e10ccc4 100644 --- a/MediaBrowser.Model/Sync/SyncDialogOptions.cs +++ b/MediaBrowser.Model/Sync/SyncDialogOptions.cs @@ -13,12 +13,12 @@ namespace MediaBrowser.Model.Sync /// Gets or sets the options. /// /// The options. - public List Options { get; set; } + public List Options { get; set; } public SyncDialogOptions() { Targets = new List(); - Options = new List(); + Options = new List(); } } } diff --git a/MediaBrowser.Model/Sync/SyncHelper.cs b/MediaBrowser.Model/Sync/SyncHelper.cs index c2a446fbe6..34a5ba9954 100644 --- a/MediaBrowser.Model/Sync/SyncHelper.cs +++ b/MediaBrowser.Model/Sync/SyncHelper.cs @@ -5,13 +5,13 @@ namespace MediaBrowser.Model.Sync { public static class SyncHelper { - public static List GetSyncOptions(List items) + public static List GetSyncOptions(List items) { - List options = new List(); + List options = new List(); if (items.Count > 1) { - options.Add(SyncOptions.Name); + options.Add(SyncJobOption.Name); } foreach (BaseItemDto item in items) @@ -20,23 +20,23 @@ namespace MediaBrowser.Model.Sync { if (item.IsVideo) { - options.Add(SyncOptions.Quality); + options.Add(SyncJobOption.Quality); if (items.Count > 1) { - options.Add(SyncOptions.UnwatchedOnly); + options.Add(SyncJobOption.UnwatchedOnly); } break; } if (item.IsFolder && !item.IsMusicGenre && !item.IsArtist && !item.IsType("musicalbum") && !item.IsGameGenre) { - options.Add(SyncOptions.Quality); - options.Add(SyncOptions.UnwatchedOnly); + options.Add(SyncJobOption.Quality); + options.Add(SyncJobOption.UnwatchedOnly); break; } if (item.IsGenre) { - options.Add(SyncOptions.SyncNewContent); - options.Add(SyncOptions.ItemLimit); + options.Add(SyncJobOption.SyncNewContent); + options.Add(SyncJobOption.ItemLimit); break; } } @@ -48,8 +48,8 @@ namespace MediaBrowser.Model.Sync { if (item.IsFolder || item.IsGameGenre || item.IsMusicGenre || item.IsGenre || item.IsArtist || item.IsStudio || item.IsPerson) { - options.Add(SyncOptions.SyncNewContent); - options.Add(SyncOptions.ItemLimit); + options.Add(SyncJobOption.SyncNewContent); + options.Add(SyncJobOption.ItemLimit); break; } } @@ -58,15 +58,15 @@ namespace MediaBrowser.Model.Sync return options; } - public static List GetSyncOptions(SyncCategory category) + public static List GetSyncOptions(SyncCategory category) { - List options = new List(); + List options = new List(); - options.Add(SyncOptions.Name); - options.Add(SyncOptions.Quality); - options.Add(SyncOptions.UnwatchedOnly); - options.Add(SyncOptions.SyncNewContent); - options.Add(SyncOptions.ItemLimit); + options.Add(SyncJobOption.Name); + options.Add(SyncJobOption.Quality); + options.Add(SyncJobOption.UnwatchedOnly); + options.Add(SyncJobOption.SyncNewContent); + options.Add(SyncJobOption.ItemLimit); return options; } diff --git a/MediaBrowser.Model/Sync/SyncJobItem.cs b/MediaBrowser.Model/Sync/SyncJobItem.cs index 3d06943aa3..943014c0d2 100644 --- a/MediaBrowser.Model/Sync/SyncJobItem.cs +++ b/MediaBrowser.Model/Sync/SyncJobItem.cs @@ -1,4 +1,6 @@ using System; +using System.Collections.Generic; +using MediaBrowser.Model.Dto; namespace MediaBrowser.Model.Sync { @@ -27,12 +29,18 @@ namespace MediaBrowser.Model.Sync /// /// The name of the item. public string ItemName { get; set; } - + /// /// Gets or sets the media source identifier. /// /// The media source identifier. public string MediaSourceId { get; set; } + + /// + /// Gets or sets the media source. + /// + /// The media source. + public MediaSourceInfo MediaSource { get; set; } /// /// Gets or sets the target identifier. @@ -74,9 +82,15 @@ namespace MediaBrowser.Model.Sync /// The primary image tag. public string PrimaryImageTag { get; set; } /// - /// Gets or sets a value indicating whether [requires conversion]. + /// Gets or sets the temporary path. /// - /// true if [requires conversion]; otherwise, false. - public bool RequiresConversion { get; set; } + /// The temporary path. + public string TemporaryPath { get; set; } + public List AdditionalFiles { get; set; } + + public SyncJobItem() + { + AdditionalFiles = new List(); + } } } diff --git a/MediaBrowser.Model/Sync/SyncOptions.cs b/MediaBrowser.Model/Sync/SyncOptions.cs index d4a7461f3a..294f7bcef7 100644 --- a/MediaBrowser.Model/Sync/SyncOptions.cs +++ b/MediaBrowser.Model/Sync/SyncOptions.cs @@ -1,12 +1,8 @@  namespace MediaBrowser.Model.Sync { - public enum SyncOptions + public class SyncOptions { - Name = 0, - Quality = 1, - UnwatchedOnly = 2, - SyncNewContent = 3, - ItemLimit = 4 + public string TemporaryPath { get; set; } } } diff --git a/MediaBrowser.Model/Sync/SyncParameter.cs b/MediaBrowser.Model/Sync/SyncParameter.cs new file mode 100644 index 0000000000..def4ab3e3f --- /dev/null +++ b/MediaBrowser.Model/Sync/SyncParameter.cs @@ -0,0 +1,12 @@ + +namespace MediaBrowser.Model.Sync +{ + public enum SyncJobOption + { + Name = 0, + Quality = 1, + UnwatchedOnly = 2, + SyncNewContent = 3, + ItemLimit = 4 + } +} diff --git a/MediaBrowser.Model/Sync/SyncedItem.cs b/MediaBrowser.Model/Sync/SyncedItem.cs index 784a12bc94..2063506b16 100644 --- a/MediaBrowser.Model/Sync/SyncedItem.cs +++ b/MediaBrowser.Model/Sync/SyncedItem.cs @@ -1,4 +1,5 @@ using MediaBrowser.Model.Dto; +using System.Collections.Generic; namespace MediaBrowser.Model.Sync { @@ -34,5 +35,15 @@ namespace MediaBrowser.Model.Sync /// /// The user identifier. public string UserId { get; set; } + /// + /// Gets or sets the additional files. + /// + /// The additional files. + public List AdditionalFiles { get; set; } + + public SyncedItem() + { + AdditionalFiles = new List(); + } } } diff --git a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj index 433b766570..b4f277fbdf 100644 --- a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj +++ b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj @@ -300,6 +300,7 @@ + diff --git a/MediaBrowser.Server.Implementations/Session/SessionManager.cs b/MediaBrowser.Server.Implementations/Session/SessionManager.cs index 8bf39fd6b9..7112c2357d 100644 --- a/MediaBrowser.Server.Implementations/Session/SessionManager.cs +++ b/MediaBrowser.Server.Implementations/Session/SessionManager.cs @@ -307,21 +307,21 @@ namespace MediaBrowser.Server.Implementations.Session /// The library item. private void UpdateNowPlayingItem(SessionInfo session, PlaybackProgressInfo info, BaseItem libraryItem) { - var runtimeTicks = libraryItem == null ? null : libraryItem.RunTimeTicks; - if (string.IsNullOrWhiteSpace(info.MediaSourceId)) { info.MediaSourceId = info.ItemId; } - if (!string.Equals(info.ItemId, info.MediaSourceId) && - !string.IsNullOrWhiteSpace(info.MediaSourceId)) + if (!string.IsNullOrWhiteSpace(info.ItemId) && info.Item == null && libraryItem != null) { - runtimeTicks = _libraryManager.GetItemById(new Guid(info.MediaSourceId)).RunTimeTicks; - } + var runtimeTicks = libraryItem.RunTimeTicks; + + if (!string.Equals(info.ItemId, info.MediaSourceId) && + !string.IsNullOrWhiteSpace(info.MediaSourceId)) + { + runtimeTicks = _libraryManager.GetItemById(new Guid(info.MediaSourceId)).RunTimeTicks; + } - if (!string.IsNullOrWhiteSpace(info.ItemId) && libraryItem != null) - { var current = session.NowPlayingItem; if (current == null || !string.Equals(current.Id, info.ItemId, StringComparison.OrdinalIgnoreCase)) @@ -711,7 +711,7 @@ namespace MediaBrowser.Server.Implementations.Session info.MediaSourceId = info.ItemId; } - if (!string.IsNullOrWhiteSpace(info.ItemId) && libraryItem != null) + if (!string.IsNullOrWhiteSpace(info.ItemId) && info.Item == null && libraryItem != null) { var current = session.NowPlayingItem; diff --git a/MediaBrowser.Server.Implementations/Sync/SyncConfig.cs b/MediaBrowser.Server.Implementations/Sync/SyncConfig.cs new file mode 100644 index 0000000000..52c7743307 --- /dev/null +++ b/MediaBrowser.Server.Implementations/Sync/SyncConfig.cs @@ -0,0 +1,29 @@ +using MediaBrowser.Common.Configuration; +using MediaBrowser.Model.Sync; +using System.Collections.Generic; + +namespace MediaBrowser.Server.Implementations.Sync +{ + public class SyncConfigurationFactory : IConfigurationFactory + { + public IEnumerable GetConfigurations() + { + return new List + { + new ConfigurationStore + { + ConfigurationType = typeof(SyncOptions), + Key = "sync" + } + }; + } + } + + public static class SyncExtensions + { + public static SyncOptions GetSyncOptions(this IConfigurationManager config) + { + return config.GetConfiguration("sync"); + } + } +} diff --git a/MediaBrowser.Server.Implementations/Sync/SyncJobProcessor.cs b/MediaBrowser.Server.Implementations/Sync/SyncJobProcessor.cs index 8053a30360..02c5aedd57 100644 --- a/MediaBrowser.Server.Implementations/Sync/SyncJobProcessor.cs +++ b/MediaBrowser.Server.Implementations/Sync/SyncJobProcessor.cs @@ -1,4 +1,7 @@ -using MediaBrowser.Common.Progress; +using System.Globalization; +using MediaBrowser.Common.Configuration; +using MediaBrowser.Common.IO; +using MediaBrowser.Common.Progress; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.Audio; using MediaBrowser.Controller.Library; @@ -16,6 +19,7 @@ using MediaBrowser.Model.Sync; using MoreLinq; using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -32,8 +36,10 @@ namespace MediaBrowser.Server.Implementations.Sync private readonly ITVSeriesManager _tvSeriesManager; private readonly IMediaEncoder _mediaEncoder; private readonly ISubtitleEncoder _subtitleEncoder; + private readonly IConfigurationManager _config; + private readonly IFileSystem _fileSystem; - public SyncJobProcessor(ILibraryManager libraryManager, ISyncRepository syncRepo, ISyncManager syncManager, ILogger logger, IUserManager userManager, ITVSeriesManager tvSeriesManager, IMediaEncoder mediaEncoder, ISubtitleEncoder subtitleEncoder) + public SyncJobProcessor(ILibraryManager libraryManager, ISyncRepository syncRepo, ISyncManager syncManager, ILogger logger, IUserManager userManager, ITVSeriesManager tvSeriesManager, IMediaEncoder mediaEncoder, ISubtitleEncoder subtitleEncoder, IConfigurationManager config, IFileSystem fileSystem) { _libraryManager = libraryManager; _syncRepo = syncRepo; @@ -43,6 +49,8 @@ namespace MediaBrowser.Server.Implementations.Sync _tvSeriesManager = tvSeriesManager; _mediaEncoder = mediaEncoder; _subtitleEncoder = subtitleEncoder; + _config = config; + _fileSystem = fileSystem; } public async Task EnsureJobItems(SyncJob job) @@ -329,6 +337,13 @@ namespace MediaBrowser.Server.Implementations.Sync }); await SyncJobItems(result.Items, true, progress, cancellationToken).ConfigureAwait(false); + + CleanDeadSyncFiles(); + } + + private void CleanDeadSyncFiles() + { + // TODO } public async Task SyncJobItems(SyncJobItem[] items, bool enableConversion, IProgress progress, CancellationToken cancellationToken) @@ -416,24 +431,36 @@ namespace MediaBrowser.Server.Implementations.Sync var streamInfo = new StreamBuilder().BuildVideoItem(options); var mediaSource = streamInfo.MediaSource; + var externalSubs = streamInfo.GetExternalSubtitles("dummy", false); + var hasExternalSubs = externalSubs.Count > 0; - jobItem.MediaSourceId = streamInfo.MediaSourceId; + var requiresConversion = streamInfo.PlayMethod == PlayMethod.Transcode || hasExternalSubs; - if (streamInfo.PlayMethod == PlayMethod.Transcode) + if (requiresConversion && !enableConversion) { - if (!enableConversion) - { - return; - } + return; + } + jobItem.MediaSourceId = streamInfo.MediaSourceId; + jobItem.TemporaryPath = GetTemporaryPath(jobItem); + + if (requiresConversion) + { jobItem.Status = SyncJobItemStatus.Converting; - jobItem.RequiresConversion = true; + } + + if (streamInfo.PlayMethod == PlayMethod.Transcode) + { + // Save the job item now since conversion could take a while await _syncRepo.Update(jobItem).ConfigureAwait(false); try { - jobItem.OutputPath = await _mediaEncoder.EncodeVideo(new EncodingJobOptions(streamInfo, profile), progress, - cancellationToken); + jobItem.OutputPath = await _mediaEncoder.EncodeVideo(new EncodingJobOptions(streamInfo, profile) + { + OutputDirectory = jobItem.TemporaryPath + + }, progress, cancellationToken); } catch (OperationCanceledException) { @@ -445,18 +472,16 @@ namespace MediaBrowser.Server.Implementations.Sync _logger.ErrorException("Error during sync transcoding", ex); } - await ConvertSubtitles(jobItem, streamInfo, cancellationToken).ConfigureAwait(false); - if (jobItem.Status == SyncJobItemStatus.Failed || jobItem.Status == SyncJobItemStatus.Queued) { await _syncRepo.Update(jobItem).ConfigureAwait(false); return; } + + jobItem.MediaSource = await GetEncodedMediaSource(jobItem.OutputPath, user, true).ConfigureAwait(false); } else { - jobItem.RequiresConversion = false; - if (mediaSource.Protocol == MediaProtocol.File) { jobItem.OutputPath = mediaSource.Path; @@ -469,6 +494,16 @@ namespace MediaBrowser.Server.Implementations.Sync { throw new InvalidOperationException(string.Format("Cannot direct stream {0} protocol", mediaSource.Protocol)); } + + jobItem.MediaSource = mediaSource; + } + + if (hasExternalSubs) + { + // Save the job item now since conversion could take a while + await _syncRepo.Update(jobItem).ConfigureAwait(false); + + await ConvertSubtitles(jobItem, externalSubs, streamInfo, cancellationToken).ConfigureAwait(false); } jobItem.Progress = 50; @@ -476,18 +511,72 @@ namespace MediaBrowser.Server.Implementations.Sync await _syncRepo.Update(jobItem).ConfigureAwait(false); } - private async Task ConvertSubtitles(SyncJobItem jobItem, StreamInfo streamInfo, CancellationToken cancellationToken) + private async Task ConvertSubtitles(SyncJobItem jobItem, + IEnumerable subtitles, + StreamInfo streamInfo, + CancellationToken cancellationToken) { - if (streamInfo.SubtitleDeliveryMethod != SubtitleDeliveryMethod.External || !streamInfo.SubtitleStreamIndex.HasValue) + var files = new List(); + + var mediaStreams = jobItem.MediaSource.MediaStreams + .Where(i => i.Type != MediaStreamType.Subtitle || !i.IsExternal) + .ToList(); + + var startingIndex = mediaStreams.Count == 0 ? + 0 : + (mediaStreams.Select(i => i.Index).Max() + 1); + + foreach (var subtitle in subtitles) { - // Nothing to do - return; + var fileInfo = await ConvertSubtitles(jobItem.TemporaryPath, streamInfo, subtitle, cancellationToken).ConfigureAwait(false); + + // Reset this to a value that will be based on the output media + fileInfo.Index = startingIndex; + files.Add(fileInfo); + + mediaStreams.Add(new MediaStream + { + Index = startingIndex, + Codec = subtitle.Format, + IsForced = subtitle.IsForced, + IsExternal = true, + Language = subtitle.Language, + Path = fileInfo.Path + }); + + startingIndex++; } - //using (var stream = await _subtitleEncoder.GetSubtitles(streamInfo.ItemId, streamInfo.MediaSourceId, streamInfo.SubtitleStreamIndex.Value, streamInfo.SubtitleFormat, 0, null, cancellationToken).ConfigureAwait(false)) - //{ + jobItem.AdditionalFiles.AddRange(files); - //} + jobItem.MediaSource.MediaStreams = mediaStreams; + } + + private async Task ConvertSubtitles(string temporaryPath, StreamInfo streamInfo, SubtitleStreamInfo subtitleStreamInfo, CancellationToken cancellationToken) + { + var subtitleStreamIndex = subtitleStreamInfo.Index; + + var filename = Guid.NewGuid() + "." + subtitleStreamInfo.Format.ToLower(); + + var path = Path.Combine(temporaryPath, filename); + + Directory.CreateDirectory(Path.GetDirectoryName(path)); + + using (var stream = await _subtitleEncoder.GetSubtitles(streamInfo.ItemId, streamInfo.MediaSourceId, subtitleStreamIndex, subtitleStreamInfo.Format, 0, null, cancellationToken).ConfigureAwait(false)) + { + using (var fs = _fileSystem.GetFileStream(path, FileMode.Create, FileAccess.Write, FileShare.Read, true)) + { + await stream.CopyToAsync(fs, StreamDefaults.DefaultCopyToBufferSize, cancellationToken).ConfigureAwait(false); + } + } + + return new ItemFileInfo + { + Name = Path.GetFileName(path), + Path = path, + Type = ItemFileType.Subtitles, + Index = subtitleStreamIndex + }; } private async Task Sync(SyncJobItem jobItem, Audio item, User user, DeviceProfile profile, bool enableConversion, IProgress progress, CancellationToken cancellationToken) @@ -505,6 +594,7 @@ namespace MediaBrowser.Server.Implementations.Sync var mediaSource = streamInfo.MediaSource; jobItem.MediaSourceId = streamInfo.MediaSourceId; + jobItem.TemporaryPath = GetTemporaryPath(jobItem); if (streamInfo.PlayMethod == PlayMethod.Transcode) { @@ -514,12 +604,15 @@ namespace MediaBrowser.Server.Implementations.Sync } jobItem.Status = SyncJobItemStatus.Converting; - jobItem.RequiresConversion = true; await _syncRepo.Update(jobItem).ConfigureAwait(false); try { - jobItem.OutputPath = await _mediaEncoder.EncodeAudio(new EncodingJobOptions(streamInfo, profile), progress, cancellationToken); + jobItem.OutputPath = await _mediaEncoder.EncodeAudio(new EncodingJobOptions(streamInfo, profile) + { + OutputDirectory = jobItem.TemporaryPath + + }, progress, cancellationToken); } catch (OperationCanceledException) { @@ -536,11 +629,11 @@ namespace MediaBrowser.Server.Implementations.Sync await _syncRepo.Update(jobItem).ConfigureAwait(false); return; } + + jobItem.MediaSource = await GetEncodedMediaSource(jobItem.OutputPath, user, false).ConfigureAwait(false); } else { - jobItem.RequiresConversion = false; - if (mediaSource.Protocol == MediaProtocol.File) { jobItem.OutputPath = mediaSource.Path; @@ -553,6 +646,8 @@ namespace MediaBrowser.Server.Implementations.Sync { throw new InvalidOperationException(string.Format("Cannot direct stream {0} protocol", mediaSource.Protocol)); } + + jobItem.MediaSource = mediaSource; } jobItem.Progress = 50; @@ -583,5 +678,65 @@ namespace MediaBrowser.Server.Implementations.Sync // TODO: Download return mediaSource.Path; } + + private string GetTemporaryPath(SyncJobItem jobItem) + { + var basePath = _config.GetSyncOptions().TemporaryPath; + + if (string.IsNullOrWhiteSpace(basePath)) + { + basePath = Path.Combine(_config.CommonApplicationPaths.ProgramDataPath, "sync"); + } + + return Path.Combine(basePath, jobItem.JobId, jobItem.Id); + } + + private async Task GetEncodedMediaSource(string path, User user, bool isVideo) + { + var item = _libraryManager.ResolvePath(new FileInfo(path)); + + await item.RefreshMetadata(CancellationToken.None).ConfigureAwait(false); + + var hasMediaSources = item as IHasMediaSources; + + var mediaSources = hasMediaSources.GetMediaSources(false).ToList(); + + var preferredAudio = string.IsNullOrEmpty(user.Configuration.AudioLanguagePreference) + ? new string[] { } + : new[] { user.Configuration.AudioLanguagePreference }; + + var preferredSubs = string.IsNullOrEmpty(user.Configuration.SubtitleLanguagePreference) + ? new List { } + : new List { user.Configuration.SubtitleLanguagePreference }; + + foreach (var source in mediaSources) + { + if (isVideo) + { + source.DefaultAudioStreamIndex = + MediaStreamSelector.GetDefaultAudioStreamIndex(source.MediaStreams, preferredAudio, user.Configuration.PlayDefaultAudioTrack); + + var defaultAudioIndex = source.DefaultAudioStreamIndex; + var audioLangage = defaultAudioIndex == null + ? null + : source.MediaStreams.Where(i => i.Type == MediaStreamType.Audio && i.Index == defaultAudioIndex).Select(i => i.Language).FirstOrDefault(); + + source.DefaultAudioStreamIndex = + MediaStreamSelector.GetDefaultSubtitleStreamIndex(source.MediaStreams, preferredSubs, user.Configuration.SubtitleMode, audioLangage); + } + else + { + var audio = source.MediaStreams.FirstOrDefault(i => i.Type == MediaStreamType.Audio); + + if (audio != null) + { + source.DefaultAudioStreamIndex = audio.Index; + } + + } + } + + return mediaSources.FirstOrDefault(); + } } } diff --git a/MediaBrowser.Server.Implementations/Sync/SyncManager.cs b/MediaBrowser.Server.Implementations/Sync/SyncManager.cs index bc6446d4e7..b8d884cee5 100644 --- a/MediaBrowser.Server.Implementations/Sync/SyncManager.cs +++ b/MediaBrowser.Server.Implementations/Sync/SyncManager.cs @@ -1,4 +1,5 @@ using MediaBrowser.Common; +using MediaBrowser.Common.Configuration; using MediaBrowser.Common.Extensions; using MediaBrowser.Common.IO; using MediaBrowser.Controller.Channels; @@ -13,6 +14,7 @@ using MediaBrowser.Controller.MediaEncoding; using MediaBrowser.Controller.Sync; using MediaBrowser.Controller.TV; using MediaBrowser.Model.Dlna; +using MediaBrowser.Model.Dto; using MediaBrowser.Model.Entities; using MediaBrowser.Model.Logging; using MediaBrowser.Model.Querying; @@ -41,10 +43,11 @@ namespace MediaBrowser.Server.Implementations.Sync private readonly Func _mediaEncoder; private readonly IFileSystem _fileSystem; private readonly Func _subtitleEncoder; + private readonly IConfigurationManager _config; private ISyncProvider[] _providers = { }; - public SyncManager(ILibraryManager libraryManager, ISyncRepository repo, IImageProcessor imageProcessor, ILogger logger, IUserManager userManager, Func dtoService, IApplicationHost appHost, ITVSeriesManager tvSeriesManager, Func mediaEncoder, IFileSystem fileSystem, Func subtitleEncoder) + public SyncManager(ILibraryManager libraryManager, ISyncRepository repo, IImageProcessor imageProcessor, ILogger logger, IUserManager userManager, Func dtoService, IApplicationHost appHost, ITVSeriesManager tvSeriesManager, Func mediaEncoder, IFileSystem fileSystem, Func subtitleEncoder, IConfigurationManager config) { _libraryManager = libraryManager; _repo = repo; @@ -57,6 +60,7 @@ namespace MediaBrowser.Server.Implementations.Sync _mediaEncoder = mediaEncoder; _fileSystem = fileSystem; _subtitleEncoder = subtitleEncoder; + _config = config; } public void AddParts(IEnumerable providers) @@ -66,7 +70,7 @@ namespace MediaBrowser.Server.Implementations.Sync public async Task CreateJob(SyncJobRequest request) { - var processor = new SyncJobProcessor(_libraryManager, _repo, this, _logger, _userManager, _tvSeriesManager, _mediaEncoder(), _subtitleEncoder()); + var processor = GetSyncJobProcessor(); var user = _userManager.GetUserById(request.UserId); @@ -129,7 +133,7 @@ namespace MediaBrowser.Server.Implementations.Sync await _repo.Create(job).ConfigureAwait(false); await processor.EnsureJobItems(job).ConfigureAwait(false); - + // If it already has a converting status then is must have been aborted during conversion var jobItemsResult = _repo.GetJobItems(new SyncJobItemQuery { @@ -180,7 +184,7 @@ namespace MediaBrowser.Server.Implementations.Sync if (item == null) { - var processor = new SyncJobProcessor(_libraryManager, _repo, this, _logger, _userManager, _tvSeriesManager, _mediaEncoder(), _subtitleEncoder()); + var processor = GetSyncJobProcessor(); var user = _userManager.GetUserById(job.UserId); @@ -408,11 +412,14 @@ namespace MediaBrowser.Server.Implementations.Sync jobItem.Status = SyncJobItemStatus.Synced; jobItem.Progress = 100; - if (jobItem.RequiresConversion) + if (!string.IsNullOrWhiteSpace(jobItem.TemporaryPath)) { try { - _fileSystem.DeleteFile(jobItem.OutputPath); + _fileSystem.DeleteDirectory(jobItem.TemporaryPath, true); + } + catch (DirectoryNotFoundException) + { } catch (Exception ex) { @@ -422,11 +429,16 @@ namespace MediaBrowser.Server.Implementations.Sync await _repo.Update(jobItem).ConfigureAwait(false); - var processor = new SyncJobProcessor(_libraryManager, _repo, this, _logger, _userManager, _tvSeriesManager, _mediaEncoder(), _subtitleEncoder()); + var processor = GetSyncJobProcessor(); await processor.UpdateJobStatus(jobItem.JobId).ConfigureAwait(false); } + private SyncJobProcessor GetSyncJobProcessor() + { + return new SyncJobProcessor(_libraryManager, _repo, this, _logger, _userManager, _tvSeriesManager, _mediaEncoder(), _subtitleEncoder(), _config, _fileSystem); + } + public SyncJobItem GetJobItem(string id) { return _repo.GetJobItem(id); @@ -455,7 +467,15 @@ namespace MediaBrowser.Server.Implementations.Sync SyncJobId = jobItem.JobId, SyncJobItemId = jobItem.Id, ServerId = _appHost.SystemId, - UserId = job.UserId + UserId = job.UserId, + AdditionalFiles = jobItem.AdditionalFiles.Select(i => new ItemFileInfo + { + ImageType = i.ImageType, + Name = i.Name, + Type = i.Type, + Index = i.Index + + }).ToList() }; var dtoOptions = new DtoOptions(); @@ -472,14 +492,11 @@ namespace MediaBrowser.Server.Implementations.Sync syncedItem.Item = _dtoService().GetBaseItemDto(libraryItem, dtoOptions); - // TODO: this should be the media source of the transcoded output - syncedItem.Item.MediaSources = syncedItem.Item.MediaSources - .Where(i => string.Equals(i.Id, jobItem.MediaSourceId)) - .ToList(); - var mediaSource = syncedItem.Item.MediaSources .FirstOrDefault(i => string.Equals(i.Id, jobItem.MediaSourceId)); + syncedItem.Item.MediaSources = new List(); + // This will be null for items that are not audio/video if (mediaSource == null) { @@ -488,6 +505,7 @@ namespace MediaBrowser.Server.Implementations.Sync else { syncedItem.OriginalFileName = Path.GetFileName(mediaSource.Path); + syncedItem.Item.MediaSources.Add(mediaSource); } return syncedItem; diff --git a/MediaBrowser.Server.Implementations/Sync/SyncRepository.cs b/MediaBrowser.Server.Implementations/Sync/SyncRepository.cs index 151860d84c..ae91437104 100644 --- a/MediaBrowser.Server.Implementations/Sync/SyncRepository.cs +++ b/MediaBrowser.Server.Implementations/Sync/SyncRepository.cs @@ -1,7 +1,9 @@ using MediaBrowser.Controller; using MediaBrowser.Controller.Sync; +using MediaBrowser.Model.Dto; using MediaBrowser.Model.Logging; using MediaBrowser.Model.Querying; +using MediaBrowser.Model.Serialization; using MediaBrowser.Model.Sync; using MediaBrowser.Server.Implementations.Persistence; using System; @@ -28,15 +30,18 @@ namespace MediaBrowser.Server.Implementations.Sync private IDbCommand _saveJobCommand; private IDbCommand _saveJobItemCommand; - public SyncRepository(ILogger logger, IServerApplicationPaths appPaths) + private readonly IJsonSerializer _json; + + public SyncRepository(ILogger logger, IServerApplicationPaths appPaths, IJsonSerializer json) { _logger = logger; _appPaths = appPaths; + _json = json; } public async Task Initialize() { - var dbFile = Path.Combine(_appPaths.DataPath, "sync11.db"); + var dbFile = Path.Combine(_appPaths.DataPath, "sync12.db"); _connection = await SqliteExtensions.ConnectToDb(dbFile, _logger).ConfigureAwait(false); @@ -45,7 +50,7 @@ namespace MediaBrowser.Server.Implementations.Sync "create table if not exists SyncJobs (Id GUID PRIMARY KEY, TargetId TEXT NOT NULL, Name TEXT NOT NULL, Quality TEXT NOT NULL, Status TEXT NOT NULL, Progress FLOAT, UserId TEXT NOT NULL, ItemIds TEXT NOT NULL, Category TEXT, ParentId TEXT, UnwatchedOnly BIT, ItemLimit INT, SyncNewContent BIT, DateCreated DateTime, DateLastModified DateTime, ItemCount int)", "create index if not exists idx_SyncJobs on SyncJobs(Id)", - "create table if not exists SyncJobItems (Id GUID PRIMARY KEY, ItemId TEXT, ItemName TEXT, MediaSourceId TEXT, JobId TEXT, RequiresConversion BIT, OutputPath TEXT, Status TEXT, TargetId TEXT, DateCreated DateTime, Progress FLOAT)", + "create table if not exists SyncJobItems (Id GUID PRIMARY KEY, ItemId TEXT, ItemName TEXT, MediaSourceId TEXT, JobId TEXT, TemporaryPath TEXT, OutputPath TEXT, Status TEXT, TargetId TEXT, DateCreated DateTime, Progress FLOAT, AdditionalFiles TEXT, MediaSource TEXT)", "create index if not exists idx_SyncJobItems on SyncJobs(Id)", //pragmas @@ -90,23 +95,25 @@ namespace MediaBrowser.Server.Implementations.Sync _saveJobCommand.Parameters.Add(_saveJobCommand, "@ItemCount"); _saveJobItemCommand = _connection.CreateCommand(); - _saveJobItemCommand.CommandText = "replace into SyncJobItems (Id, ItemId, ItemName, MediaSourceId, JobId, RequiresConversion, OutputPath, Status, TargetId, DateCreated, Progress) values (@Id, @ItemId, @ItemName, @MediaSourceId, @JobId, @RequiresConversion, @OutputPath, @Status, @TargetId, @DateCreated, @Progress)"; + _saveJobItemCommand.CommandText = "replace into SyncJobItems (Id, ItemId, ItemName, MediaSourceId, JobId, TemporaryPath, OutputPath, Status, TargetId, DateCreated, Progress, AdditionalFiles, MediaSource) values (@Id, @ItemId, @ItemName, @MediaSourceId, @JobId, @TemporaryPath, @OutputPath, @Status, @TargetId, @DateCreated, @Progress, @AdditionalFiles, @MediaSource)"; _saveJobItemCommand.Parameters.Add(_saveJobItemCommand, "@Id"); _saveJobItemCommand.Parameters.Add(_saveJobItemCommand, "@ItemId"); _saveJobItemCommand.Parameters.Add(_saveJobItemCommand, "@ItemName"); _saveJobItemCommand.Parameters.Add(_saveJobItemCommand, "@MediaSourceId"); _saveJobItemCommand.Parameters.Add(_saveJobItemCommand, "@JobId"); - _saveJobItemCommand.Parameters.Add(_saveJobItemCommand, "@RequiresConversion"); + _saveJobItemCommand.Parameters.Add(_saveJobItemCommand, "@TemporaryPath"); _saveJobItemCommand.Parameters.Add(_saveJobItemCommand, "@OutputPath"); _saveJobItemCommand.Parameters.Add(_saveJobItemCommand, "@Status"); _saveJobItemCommand.Parameters.Add(_saveJobItemCommand, "@TargetId"); _saveJobItemCommand.Parameters.Add(_saveJobItemCommand, "@DateCreated"); _saveJobItemCommand.Parameters.Add(_saveJobItemCommand, "@Progress"); + _saveJobItemCommand.Parameters.Add(_saveJobItemCommand, "@AdditionalFiles"); + _saveJobItemCommand.Parameters.Add(_saveJobItemCommand, "@MediaSource"); } private const string BaseJobSelectText = "select Id, TargetId, Name, Quality, Status, Progress, UserId, ItemIds, Category, ParentId, UnwatchedOnly, ItemLimit, SyncNewContent, DateCreated, DateLastModified, ItemCount from SyncJobs"; - private const string BaseJobItemSelectText = "select Id, ItemId, ItemName, MediaSourceId, JobId, RequiresConversion, OutputPath, Status, TargetId, DateCreated, Progress from SyncJobItems"; + private const string BaseJobItemSelectText = "select Id, ItemId, ItemName, MediaSourceId, JobId, TemporaryPath, OutputPath, Status, TargetId, DateCreated, Progress, AdditionalFiles, MediaSource from SyncJobItems"; public SyncJob GetJob(string id) { @@ -557,12 +564,14 @@ namespace MediaBrowser.Server.Implementations.Sync _saveJobItemCommand.GetParameter(index++).Value = jobItem.ItemName; _saveJobItemCommand.GetParameter(index++).Value = jobItem.MediaSourceId; _saveJobItemCommand.GetParameter(index++).Value = jobItem.JobId; - _saveJobItemCommand.GetParameter(index++).Value = jobItem.RequiresConversion; + _saveJobItemCommand.GetParameter(index++).Value = jobItem.TemporaryPath; _saveJobItemCommand.GetParameter(index++).Value = jobItem.OutputPath; _saveJobItemCommand.GetParameter(index++).Value = jobItem.Status.ToString(); _saveJobItemCommand.GetParameter(index++).Value = jobItem.TargetId; _saveJobItemCommand.GetParameter(index++).Value = jobItem.DateCreated; _saveJobItemCommand.GetParameter(index++).Value = jobItem.Progress; + _saveJobItemCommand.GetParameter(index++).Value = _json.SerializeToString(jobItem.AdditionalFiles); + _saveJobItemCommand.GetParameter(index++).Value = jobItem.MediaSource == null ? null : _json.SerializeToString(jobItem.MediaSource); _saveJobItemCommand.Transaction = transaction; @@ -620,8 +629,11 @@ namespace MediaBrowser.Server.Implementations.Sync } info.JobId = reader.GetString(4); - info.RequiresConversion = reader.GetBoolean(5); + if (!reader.IsDBNull(5)) + { + info.TemporaryPath = reader.GetString(5); + } if (!reader.IsDBNull(6)) { info.OutputPath = reader.GetString(6); @@ -641,6 +653,26 @@ namespace MediaBrowser.Server.Implementations.Sync info.Progress = reader.GetDouble(10); } + if (!reader.IsDBNull(11)) + { + var json = reader.GetString(11); + + if (!string.IsNullOrWhiteSpace(json)) + { + info.AdditionalFiles = _json.DeserializeFromString>(json); + } + } + + if (!reader.IsDBNull(12)) + { + var json = reader.GetString(12); + + if (!string.IsNullOrWhiteSpace(json)) + { + info.MediaSource = _json.DeserializeFromString(json); + } + } + return info; } diff --git a/MediaBrowser.Server.Implementations/Sync/SyncScheduledTask.cs b/MediaBrowser.Server.Implementations/Sync/SyncScheduledTask.cs index 88b761a7da..4edebb60f1 100644 --- a/MediaBrowser.Server.Implementations/Sync/SyncScheduledTask.cs +++ b/MediaBrowser.Server.Implementations/Sync/SyncScheduledTask.cs @@ -1,4 +1,6 @@ -using MediaBrowser.Common.ScheduledTasks; +using MediaBrowser.Common.Configuration; +using MediaBrowser.Common.IO; +using MediaBrowser.Common.ScheduledTasks; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.MediaEncoding; using MediaBrowser.Controller.Sync; @@ -21,8 +23,10 @@ namespace MediaBrowser.Server.Implementations.Sync private readonly ITVSeriesManager _tvSeriesManager; private readonly IMediaEncoder _mediaEncoder; private readonly ISubtitleEncoder _subtitleEncoder; + private readonly IConfigurationManager _config; + private readonly IFileSystem _fileSystem; - public SyncScheduledTask(ILibraryManager libraryManager, ISyncRepository syncRepo, ISyncManager syncManager, ILogger logger, IUserManager userManager, ITVSeriesManager tvSeriesManager, IMediaEncoder mediaEncoder, ISubtitleEncoder subtitleEncoder) + public SyncScheduledTask(ILibraryManager libraryManager, ISyncRepository syncRepo, ISyncManager syncManager, ILogger logger, IUserManager userManager, ITVSeriesManager tvSeriesManager, IMediaEncoder mediaEncoder, ISubtitleEncoder subtitleEncoder, IConfigurationManager config, IFileSystem fileSystem) { _libraryManager = libraryManager; _syncRepo = syncRepo; @@ -32,6 +36,8 @@ namespace MediaBrowser.Server.Implementations.Sync _tvSeriesManager = tvSeriesManager; _mediaEncoder = mediaEncoder; _subtitleEncoder = subtitleEncoder; + _config = config; + _fileSystem = fileSystem; } public string Name @@ -54,7 +60,7 @@ namespace MediaBrowser.Server.Implementations.Sync public Task Execute(CancellationToken cancellationToken, IProgress progress) { - return new SyncJobProcessor(_libraryManager, _syncRepo, _syncManager, _logger, _userManager, _tvSeriesManager, _mediaEncoder, _subtitleEncoder).Sync(progress, + return new SyncJobProcessor(_libraryManager, _syncRepo, _syncManager, _logger, _userManager, _tvSeriesManager, _mediaEncoder, _subtitleEncoder, _config, _fileSystem).Sync(progress, cancellationToken); } diff --git a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs index 65d3b009f9..f7ff5eef15 100644 --- a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs +++ b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs @@ -483,7 +483,7 @@ namespace MediaBrowser.Server.Startup.Common TVSeriesManager = new TVSeriesManager(UserManager, UserDataManager, LibraryManager); RegisterSingleInstance(TVSeriesManager); - SyncManager = new SyncManager(LibraryManager, SyncRepository, ImageProcessor, LogManager.GetLogger("SyncManager"), UserManager, () => DtoService, this, TVSeriesManager, () => MediaEncoder, FileSystemManager, () => SubtitleEncoder); + SyncManager = new SyncManager(LibraryManager, SyncRepository, ImageProcessor, LogManager.GetLogger("SyncManager"), UserManager, () => DtoService, this, TVSeriesManager, () => MediaEncoder, FileSystemManager, () => SubtitleEncoder, ServerConfigurationManager); RegisterSingleInstance(SyncManager); DtoService = new DtoService(Logger, LibraryManager, UserDataManager, ItemRepository, ImageProcessor, ServerConfigurationManager, FileSystemManager, ProviderManager, () => ChannelManager, SyncManager, this); @@ -663,7 +663,7 @@ namespace MediaBrowser.Server.Startup.Common private async Task GetSyncRepository() { - var repo = new SyncRepository(LogManager.GetLogger("SyncRepository"), ServerConfigurationManager.ApplicationPaths); + var repo = new SyncRepository(LogManager.GetLogger("SyncRepository"), ServerConfigurationManager.ApplicationPaths, JsonSerializer); await repo.Initialize().ConfigureAwait(false); diff --git a/Nuget/MediaBrowser.Common.Internal.nuspec b/Nuget/MediaBrowser.Common.Internal.nuspec index b2e8ce2072..2f875f536d 100644 --- a/Nuget/MediaBrowser.Common.Internal.nuspec +++ b/Nuget/MediaBrowser.Common.Internal.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common.Internal - 3.0.541 + 3.0.543 MediaBrowser.Common.Internal Luke ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains common components shared by Media Browser Theater and Media Browser Server. Not intended for plugin developer consumption. Copyright © Media Browser 2013 - + diff --git a/Nuget/MediaBrowser.Common.nuspec b/Nuget/MediaBrowser.Common.nuspec index 06fbc750fb..7224a73cb8 100644 --- a/Nuget/MediaBrowser.Common.nuspec +++ b/Nuget/MediaBrowser.Common.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common - 3.0.541 + 3.0.543 MediaBrowser.Common Media Browser Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Model.Signed.nuspec b/Nuget/MediaBrowser.Model.Signed.nuspec index c11f886c15..f5a3a3de0f 100644 --- a/Nuget/MediaBrowser.Model.Signed.nuspec +++ b/Nuget/MediaBrowser.Model.Signed.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Model.Signed - 3.0.541 + 3.0.543 MediaBrowser.Model - Signed Edition Media Browser Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Server.Core.nuspec b/Nuget/MediaBrowser.Server.Core.nuspec index d183c9931a..e3cbe9d040 100644 --- a/Nuget/MediaBrowser.Server.Core.nuspec +++ b/Nuget/MediaBrowser.Server.Core.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Server.Core - 3.0.541 + 3.0.543 Media Browser.Server.Core Media Browser Team ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains core components required to build plugins for Media Browser Server. Copyright © Media Browser 2013 - + -- cgit v1.2.3 From 2300d56f688c2515def000fbd2330ad9e0116d33 Mon Sep 17 00:00:00 2001 From: Mike Date: Tue, 6 Jan 2015 22:36:42 -0500 Subject: Ssl in mediabrowser against new listener. --- MediaBrowser.Controller/IServerApplicationHost.cs | 22 ++++++++++++++++++++ MediaBrowser.Controller/Net/IHttpServer.cs | 4 +++- MediaBrowser.Controller/Net/IServerManager.cs | 4 +++- .../Configuration/ServerConfiguration.cs | 17 ++++++++++++++- MediaBrowser.Model/System/SystemInfo.cs | 18 ++++++++++++++++ .../HttpServer/HttpListenerHost.cs | 9 ++++++-- .../SocketSharp/WebSocketSharpListener.cs | 7 +++++-- .../Localization/Server/server.json | 8 ++++++++ .../ServerManager/ServerManager.cs | 8 ++++---- .../ApplicationHost.cs | 24 +++++++++++++++++++++- 10 files changed, 109 insertions(+), 12 deletions(-) (limited to 'MediaBrowser.Controller') diff --git a/MediaBrowser.Controller/IServerApplicationHost.cs b/MediaBrowser.Controller/IServerApplicationHost.cs index 76eb9fceb0..6bee5e58a3 100644 --- a/MediaBrowser.Controller/IServerApplicationHost.cs +++ b/MediaBrowser.Controller/IServerApplicationHost.cs @@ -36,6 +36,28 @@ namespace MediaBrowser.Controller /// The HTTP server port. int HttpServerPort { get; } + /// + /// Gets the HTTPS server port. + /// + /// The HTTPS server port. + int HttpsServerPort { get; } + + /// + /// Gets the value indiciating if an https port should be hosted. + /// + /// + /// The value indiciating if an https port should be hosted. + /// + bool UseHttps { get; } + + /// + /// Gets the value pointing to the file system where the ssl certiifcate is located. + /// + /// + /// The value pointing to the file system where the ssl certiifcate is located. + /// + string CertificatePath { get; } + /// /// Gets a value indicating whether this instance has update available. /// diff --git a/MediaBrowser.Controller/Net/IHttpServer.cs b/MediaBrowser.Controller/Net/IHttpServer.cs index 5b179d479a..d56bee009e 100644 --- a/MediaBrowser.Controller/Net/IHttpServer.cs +++ b/MediaBrowser.Controller/Net/IHttpServer.cs @@ -19,7 +19,9 @@ namespace MediaBrowser.Controller.Net /// Starts the specified server name. /// /// The URL prefixes. - void StartServer(IEnumerable urlPrefixes); + /// If an https prefix is specified, + /// the ssl certificate localtion on the file system. + void StartServer(IEnumerable urlPrefixes, string certificatePath); /// /// Gets the local end points. diff --git a/MediaBrowser.Controller/Net/IServerManager.cs b/MediaBrowser.Controller/Net/IServerManager.cs index dff0863478..d90a0f8ed6 100644 --- a/MediaBrowser.Controller/Net/IServerManager.cs +++ b/MediaBrowser.Controller/Net/IServerManager.cs @@ -15,7 +15,9 @@ namespace MediaBrowser.Controller.Net /// Starts this instance. /// /// The URL prefixes. - void Start(IEnumerable urlPrefixes); + /// If an https prefix is specified, + /// the ssl certificate localtion on the file system. + void Start(IEnumerable urlPrefixes, string certificatePath); /// /// Sends a message to all clients currently connected via a web socket diff --git a/MediaBrowser.Model/Configuration/ServerConfiguration.cs b/MediaBrowser.Model/Configuration/ServerConfiguration.cs index c4a9c5eeaf..755fe8aa83 100644 --- a/MediaBrowser.Model/Configuration/ServerConfiguration.cs +++ b/MediaBrowser.Model/Configuration/ServerConfiguration.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Model.Dto; +using System.Xml.Schema; +using MediaBrowser.Model.Dto; using MediaBrowser.Model.Entities; namespace MediaBrowser.Model.Configuration @@ -32,6 +33,17 @@ namespace MediaBrowser.Model.Configuration /// The HTTPS server port number. public int HttpsPortNumber { get; set; } + /// Gets or sets the value pointing to the file system where the ssl certiifcate is located. + /// + /// The value pointing to the file system where the ssl certiifcate is located. + public bool UseHttps { get; set; } + + /// + /// Gets or sets the value pointing to the file system where the ssl certiifcate is located.. + /// + /// The value pointing to the file system where the ssl certiifcate is located.. + public string CertificatePath { get; set; } + /// /// Gets or sets a value indicating whether [enable internet providers]. /// @@ -187,6 +199,7 @@ namespace MediaBrowser.Model.Configuration public string[] InsecureApps8 { get; set; } public bool SaveMetadataHidden { get; set; } + public bool EnableWin8HttpListener { get; set; } public NameValuePair[] ContentTypes { get; set; } @@ -204,6 +217,8 @@ namespace MediaBrowser.Model.Configuration PublicPort = 8096; HttpServerPortNumber = 8096; HttpsPortNumber = 8920; + UseHttps = false; + CertificatePath = null; EnableDashboardResponseCaching = true; EnableAutomaticRestart = true; diff --git a/MediaBrowser.Model/System/SystemInfo.cs b/MediaBrowser.Model/System/SystemInfo.cs index f9cacea122..9d4cfd6dbd 100644 --- a/MediaBrowser.Model/System/SystemInfo.cs +++ b/MediaBrowser.Model/System/SystemInfo.cs @@ -122,6 +122,24 @@ namespace MediaBrowser.Model.System /// The HTTP server port number. public int HttpServerPortNumber { get; set; } + /// + /// Gets or sets the value pointing to the file system where the ssl certiifcate is located. + /// + /// The value pointing to the file system where the ssl certiifcate is located. + public bool UseHttps { get; set; } + + /// + /// Gets or sets the value pointing to the file system where the ssl certiifcate is located.. + /// + /// The value pointing to the file system where the ssl certiifcate is located.. + public string CertificatePath { get; set; } + + /// + /// Gets or sets the HTTPS server port number. + /// + /// The HTTPS server port number. + public int HttpsPortNumber { get; set; } + /// /// Gets or sets a value indicating whether this instance has update available. /// diff --git a/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs b/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs index c3228db920..0c0922800a 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs @@ -44,6 +44,8 @@ namespace MediaBrowser.Server.Implementations.HttpServer private readonly bool _supportsNativeWebSocket; + private string _certificatePath; + /// /// Gets the local end points. /// @@ -217,10 +219,12 @@ namespace MediaBrowser.Server.Implementations.HttpServer { if (_supportsNativeWebSocket && NativeWebSocket.IsSupported) { + // Certificate location is ignored here. You need to use netsh + // to assign the certificate to the proper port. return new HttpListenerServer(_logger, OnRequestReceived); } - return new WebSocketSharpListener(_logger, OnRequestReceived); + return new WebSocketSharpListener(_logger, OnRequestReceived, _certificatePath); } private void WebSocketHandler(WebSocketConnectEventArgs args) @@ -425,8 +429,9 @@ namespace MediaBrowser.Server.Implementations.HttpServer GC.SuppressFinalize(this); } - public void StartServer(IEnumerable urlPrefixes) + public void StartServer(IEnumerable urlPrefixes, string certificatePath) { + _certificatePath = certificatePath; UrlPrefixes = urlPrefixes.ToList(); Start(UrlPrefixes.First()); } diff --git a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpListener.cs b/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpListener.cs index 04db0d8a58..1cf523ad29 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpListener.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpListener.cs @@ -18,11 +18,14 @@ namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp private readonly ILogger _logger; private readonly Action _endpointListener; + private readonly string _certificatePath ; - public WebSocketSharpListener(ILogger logger, Action endpointListener) + public WebSocketSharpListener(ILogger logger, Action endpointListener, + string certificatePath) { _logger = logger; _endpointListener = endpointListener; + _certificatePath = certificatePath; } public Action ErrorHandler { get; set; } @@ -34,7 +37,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp public void Start(IEnumerable urlPrefixes) { if (_listener == null) - _listener = new HttpListener(new PatternsLogger(_logger), null); + _listener = new HttpListener(new PatternsLogger(_logger), _certificatePath); foreach (var prefix in urlPrefixes) { diff --git a/MediaBrowser.Server.Implementations/Localization/Server/server.json b/MediaBrowser.Server.Implementations/Localization/Server/server.json index 35d58837cb..253d9a00db 100644 --- a/MediaBrowser.Server.Implementations/Localization/Server/server.json +++ b/MediaBrowser.Server.Implementations/Localization/Server/server.json @@ -508,6 +508,14 @@ "LabelLocalHttpServerPortNumberHelp": "The tcp port number that Media Browser's http server should bind to.", "LabelPublicPort": "Public port number:", "LabelPublicPortHelp": "The public port number that should be mapped to the local port.", + + "LabelUseHttps": "Enable SSL", + "LabelUseHttpsHelp": "Check to enable SSL hosting.", + "LabelHttpsPort": "Local http port:", + "LabelHttpsPortHelp": "The tcp port number that Media Browser's https server should bind to.", + "LabelCertificatePath": "SSL Certificate path:", + "LabelCertificatePathHelp": "The path on the filesystem to the ssl certificate pfx file.", + "LabelWebSocketPortNumber": "Web socket port number:", "LabelEnableAutomaticPortMap": "Enable automatic port mapping", "LabelEnableAutomaticPortMapHelp": "Attempt to automatically map the public port to the local port via UPnP. This may not work with some router models.", diff --git a/MediaBrowser.Server.Implementations/ServerManager/ServerManager.cs b/MediaBrowser.Server.Implementations/ServerManager/ServerManager.cs index 7a23d8e082..ef2fef7466 100644 --- a/MediaBrowser.Server.Implementations/ServerManager/ServerManager.cs +++ b/MediaBrowser.Server.Implementations/ServerManager/ServerManager.cs @@ -99,22 +99,22 @@ namespace MediaBrowser.Server.Implementations.ServerManager /// /// Starts this instance. /// - public void Start(IEnumerable urlPrefixes) + public void Start(IEnumerable urlPrefixes, string certificatePath) { - ReloadHttpServer(urlPrefixes); + ReloadHttpServer(urlPrefixes, certificatePath); } /// /// Restarts the Http Server, or starts it if not currently running /// - private void ReloadHttpServer(IEnumerable urlPrefixes) + private void ReloadHttpServer(IEnumerable urlPrefixes, string certificatePath) { _logger.Info("Loading Http Server"); try { HttpServer = _applicationHost.Resolve(); - HttpServer.StartServer(urlPrefixes); + HttpServer.StartServer(urlPrefixes, certificatePath); } catch (SocketException ex) { diff --git a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs index f7ff5eef15..29c5304382 100644 --- a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs +++ b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs @@ -133,6 +133,11 @@ namespace MediaBrowser.Server.Startup.Common "http://+:" + ServerConfigurationManager.Configuration.HttpServerPortNumber + "/" + WebApplicationName + "/" }; + if (ServerConfigurationManager.Configuration.UseHttps) + { + list.Add("https://+:" + ServerConfigurationManager.Configuration.HttpsPortNumber + "/" + WebApplicationName + "/"); + } + return list; } } @@ -805,7 +810,7 @@ namespace MediaBrowser.Server.Startup.Common { try { - ServerManager.Start(HttpServerUrlPrefixes); + ServerManager.Start(HttpServerUrlPrefixes, CertificatePath); } catch (Exception ex) { @@ -972,6 +977,8 @@ namespace MediaBrowser.Server.Startup.Common CachePath = ApplicationPaths.CachePath, MacAddress = GetMacAddress(), HttpServerPortNumber = HttpServerPort, + UseHttps = UseHttps, + CertificatePath = CertificatePath, OperatingSystem = OperatingSystemDisplayName, CanSelfRestart = CanSelfRestart, CanSelfUpdate = CanSelfUpdate, @@ -1046,6 +1053,21 @@ namespace MediaBrowser.Server.Startup.Common get { return ServerConfigurationManager.Configuration.HttpServerPortNumber; } } + public bool UseHttps + { + get { return this.ServerConfigurationManager.Configuration.UseHttps; } + } + + public string CertificatePath + { + get { return this.ServerConfigurationManager.Configuration.CertificatePath; } + } + + public int HttpsServerPort + { + get { return ServerConfigurationManager.Configuration.HttpsPortNumber; } + } + /// /// Gets the mac address. /// -- cgit v1.2.3 From 628c6cbc28f5a744785731dd4e94ec7a1f881dd2 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 17 Jan 2015 13:15:09 -0500 Subject: make library scan a bit more hands off --- MediaBrowser.Controller/LiveTv/LiveTvChannel.cs | 20 +----- .../MediaBrowser.LocalMetadata.csproj | 2 - .../Providers/ChannelXmlProvider.cs | 30 -------- .../Savers/ChannelXmlSaver.cs | 81 ---------------------- MediaBrowser.Model/Users/UserPolicy.cs | 2 + .../BoxSets/BoxSetMetadataService.cs | 42 ++++++----- MediaBrowser.Providers/Manager/MetadataService.cs | 28 +++----- .../Music/AlbumMetadataService.cs | 76 ++++++++++---------- .../Music/ArtistMetadataService.cs | 37 ++++++---- MediaBrowser.Providers/TV/DummySeasonProvider.cs | 65 ++++++++++++++++- .../TV/MissingEpisodeProvider.cs | 4 +- MediaBrowser.Providers/TV/SeasonMetadataService.cs | 14 +++- MediaBrowser.Providers/TV/SeriesMetadataService.cs | 21 +++++- MediaBrowser.Providers/TV/SeriesPostScanTask.cs | 2 +- .../Library/LibraryManager.cs | 70 ------------------- .../Library/Resolvers/Audio/MusicAlbumResolver.cs | 3 +- .../Library/Validators/ArtistsPostScanTask.cs | 7 +- .../Library/Validators/ArtistsValidator.cs | 65 +---------------- .../Library/Validators/GameGenresPostScanTask.cs | 8 ++- .../Library/Validators/GameGenresValidator.cs | 15 +--- .../Library/Validators/GenresPostScanTask.cs | 8 ++- .../Library/Validators/GenresValidator.cs | 15 +--- .../Library/Validators/MusicGenresPostScanTask.cs | 8 ++- .../Library/Validators/MusicGenresValidator.cs | 7 +- .../Library/Validators/StudiosPostScanTask.cs | 8 ++- .../Library/Validators/StudiosValidator.cs | 15 +--- .../Library/Validators/YearsPostScanTask.cs | 12 ++-- .../LiveTv/LiveTvManager.cs | 25 +------ 28 files changed, 247 insertions(+), 443 deletions(-) delete mode 100644 MediaBrowser.LocalMetadata/Providers/ChannelXmlProvider.cs delete mode 100644 MediaBrowser.LocalMetadata/Savers/ChannelXmlSaver.cs (limited to 'MediaBrowser.Controller') diff --git a/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs b/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs index 459ead16cb..b4b9fa77b8 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs +++ b/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs @@ -4,9 +4,9 @@ using MediaBrowser.Model.Dto; using MediaBrowser.Model.Entities; using MediaBrowser.Model.LiveTv; using MediaBrowser.Model.MediaInfo; +using MediaBrowser.Model.Users; using System.Collections.Generic; using System.Linq; -using MediaBrowser.Model.Users; namespace MediaBrowser.Controller.LiveTv { @@ -21,19 +21,6 @@ namespace MediaBrowser.Controller.LiveTv return GetClientTypeName() + "-" + Name; } - /// - /// Returns the folder containing the item. - /// If the item is a folder, it returns the folder itself - /// - /// The containing folder path. - public override string ContainingFolderPath - { - get - { - return Path; - } - } - protected override bool GetBlockUnratedValue(UserPolicy config) { return config.BlockUnratedItems.Contains(UnratedItem.LiveTvChannel); @@ -51,11 +38,6 @@ namespace MediaBrowser.Controller.LiveTv } } - public override bool IsSaveLocalMetadataEnabled() - { - return true; - } - /// /// Gets or sets the number. /// diff --git a/MediaBrowser.LocalMetadata/MediaBrowser.LocalMetadata.csproj b/MediaBrowser.LocalMetadata/MediaBrowser.LocalMetadata.csproj index cb9c23494a..894be87994 100644 --- a/MediaBrowser.LocalMetadata/MediaBrowser.LocalMetadata.csproj +++ b/MediaBrowser.LocalMetadata/MediaBrowser.LocalMetadata.csproj @@ -61,7 +61,6 @@ - @@ -74,7 +73,6 @@ - diff --git a/MediaBrowser.LocalMetadata/Providers/ChannelXmlProvider.cs b/MediaBrowser.LocalMetadata/Providers/ChannelXmlProvider.cs deleted file mode 100644 index 78845487a2..0000000000 --- a/MediaBrowser.LocalMetadata/Providers/ChannelXmlProvider.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System.IO; -using System.Threading; -using MediaBrowser.Common.IO; -using MediaBrowser.Controller.LiveTv; -using MediaBrowser.Controller.Providers; -using MediaBrowser.Model.Logging; - -namespace MediaBrowser.LocalMetadata.Providers -{ - public class ChannelXmlProvider : BaseXmlProvider - { - private readonly ILogger _logger; - - public ChannelXmlProvider(IFileSystem fileSystem, ILogger logger) - : base(fileSystem) - { - _logger = logger; - } - - protected override void Fetch(LocalMetadataResult result, string path, CancellationToken cancellationToken) - { - new BaseItemXmlParser(_logger).Fetch(result.Item, path, cancellationToken); - } - - protected override FileSystemInfo GetXmlFile(ItemInfo info, IDirectoryService directoryService) - { - return directoryService.GetFile(Path.Combine(info.Path, "channel.xml")); - } - } -} diff --git a/MediaBrowser.LocalMetadata/Savers/ChannelXmlSaver.cs b/MediaBrowser.LocalMetadata/Savers/ChannelXmlSaver.cs deleted file mode 100644 index 03fdf2bc80..0000000000 --- a/MediaBrowser.LocalMetadata/Savers/ChannelXmlSaver.cs +++ /dev/null @@ -1,81 +0,0 @@ -using MediaBrowser.Controller.Configuration; -using MediaBrowser.Controller.Entities; -using MediaBrowser.Controller.Library; -using MediaBrowser.Controller.LiveTv; -using System.Collections.Generic; -using System.IO; -using System.Text; -using System.Threading; - -namespace MediaBrowser.LocalMetadata.Savers -{ - /// - /// Class PersonXmlSaver - /// - public class ChannelXmlSaver : IMetadataFileSaver - { - private readonly IServerConfigurationManager _config; - - public ChannelXmlSaver(IServerConfigurationManager config) - { - _config = config; - } - - /// - /// Determines whether [is enabled for] [the specified item]. - /// - /// The item. - /// Type of the update. - /// true if [is enabled for] [the specified item]; otherwise, false. - public bool IsEnabledFor(IHasMetadata item, ItemUpdateType updateType) - { - if (!item.SupportsLocalMetadata) - { - return false; - } - - return item is LiveTvChannel && updateType >= ItemUpdateType.MetadataDownload; - } - - public string Name - { - get - { - return XmlProviderUtils.Name; - } - } - - /// - /// Saves the specified item. - /// - /// The item. - /// The cancellation token. - /// Task. - public void Save(IHasMetadata item, CancellationToken cancellationToken) - { - var builder = new StringBuilder(); - - builder.Append(""); - - XmlSaverHelpers.AddCommonNodes((LiveTvChannel)item, builder); - - builder.Append(""); - - var xmlFilePath = GetSavePath(item); - - XmlSaverHelpers.Save(builder, xmlFilePath, new List - { - }, _config); - } - - /// - /// Gets the save path. - /// - /// The item. - /// System.String. - public string GetSavePath(IHasMetadata item) - { - return Path.Combine(item.Path, "channel.xml"); - } - } -} diff --git a/MediaBrowser.Model/Users/UserPolicy.cs b/MediaBrowser.Model/Users/UserPolicy.cs index 12b8c40715..eb8dbc6f0b 100644 --- a/MediaBrowser.Model/Users/UserPolicy.cs +++ b/MediaBrowser.Model/Users/UserPolicy.cs @@ -62,6 +62,8 @@ namespace MediaBrowser.Model.Users EnableLiveTvAccess = true; EnableSharedDeviceControl = true; + EnabledChannels = new string[] { }; + BlockedMediaFolders = new string[] { }; BlockedTags = new string[] { }; BlockUnratedItems = new UnratedItem[] { }; diff --git a/MediaBrowser.Providers/BoxSets/BoxSetMetadataService.cs b/MediaBrowser.Providers/BoxSets/BoxSetMetadataService.cs index 5afaaa8753..5e16ed69cf 100644 --- a/MediaBrowser.Providers/BoxSets/BoxSetMetadataService.cs +++ b/MediaBrowser.Providers/BoxSets/BoxSetMetadataService.cs @@ -12,6 +12,7 @@ using MediaBrowser.Providers.Manager; using System; using System.Collections.Generic; using System.Linq; +using System.Threading.Tasks; namespace MediaBrowser.Providers.BoxSets { @@ -51,31 +52,34 @@ namespace MediaBrowser.Providers.BoxSets } } - protected override ItemUpdateType BeforeSave(BoxSet item) + protected override async Task BeforeSave(BoxSet item, bool isFullRefresh, ItemUpdateType currentUpdateType) { - var updateType = base.BeforeSave(item); + var updateType = await base.BeforeSave(item, isFullRefresh, currentUpdateType).ConfigureAwait(false); - if (!item.LockedFields.Contains(MetadataFields.OfficialRating)) + if (isFullRefresh || currentUpdateType > ItemUpdateType.None) { - var currentOfficialRating = item.OfficialRating; + if (!item.LockedFields.Contains(MetadataFields.OfficialRating)) + { + var currentOfficialRating = item.OfficialRating; - // Gather all possible ratings - var ratings = item.RecursiveChildren - .Concat(item.GetLinkedChildren()) - .Where(i => i is Movie || i is Series) - .Select(i => i.OfficialRating) - .Where(i => !string.IsNullOrEmpty(i)) - .Distinct(StringComparer.OrdinalIgnoreCase) - .Select(i => new Tuple(i, _iLocalizationManager.GetRatingLevel(i))) - .OrderBy(i => i.Item2 ?? 1000) - .Select(i => i.Item1); + // Gather all possible ratings + var ratings = item.RecursiveChildren + .Concat(item.GetLinkedChildren()) + .Where(i => i is Movie || i is Series) + .Select(i => i.OfficialRating) + .Where(i => !string.IsNullOrEmpty(i)) + .Distinct(StringComparer.OrdinalIgnoreCase) + .Select(i => new Tuple(i, _iLocalizationManager.GetRatingLevel(i))) + .OrderBy(i => i.Item2 ?? 1000) + .Select(i => i.Item1); - item.OfficialRating = ratings.FirstOrDefault() ?? item.OfficialRating; + item.OfficialRating = ratings.FirstOrDefault() ?? item.OfficialRating; - if (!string.Equals(currentOfficialRating ?? string.Empty, item.OfficialRating ?? string.Empty, - StringComparison.OrdinalIgnoreCase)) - { - updateType = updateType | ItemUpdateType.MetadataEdit; + if (!string.Equals(currentOfficialRating ?? string.Empty, item.OfficialRating ?? string.Empty, + StringComparison.OrdinalIgnoreCase)) + { + updateType = updateType | ItemUpdateType.MetadataEdit; + } } } diff --git a/MediaBrowser.Providers/Manager/MetadataService.cs b/MediaBrowser.Providers/Manager/MetadataService.cs index e27c39df13..f55eddfcf1 100644 --- a/MediaBrowser.Providers/Manager/MetadataService.cs +++ b/MediaBrowser.Providers/Manager/MetadataService.cs @@ -163,14 +163,13 @@ namespace MediaBrowser.Providers.Manager } } - updateType = updateType | BeforeSave(itemOfType); - - var providersHadChanges = updateType > ItemUpdateType.None; + updateType = updateType | (await BeforeSave(itemOfType, item.DateLastSaved == default(DateTime) || refreshOptions.ReplaceAllMetadata, updateType).ConfigureAwait(false)); // Save if changes were made, or it's never been saved before - if (refreshOptions.ForceSave || providersHadChanges || item.DateLastSaved == default(DateTime) || refreshOptions.ReplaceAllMetadata) + if (refreshOptions.ForceSave || updateType > ItemUpdateType.None || item.DateLastSaved == default(DateTime) || refreshOptions.ReplaceAllMetadata) { - if (refreshOptions.ForceSave || providersHadChanges || refreshOptions.ReplaceAllMetadata) + // If any of these properties are set then make sure the updateType is not None, just to force everything to save + if (refreshOptions.ForceSave || refreshOptions.ReplaceAllMetadata) { updateType = updateType | ItemUpdateType.MetadataDownload; } @@ -179,7 +178,7 @@ namespace MediaBrowser.Providers.Manager await SaveItem(itemOfType, updateType, cancellationToken); } - if (providersHadChanges || refreshResult.IsDirty) + if (updateType > ItemUpdateType.None || refreshResult.IsDirty) { await SaveProviderResult(itemOfType, refreshResult, refreshOptions.DirectoryService).ConfigureAwait(false); } @@ -194,14 +193,17 @@ namespace MediaBrowser.Providers.Manager } } + private readonly Task _cachedResult = Task.FromResult(ItemUpdateType.None); /// /// Befores the save. /// /// The item. + /// if set to true [is full refresh]. + /// Type of the current update. /// ItemUpdateType. - protected virtual ItemUpdateType BeforeSave(TItemType item) + protected virtual Task BeforeSave(TItemType item, bool isFullRefresh, ItemUpdateType currentUpdateType) { - return ItemUpdateType.None; + return _cachedResult; } /// @@ -549,11 +551,6 @@ namespace MediaBrowser.Providers.Manager } } - if (refreshResult.Successes > 0) - { - AfterRemoteRefresh(temp); - } - return refreshResult; } @@ -570,11 +567,6 @@ namespace MediaBrowser.Providers.Manager } } - protected virtual void AfterRemoteRefresh(TItemType item) - { - - } - private async Task CreateInitialLookupInfo(TItemType item, CancellationToken cancellationToken) { var info = item.GetLookupInfo(); diff --git a/MediaBrowser.Providers/Music/AlbumMetadataService.cs b/MediaBrowser.Providers/Music/AlbumMetadataService.cs index 6e3a5bf063..64dcd913d8 100644 --- a/MediaBrowser.Providers/Music/AlbumMetadataService.cs +++ b/MediaBrowser.Providers/Music/AlbumMetadataService.cs @@ -9,6 +9,7 @@ using MediaBrowser.Providers.Manager; using System; using System.Collections.Generic; using System.Linq; +using System.Threading.Tasks; namespace MediaBrowser.Providers.Music { @@ -36,59 +37,62 @@ namespace MediaBrowser.Providers.Music } } - protected override ItemUpdateType BeforeSave(MusicAlbum item) + protected override async Task BeforeSave(MusicAlbum item, bool isFullRefresh, ItemUpdateType currentUpdateType) { - var updateType = base.BeforeSave(item); + var updateType = await base.BeforeSave(item, isFullRefresh, currentUpdateType).ConfigureAwait(false); - var songs = item.RecursiveChildren.OfType private readonly ILibraryManager _libraryManager; + private readonly ILogger _logger; /// /// Initializes a new instance of the class. /// /// The library manager. - public GameGenresPostScanTask(ILibraryManager libraryManager) + /// The logger. + public GameGenresPostScanTask(ILibraryManager libraryManager, ILogger logger) { _libraryManager = libraryManager; + _logger = logger; } /// @@ -32,7 +36,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators /// Task. public Task Run(IProgress progress, CancellationToken cancellationToken) { - return ((LibraryManager)_libraryManager).ValidateGameGenres(cancellationToken, progress); + return new GameGenresValidator(_libraryManager, _logger).Run(progress, cancellationToken); } } } diff --git a/MediaBrowser.Server.Implementations/Library/Validators/GameGenresValidator.cs b/MediaBrowser.Server.Implementations/Library/Validators/GameGenresValidator.cs index 6b658e175d..b2f2a60c24 100644 --- a/MediaBrowser.Server.Implementations/Library/Validators/GameGenresValidator.cs +++ b/MediaBrowser.Server.Implementations/Library/Validators/GameGenresValidator.cs @@ -15,20 +15,14 @@ namespace MediaBrowser.Server.Implementations.Library.Validators /// private readonly ILibraryManager _libraryManager; - /// - /// The _user manager - /// - private readonly IUserManager _userManager; - /// /// The _logger /// private readonly ILogger _logger; - public GameGenresValidator(ILibraryManager libraryManager, IUserManager userManager, ILogger logger) + public GameGenresValidator(ILibraryManager libraryManager, ILogger logger) { _libraryManager = libraryManager; - _userManager = userManager; _logger = logger; } @@ -45,14 +39,11 @@ namespace MediaBrowser.Server.Implementations.Library.Validators .Distinct(StringComparer.OrdinalIgnoreCase) .ToList(); - progress.Report(2); var numComplete = 0; var count = items.Count; foreach (var name in items) { - cancellationToken.ThrowIfCancellationRequested(); - try { var itemByName = _libraryManager.GetGameGenre(name); @@ -72,9 +63,9 @@ namespace MediaBrowser.Server.Implementations.Library.Validators numComplete++; double percent = numComplete; percent /= count; - percent *= 90; + percent *= 100; - progress.Report(percent + 10); + progress.Report(percent); } progress.Report(100); diff --git a/MediaBrowser.Server.Implementations/Library/Validators/GenresPostScanTask.cs b/MediaBrowser.Server.Implementations/Library/Validators/GenresPostScanTask.cs index f1d0ef3706..a1c34676c8 100644 --- a/MediaBrowser.Server.Implementations/Library/Validators/GenresPostScanTask.cs +++ b/MediaBrowser.Server.Implementations/Library/Validators/GenresPostScanTask.cs @@ -2,6 +2,7 @@ using System; using System.Threading; using System.Threading.Tasks; +using MediaBrowser.Model.Logging; namespace MediaBrowser.Server.Implementations.Library.Validators { @@ -11,14 +12,17 @@ namespace MediaBrowser.Server.Implementations.Library.Validators /// The _library manager /// private readonly ILibraryManager _libraryManager; + private readonly ILogger _logger; /// /// Initializes a new instance of the class. /// /// The library manager. - public GenresPostScanTask(ILibraryManager libraryManager) + /// The logger. + public GenresPostScanTask(ILibraryManager libraryManager, ILogger logger) { _libraryManager = libraryManager; + _logger = logger; } /// @@ -29,7 +33,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators /// Task. public Task Run(IProgress progress, CancellationToken cancellationToken) { - return ((LibraryManager)_libraryManager).ValidateGenres(cancellationToken, progress); + return new GenresValidator(_libraryManager, _logger).Run(progress, cancellationToken); } } } diff --git a/MediaBrowser.Server.Implementations/Library/Validators/GenresValidator.cs b/MediaBrowser.Server.Implementations/Library/Validators/GenresValidator.cs index b0dee9aaf3..43dc69e63c 100644 --- a/MediaBrowser.Server.Implementations/Library/Validators/GenresValidator.cs +++ b/MediaBrowser.Server.Implementations/Library/Validators/GenresValidator.cs @@ -16,20 +16,14 @@ namespace MediaBrowser.Server.Implementations.Library.Validators /// private readonly ILibraryManager _libraryManager; - /// - /// The _user manager - /// - private readonly IUserManager _userManager; - /// /// The _logger /// private readonly ILogger _logger; - public GenresValidator(ILibraryManager libraryManager, IUserManager userManager, ILogger logger) + public GenresValidator(ILibraryManager libraryManager, ILogger logger) { _libraryManager = libraryManager; - _userManager = userManager; _logger = logger; } @@ -46,14 +40,11 @@ namespace MediaBrowser.Server.Implementations.Library.Validators .Distinct(StringComparer.OrdinalIgnoreCase) .ToList(); - progress.Report(2); var numComplete = 0; var count = items.Count; foreach (var name in items) { - cancellationToken.ThrowIfCancellationRequested(); - try { var itemByName = _libraryManager.GetGenre(name); @@ -73,9 +64,9 @@ namespace MediaBrowser.Server.Implementations.Library.Validators numComplete++; double percent = numComplete; percent /= count; - percent *= 90; + percent *= 100; - progress.Report(percent + 10); + progress.Report(percent); } progress.Report(100); diff --git a/MediaBrowser.Server.Implementations/Library/Validators/MusicGenresPostScanTask.cs b/MediaBrowser.Server.Implementations/Library/Validators/MusicGenresPostScanTask.cs index 280dd90f46..dbcab0832a 100644 --- a/MediaBrowser.Server.Implementations/Library/Validators/MusicGenresPostScanTask.cs +++ b/MediaBrowser.Server.Implementations/Library/Validators/MusicGenresPostScanTask.cs @@ -1,4 +1,5 @@ using MediaBrowser.Controller.Library; +using MediaBrowser.Model.Logging; using System; using System.Threading; using System.Threading.Tasks; @@ -14,14 +15,17 @@ namespace MediaBrowser.Server.Implementations.Library.Validators /// The _library manager /// private readonly ILibraryManager _libraryManager; + private readonly ILogger _logger; /// /// Initializes a new instance of the class. /// /// The library manager. - public MusicGenresPostScanTask(ILibraryManager libraryManager) + /// The logger. + public MusicGenresPostScanTask(ILibraryManager libraryManager, ILogger logger) { _libraryManager = libraryManager; + _logger = logger; } /// @@ -32,7 +36,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators /// Task. public Task Run(IProgress progress, CancellationToken cancellationToken) { - return ((LibraryManager)_libraryManager).ValidateMusicGenres(cancellationToken, progress); + return new MusicGenresValidator(_libraryManager, _logger).Run(progress, cancellationToken); } } } diff --git a/MediaBrowser.Server.Implementations/Library/Validators/MusicGenresValidator.cs b/MediaBrowser.Server.Implementations/Library/Validators/MusicGenresValidator.cs index aa6c6281ee..dfdbda1d96 100644 --- a/MediaBrowser.Server.Implementations/Library/Validators/MusicGenresValidator.cs +++ b/MediaBrowser.Server.Implementations/Library/Validators/MusicGenresValidator.cs @@ -39,14 +39,11 @@ namespace MediaBrowser.Server.Implementations.Library.Validators .Distinct(StringComparer.OrdinalIgnoreCase) .ToList(); - progress.Report(2); var numComplete = 0; var count = items.Count; foreach (var name in items) { - cancellationToken.ThrowIfCancellationRequested(); - try { var itemByName = _libraryManager.GetMusicGenre(name); @@ -66,9 +63,9 @@ namespace MediaBrowser.Server.Implementations.Library.Validators numComplete++; double percent = numComplete; percent /= count; - percent *= 90; + percent *= 100; - progress.Report(percent + 10); + progress.Report(percent); } progress.Report(100); diff --git a/MediaBrowser.Server.Implementations/Library/Validators/StudiosPostScanTask.cs b/MediaBrowser.Server.Implementations/Library/Validators/StudiosPostScanTask.cs index 0f998b0708..0ff609da15 100644 --- a/MediaBrowser.Server.Implementations/Library/Validators/StudiosPostScanTask.cs +++ b/MediaBrowser.Server.Implementations/Library/Validators/StudiosPostScanTask.cs @@ -1,4 +1,5 @@ using MediaBrowser.Controller.Library; +using MediaBrowser.Model.Logging; using System; using System.Threading; using System.Threading.Tasks; @@ -15,13 +16,16 @@ namespace MediaBrowser.Server.Implementations.Library.Validators /// private readonly ILibraryManager _libraryManager; + private readonly ILogger _logger; + /// /// Initializes a new instance of the class. /// /// The library manager. - public StudiosPostScanTask(ILibraryManager libraryManager) + public StudiosPostScanTask(ILibraryManager libraryManager, ILogger logger) { _libraryManager = libraryManager; + _logger = logger; } /// @@ -32,7 +36,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators /// Task. public Task Run(IProgress progress, CancellationToken cancellationToken) { - return ((LibraryManager)_libraryManager).ValidateStudios(cancellationToken, progress); + return new StudiosValidator(_libraryManager, _logger).Run(progress, cancellationToken); } } } diff --git a/MediaBrowser.Server.Implementations/Library/Validators/StudiosValidator.cs b/MediaBrowser.Server.Implementations/Library/Validators/StudiosValidator.cs index a2ec9788c7..643deef014 100644 --- a/MediaBrowser.Server.Implementations/Library/Validators/StudiosValidator.cs +++ b/MediaBrowser.Server.Implementations/Library/Validators/StudiosValidator.cs @@ -14,20 +14,14 @@ namespace MediaBrowser.Server.Implementations.Library.Validators /// private readonly ILibraryManager _libraryManager; - /// - /// The _user manager - /// - private readonly IUserManager _userManager; - /// /// The _logger /// private readonly ILogger _logger; - public StudiosValidator(ILibraryManager libraryManager, IUserManager userManager, ILogger logger) + public StudiosValidator(ILibraryManager libraryManager, ILogger logger) { _libraryManager = libraryManager; - _userManager = userManager; _logger = logger; } @@ -44,14 +38,11 @@ namespace MediaBrowser.Server.Implementations.Library.Validators .Distinct(StringComparer.OrdinalIgnoreCase) .ToList(); - progress.Report(2); var numComplete = 0; var count = items.Count; foreach (var name in items) { - cancellationToken.ThrowIfCancellationRequested(); - try { var itemByName = _libraryManager.GetStudio(name); @@ -71,9 +62,9 @@ namespace MediaBrowser.Server.Implementations.Library.Validators numComplete++; double percent = numComplete; percent /= count; - percent *= 90; + percent *= 100; - progress.Report(percent + 10); + progress.Report(percent); } progress.Report(100); diff --git a/MediaBrowser.Server.Implementations/Library/Validators/YearsPostScanTask.cs b/MediaBrowser.Server.Implementations/Library/Validators/YearsPostScanTask.cs index 78783db90a..5b8f27f58a 100644 --- a/MediaBrowser.Server.Implementations/Library/Validators/YearsPostScanTask.cs +++ b/MediaBrowser.Server.Implementations/Library/Validators/YearsPostScanTask.cs @@ -26,17 +26,15 @@ namespace MediaBrowser.Server.Implementations.Library.Validators .Distinct() .ToList(); - progress.Report(10); - var count = allYears.Count; var numComplete = 0; foreach (var yearNumber in allYears) { - var year = _libraryManager.GetYear(yearNumber); - try { + var year = _libraryManager.GetYear(yearNumber); + await year.RefreshMetadata(cancellationToken).ConfigureAwait(false); } catch (OperationCanceledException) @@ -46,15 +44,15 @@ namespace MediaBrowser.Server.Implementations.Library.Validators } catch (Exception ex) { - _logger.ErrorException("Error refreshing year {0}", ex, year); + _logger.ErrorException("Error refreshing year {0}", ex, yearNumber); } numComplete++; double percent = numComplete; percent /= count; - percent *= 90; + percent *= 100; - progress.Report(percent + 10); + progress.Report(percent); } } } diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs index 96498563e6..74069e5801 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs @@ -436,40 +436,19 @@ namespace MediaBrowser.Server.Implementations.LiveTv private async Task GetChannel(ChannelInfo channelInfo, string serviceName, CancellationToken cancellationToken) { - var path = Path.Combine(_config.ApplicationPaths.ItemsByNamePath, "tvchannels", _fileSystem.GetValidFilename(channelInfo.Name)); - - var fileInfo = new DirectoryInfo(path); - var isNew = false; - if (!fileInfo.Exists) - { - _logger.Debug("Creating directory {0}", path); - - Directory.CreateDirectory(path); - fileInfo = new DirectoryInfo(path); - - if (!fileInfo.Exists) - { - throw new IOException("Path not created: " + path); - } - - isNew = true; - } - var id = _tvDtoService.GetInternalChannelId(serviceName, channelInfo.Id); var item = _itemRepo.RetrieveItem(id) as LiveTvChannel; - if (item == null || !string.Equals(item.Path, path, StringComparison.OrdinalIgnoreCase)) + if (item == null) { item = new LiveTvChannel { Name = channelInfo.Name, Id = id, - DateCreated = _fileSystem.GetCreationTimeUtc(fileInfo), - DateModified = _fileSystem.GetLastWriteTimeUtc(fileInfo), - Path = path + DateCreated = DateTime.UtcNow, }; isNew = true; -- cgit v1.2.3 From a8da86d059c0a9ba724bfcf11166d1b32406ca89 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 17 Jan 2015 14:30:23 -0500 Subject: support api without /mediabrowser --- MediaBrowser.Api/Playback/BaseStreamingService.cs | 2 +- MediaBrowser.Api/Playback/Hls/MpegDashService.cs | 2 +- MediaBrowser.Controller/IServerApplicationHost.cs | 28 --------- MediaBrowser.Dlna/Main/DlnaEntryPoint.cs | 2 +- MediaBrowser.Dlna/Server/DescriptionXmlBuilder.cs | 24 ++++---- MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs | 2 +- MediaBrowser.Model/System/SystemInfo.cs | 12 ---- .../Connect/ConnectManager.cs | 1 - .../HttpServer/HttpListenerHost.cs | 68 +++++++++++++--------- .../HttpServer/ServerFactory.cs | 4 +- .../Library/UserManager.cs | 2 +- .../Localization/Server/server.json | 8 ++- .../ApplicationHost.cs | 20 ++----- .../Browser/BrowserLauncher.cs | 6 +- .../BackgroundServiceInstaller.cs | 2 +- 15 files changed, 71 insertions(+), 112 deletions(-) (limited to 'MediaBrowser.Controller') diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index 84dd0c1e8d..e70c1e5733 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -857,7 +857,7 @@ namespace MediaBrowser.Api.Playback { if (SupportsThrottleWithStream) { - var url = "http://localhost:" + ServerConfigurationManager.Configuration.HttpServerPortNumber.ToString(UsCulture) + "/mediabrowser/videos/" + state.Request.Id + "/stream?static=true&Throttle=true&mediaSourceId=" + state.Request.MediaSourceId; + var url = "http://localhost:" + ServerConfigurationManager.Configuration.HttpServerPortNumber.ToString(UsCulture) + "/videos/" + state.Request.Id + "/stream?static=true&Throttle=true&mediaSourceId=" + state.Request.MediaSourceId; url += "&transcodingJobId=" + transcodingJobId; diff --git a/MediaBrowser.Api/Playback/Hls/MpegDashService.cs b/MediaBrowser.Api/Playback/Hls/MpegDashService.cs index 514597c3e1..a0b67a2209 100644 --- a/MediaBrowser.Api/Playback/Hls/MpegDashService.cs +++ b/MediaBrowser.Api/Playback/Hls/MpegDashService.cs @@ -625,7 +625,7 @@ namespace MediaBrowser.Api.Playback.Hls protected override string GetCommandLineArguments(string outputPath, string transcodingJobId, StreamState state, bool isEncoding) { - // test url http://192.168.1.2:8096/mediabrowser/videos/233e8905d559a8f230db9bffd2ac9d6d/master.mpd?mediasourceid=233e8905d559a8f230db9bffd2ac9d6d&videocodec=h264&audiocodec=aac&maxwidth=1280&videobitrate=500000&audiobitrate=128000&profile=baseline&level=3 + // test url http://192.168.1.2:8096/videos/233e8905d559a8f230db9bffd2ac9d6d/master.mpd?mediasourceid=233e8905d559a8f230db9bffd2ac9d6d&videocodec=h264&audiocodec=aac&maxwidth=1280&videobitrate=500000&audiobitrate=128000&profile=baseline&level=3 // Good info on i-frames http://blog.streamroot.io/encode-multi-bitrate-videos-mpeg-dash-mse-based-media-players/ var threads = GetNumberOfThreads(state, false); diff --git a/MediaBrowser.Controller/IServerApplicationHost.cs b/MediaBrowser.Controller/IServerApplicationHost.cs index 6bee5e58a3..181c14debe 100644 --- a/MediaBrowser.Controller/IServerApplicationHost.cs +++ b/MediaBrowser.Controller/IServerApplicationHost.cs @@ -18,12 +18,6 @@ namespace MediaBrowser.Controller /// SystemInfo. SystemInfo GetSystemInfo(); - /// - /// Gets the name of the web application. - /// - /// The name of the web application. - string WebApplicationName { get; } - /// /// Gets a value indicating whether [supports automatic run at startup]. /// @@ -36,28 +30,6 @@ namespace MediaBrowser.Controller /// The HTTP server port. int HttpServerPort { get; } - /// - /// Gets the HTTPS server port. - /// - /// The HTTPS server port. - int HttpsServerPort { get; } - - /// - /// Gets the value indiciating if an https port should be hosted. - /// - /// - /// The value indiciating if an https port should be hosted. - /// - bool UseHttps { get; } - - /// - /// Gets the value pointing to the file system where the ssl certiifcate is located. - /// - /// - /// The value pointing to the file system where the ssl certiifcate is located. - /// - string CertificatePath { get; } - /// /// Gets a value indicating whether this instance has update available. /// diff --git a/MediaBrowser.Dlna/Main/DlnaEntryPoint.cs b/MediaBrowser.Dlna/Main/DlnaEntryPoint.cs index 810b1e5684..bcb539ac8d 100644 --- a/MediaBrowser.Dlna/Main/DlnaEntryPoint.cs +++ b/MediaBrowser.Dlna/Main/DlnaEntryPoint.cs @@ -165,7 +165,7 @@ namespace MediaBrowser.Dlna.Main { var guid = address.GetMD5(); - var descriptorURI = "/mediabrowser/dlna/" + guid.ToString("N") + "/description.xml"; + var descriptorURI = "/dlna/" + guid.ToString("N") + "/description.xml"; var uri = new Uri(string.Format("http://{0}:{1}{2}", address, _config.Configuration.HttpServerPortNumber, descriptorURI)); diff --git a/MediaBrowser.Dlna/Server/DescriptionXmlBuilder.cs b/MediaBrowser.Dlna/Server/DescriptionXmlBuilder.cs index f4f724d07a..545da7a86f 100644 --- a/MediaBrowser.Dlna/Server/DescriptionXmlBuilder.cs +++ b/MediaBrowser.Dlna/Server/DescriptionXmlBuilder.cs @@ -139,7 +139,7 @@ namespace MediaBrowser.Dlna.Server Depth = "24", Width = 240, Height = 240, - Url = "/mediabrowser/dlna/icons/logo240.png" + Url = "/dlna/icons/logo240.png" }); list.Add(new DeviceIcon @@ -148,7 +148,7 @@ namespace MediaBrowser.Dlna.Server Depth = "24", Width = 240, Height = 240, - Url = "/mediabrowser/dlna/icons/logo240.jpg" + Url = "/dlna/icons/logo240.jpg" }); list.Add(new DeviceIcon @@ -157,7 +157,7 @@ namespace MediaBrowser.Dlna.Server Depth = "24", Width = 120, Height = 120, - Url = "/mediabrowser/dlna/icons/logo120.png" + Url = "/dlna/icons/logo120.png" }); list.Add(new DeviceIcon @@ -166,7 +166,7 @@ namespace MediaBrowser.Dlna.Server Depth = "24", Width = 120, Height = 120, - Url = "/mediabrowser/dlna/icons/logo120.jpg" + Url = "/dlna/icons/logo120.jpg" }); list.Add(new DeviceIcon @@ -175,7 +175,7 @@ namespace MediaBrowser.Dlna.Server Depth = "24", Width = 48, Height = 48, - Url = "/mediabrowser/dlna/icons/logo48.png" + Url = "/dlna/icons/logo48.png" }); list.Add(new DeviceIcon @@ -184,7 +184,7 @@ namespace MediaBrowser.Dlna.Server Depth = "24", Width = 48, Height = 48, - Url = "/mediabrowser/dlna/icons/logo48.jpg" + Url = "/dlna/icons/logo48.jpg" }); return list; @@ -198,18 +198,18 @@ namespace MediaBrowser.Dlna.Server { ServiceType = "urn:schemas-upnp-org:service:ContentDirectory:1", ServiceId = "urn:upnp-org:serviceId:ContentDirectory", - ScpdUrl = "/mediabrowser/dlna/contentdirectory/contentdirectory.xml", - ControlUrl = "/mediabrowser/dlna/contentdirectory/" + _serverUdn + "/control", - EventSubUrl = "/mediabrowser/dlna/contentdirectory/" + _serverUdn + "/events" + ScpdUrl = "/dlna/contentdirectory/contentdirectory.xml", + ControlUrl = "/dlna/contentdirectory/" + _serverUdn + "/control", + EventSubUrl = "/dlna/contentdirectory/" + _serverUdn + "/events" }); list.Add(new DeviceService { ServiceType = "urn:schemas-upnp-org:service:ConnectionManager:1", ServiceId = "urn:upnp-org:serviceId:ConnectionManager", - ScpdUrl = "/mediabrowser/dlna/connectionmanager/connectionmanager.xml", - ControlUrl = "/mediabrowser/dlna/connectionmanager/" + _serverUdn + "/control", - EventSubUrl = "/mediabrowser/dlna/connectionmanager/" + _serverUdn + "/events" + ScpdUrl = "/dlna/connectionmanager/connectionmanager.xml", + ControlUrl = "/dlna/connectionmanager/" + _serverUdn + "/control", + EventSubUrl = "/dlna/connectionmanager/" + _serverUdn + "/events" }); return list; diff --git a/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs index 4dc522f05c..b357b04178 100644 --- a/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs +++ b/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs @@ -461,7 +461,7 @@ namespace MediaBrowser.MediaEncoding.Encoder // { // if (SupportsThrottleWithStream) // { - // var url = "http://localhost:" + ServerConfigurationManager.Configuration.HttpServerPortNumber.ToString(UsCulture) + "/mediabrowser/videos/" + job.Request.Id + "/stream?static=true&Throttle=true&mediaSourceId=" + job.Request.MediaSourceId; + // var url = "http://localhost:" + ServerConfigurationManager.Configuration.HttpServerPortNumber.ToString(UsCulture) + "/videos/" + job.Request.Id + "/stream?static=true&Throttle=true&mediaSourceId=" + job.Request.MediaSourceId; // url += "&transcodingJobId=" + transcodingJobId; diff --git a/MediaBrowser.Model/System/SystemInfo.cs b/MediaBrowser.Model/System/SystemInfo.cs index 9d4cfd6dbd..5a91978279 100644 --- a/MediaBrowser.Model/System/SystemInfo.cs +++ b/MediaBrowser.Model/System/SystemInfo.cs @@ -122,18 +122,6 @@ namespace MediaBrowser.Model.System /// The HTTP server port number. public int HttpServerPortNumber { get; set; } - /// - /// Gets or sets the value pointing to the file system where the ssl certiifcate is located. - /// - /// The value pointing to the file system where the ssl certiifcate is located. - public bool UseHttps { get; set; } - - /// - /// Gets or sets the value pointing to the file system where the ssl certiifcate is located.. - /// - /// The value pointing to the file system where the ssl certiifcate is located.. - public string CertificatePath { get; set; } - /// /// Gets or sets the HTTPS server port number. /// diff --git a/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs b/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs index 9625593d10..194a8a4a23 100644 --- a/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs +++ b/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs @@ -1,5 +1,4 @@ using MediaBrowser.Common.Configuration; -using MediaBrowser.Common.Extensions; using MediaBrowser.Common.Net; using MediaBrowser.Controller; using MediaBrowser.Controller.Configuration; diff --git a/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs b/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs index 0c0922800a..1d7e89d285 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs @@ -24,7 +24,6 @@ namespace MediaBrowser.Server.Implementations.HttpServer { public class HttpListenerHost : ServiceStackHost, IHttpServer { - private string HandlerPath { get; set; } private string DefaultRedirectPath { get; set; } private readonly ILogger _logger; @@ -64,18 +63,16 @@ namespace MediaBrowser.Server.Implementations.HttpServer } } - public HttpListenerHost(IApplicationHost applicationHost, - ILogManager logManager, - string serviceName, - string handlerPath, - string defaultRedirectPath, - bool supportsNativeWebSocket, + public HttpListenerHost(IApplicationHost applicationHost, + ILogManager logManager, + string serviceName, + string defaultRedirectPath, + bool supportsNativeWebSocket, params Assembly[] assembliesWithServices) : base(serviceName, assembliesWithServices) { DefaultRedirectPath = defaultRedirectPath; _supportsNativeWebSocket = supportsNativeWebSocket; - HandlerPath = handlerPath; _logger = logManager.GetLogger("HttpServer"); @@ -136,13 +133,9 @@ namespace MediaBrowser.Server.Implementations.HttpServer { base.OnConfigLoad(); - Config.HandlerFactoryPath = string.IsNullOrEmpty(HandlerPath) - ? null - : HandlerPath; + Config.HandlerFactoryPath = null; - Config.MetadataRedirectPath = string.IsNullOrEmpty(HandlerPath) - ? "metadata" - : PathUtils.CombinePaths(HandlerPath, "metadata"); + Config.MetadataRedirectPath = "metadata"; } protected override ServiceController CreateServiceController(params Assembly[] assembliesWithServices) @@ -245,7 +238,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer { return; } - + var errorResponse = new ErrorResponse { ResponseStatus = new ResponseStatus @@ -314,24 +307,24 @@ namespace MediaBrowser.Server.Implementations.HttpServer var operationName = httpReq.OperationName; var localPath = url.LocalPath; - if (string.Equals(localPath, "/" + HandlerPath + "/", StringComparison.OrdinalIgnoreCase)) + if (string.Equals(localPath, "/mediabrowser/", StringComparison.OrdinalIgnoreCase)) { - httpRes.RedirectToUrl(DefaultRedirectPath); + httpRes.RedirectToUrl("/../" + DefaultRedirectPath); return Task.FromResult(true); } - if (string.Equals(localPath, "/" + HandlerPath, StringComparison.OrdinalIgnoreCase)) + if (string.Equals(localPath, "/mediabrowser", StringComparison.OrdinalIgnoreCase)) { - httpRes.RedirectToUrl(HandlerPath + "/" + DefaultRedirectPath); + httpRes.RedirectToUrl("../" + DefaultRedirectPath); return Task.FromResult(true); } if (string.Equals(localPath, "/", StringComparison.OrdinalIgnoreCase)) { - httpRes.RedirectToUrl(HandlerPath + "/" + DefaultRedirectPath); + httpRes.RedirectToUrl(DefaultRedirectPath); return Task.FromResult(true); } if (string.IsNullOrEmpty(localPath)) { - httpRes.RedirectToUrl("/" + HandlerPath + "/" + DefaultRedirectPath); + httpRes.RedirectToUrl("/" + DefaultRedirectPath); return Task.FromResult(true); } @@ -386,12 +379,33 @@ namespace MediaBrowser.Server.Implementations.HttpServer base.Init(); } - //public override RouteAttribute[] GetRouteAttributes(System.Type requestType) - //{ - // var routes = base.GetRouteAttributes(requestType); - // routes.Each(x => x.Path = "/api" + x.Path); - // return routes; - //} + public override RouteAttribute[] GetRouteAttributes(Type requestType) + { + var routes = base.GetRouteAttributes(requestType).ToList(); + var clone = routes.ToList(); + + foreach (var route in clone) + { + routes.Add(new RouteAttribute(NormalizeRoutePath(route.Path), route.Verbs) + { + Notes = route.Notes, + Priority = route.Priority, + Summary = route.Summary + }); + } + + return routes.ToArray(); + } + + private string NormalizeRoutePath(string path) + { + if (path.StartsWith("/", StringComparison.OrdinalIgnoreCase)) + { + return "/mediabrowser" + path; + } + + return "mediabrowser/" + path; + } /// /// Releases the specified instance. diff --git a/MediaBrowser.Server.Implementations/HttpServer/ServerFactory.cs b/MediaBrowser.Server.Implementations/HttpServer/ServerFactory.cs index b48703a15f..73d7610601 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/ServerFactory.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/ServerFactory.cs @@ -16,20 +16,18 @@ namespace MediaBrowser.Server.Implementations.HttpServer /// The application host. /// The log manager. /// Name of the server. - /// The handler path. /// The default redirectpath. /// if set to true [supports native web socket]. /// IHttpServer. public static IHttpServer CreateServer(IApplicationHost applicationHost, ILogManager logManager, string serverName, - string handlerPath, string defaultRedirectpath, bool supportsNativeWebSocket) { LogManager.LogFactory = new ServerLogFactory(logManager); - return new HttpListenerHost(applicationHost, logManager, serverName, handlerPath, defaultRedirectpath, supportsNativeWebSocket); + return new HttpListenerHost(applicationHost, logManager, serverName, defaultRedirectpath, supportsNativeWebSocket); } } } diff --git a/MediaBrowser.Server.Implementations/Library/UserManager.cs b/MediaBrowser.Server.Implementations/Library/UserManager.cs index b51a9ee7cd..edcf7255d7 100644 --- a/MediaBrowser.Server.Implementations/Library/UserManager.cs +++ b/MediaBrowser.Server.Implementations/Library/UserManager.cs @@ -744,7 +744,7 @@ namespace MediaBrowser.Server.Implementations.Library text.AppendLine("Use your web browser to visit:"); text.AppendLine(string.Empty); - text.AppendLine(localAddress + "/mediabrowser/web/forgotpasswordpin.html"); + text.AppendLine(localAddress + "/web/forgotpasswordpin.html"); text.AppendLine(string.Empty); text.AppendLine("Enter the following pin code:"); text.AppendLine(string.Empty); diff --git a/MediaBrowser.Server.Implementations/Localization/Server/server.json b/MediaBrowser.Server.Implementations/Localization/Server/server.json index 253d9a00db..1ed5ddb4fd 100644 --- a/MediaBrowser.Server.Implementations/Localization/Server/server.json +++ b/MediaBrowser.Server.Implementations/Localization/Server/server.json @@ -46,6 +46,7 @@ "HeaderTV": "TV", "HeaderAudio": "Audio", "HeaderVideo": "Video", + "HeaderPaths": "Paths", "OptionDetectArchiveFilesAsMedia": "Detect archive files as media", "OptionDetectArchiveFilesAsMediaHelp": "If enabled, files with .rar and .zip extensions will be detected as media files.", "LabelEnterConnectUserName": "User name or email:", @@ -321,8 +322,8 @@ "LabelAutomaticUpdatesFanartHelp": "If enabled, new images will be downloaded automatically as they're added to fanart.tv. Existing images will not be replaced.", "LabelAutomaticUpdatesTmdbHelp": "If enabled, new images will be downloaded automatically as they're added to TheMovieDB.org. Existing images will not be replaced.", "LabelAutomaticUpdatesTvdbHelp": "If enabled, new images will be downloaded automatically as they're added to TheTVDB.com. Existing images will not be replaced.", - "LabelFanartApiKey": "Personal api key:", - "LabelFanartApiKeyHelp": "Requests to fanart without a personal API key return results that were approved over 7 days ago. With a personal API key that drops to 48 hours and if you are also a fanart VIP member that will further drop to around 10 minutes.", + "LabelFanartApiKey": "Personal api key:", + "LabelFanartApiKeyHelp": "Requests to fanart without a personal API key return results that were approved over 7 days ago. With a personal API key that drops to 48 hours and if you are also a fanart VIP member that will further drop to around 10 minutes.", "ExtractChapterImagesHelp": "Extracting chapter images will allow clients to display graphical scene selection menus. The process can be slow, cpu-intensive and may require several gigabytes of space. It runs when videos are discovered, and also as a nightly scheduled task at 4am. The schedule is configurable in the scheduled tasks area. It is not recommended to run this task during peak usage hours.", "LabelMetadataDownloadLanguage": "Preferred download language:", "ButtonAutoScroll": "Auto-scroll", @@ -492,6 +493,7 @@ "HeaderSystemPaths": "System Paths", "LinkCommunity": "Community", "LinkGithub": "Github", + "LinkApi": "Api", "LinkApiDocumentation": "Api Documentation", "LabelFriendlyServerName": "Friendly server name:", "LabelFriendlyServerNameHelp": "This name will be used to identify this server. If left blank, the computer name will be used.", @@ -511,7 +513,7 @@ "LabelUseHttps": "Enable SSL", "LabelUseHttpsHelp": "Check to enable SSL hosting.", - "LabelHttpsPort": "Local http port:", + "LabelHttpsPort": "Local http port:", "LabelHttpsPortHelp": "The tcp port number that Media Browser's https server should bind to.", "LabelCertificatePath": "SSL Certificate path:", "LabelCertificatePathHelp": "The path on the filesystem to the ssl certificate pfx file.", diff --git a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs index 29c5304382..0d8b651904 100644 --- a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs +++ b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs @@ -130,12 +130,12 @@ namespace MediaBrowser.Server.Startup.Common { var list = new List { - "http://+:" + ServerConfigurationManager.Configuration.HttpServerPortNumber + "/" + WebApplicationName + "/" + "http://+:" + ServerConfigurationManager.Configuration.HttpServerPortNumber + "/" }; if (ServerConfigurationManager.Configuration.UseHttps) { - list.Add("https://+:" + ServerConfigurationManager.Configuration.HttpsPortNumber + "/" + WebApplicationName + "/"); + list.Add("https://+:" + ServerConfigurationManager.Configuration.HttpsPortNumber + "/"); } return list; @@ -472,7 +472,7 @@ namespace MediaBrowser.Server.Startup.Common _supportsNativeWebSocket = false; } - HttpServer = ServerFactory.CreateServer(this, LogManager, "Media Browser", WebApplicationName, "dashboard/index.html", false); + HttpServer = ServerFactory.CreateServer(this, LogManager, "Media Browser", "web/index.html", false); RegisterSingleInstance(HttpServer, false); progress.Report(10); @@ -810,7 +810,7 @@ namespace MediaBrowser.Server.Startup.Common { try { - ServerManager.Start(HttpServerUrlPrefixes, CertificatePath); + ServerManager.Start(HttpServerUrlPrefixes, ServerConfigurationManager.Configuration.CertificatePath); } catch (Exception ex) { @@ -977,8 +977,6 @@ namespace MediaBrowser.Server.Startup.Common CachePath = ApplicationPaths.CachePath, MacAddress = GetMacAddress(), HttpServerPortNumber = HttpServerPort, - UseHttps = UseHttps, - CertificatePath = CertificatePath, OperatingSystem = OperatingSystemDisplayName, CanSelfRestart = CanSelfRestart, CanSelfUpdate = CanSelfUpdate, @@ -1053,16 +1051,6 @@ namespace MediaBrowser.Server.Startup.Common get { return ServerConfigurationManager.Configuration.HttpServerPortNumber; } } - public bool UseHttps - { - get { return this.ServerConfigurationManager.Configuration.UseHttps; } - } - - public string CertificatePath - { - get { return this.ServerConfigurationManager.Configuration.CertificatePath; } - } - public int HttpsServerPort { get { return ServerConfigurationManager.Configuration.HttpsPortNumber; } diff --git a/MediaBrowser.Server.Startup.Common/Browser/BrowserLauncher.cs b/MediaBrowser.Server.Startup.Common/Browser/BrowserLauncher.cs index 97f6b89d78..bb78cc02f8 100644 --- a/MediaBrowser.Server.Startup.Common/Browser/BrowserLauncher.cs +++ b/MediaBrowser.Server.Startup.Common/Browser/BrowserLauncher.cs @@ -18,8 +18,7 @@ namespace MediaBrowser.Server.Startup.Common.Browser /// The logger. public static void OpenDashboardPage(string page, IServerApplicationHost appHost, ILogger logger) { - var url = "http://localhost:" + appHost.HttpServerPort + "/" + - appHost.WebApplicationName + "/web/" + page; + var url = "http://localhost:" + appHost.HttpServerPort + "/web/" + page; OpenUrl(url, logger); } @@ -69,8 +68,7 @@ namespace MediaBrowser.Server.Startup.Common.Browser /// The logger. public static void OpenSwagger(IServerApplicationHost appHost, ILogger logger) { - OpenUrl("http://localhost:" + appHost.HttpServerPort + "/" + - appHost.WebApplicationName + "/swagger-ui/index.html", logger); + OpenUrl("http://localhost:" + appHost.HttpServerPort + "/swagger-ui/index.html", logger); } /// diff --git a/MediaBrowser.ServerApplication/BackgroundServiceInstaller.cs b/MediaBrowser.ServerApplication/BackgroundServiceInstaller.cs index 27ddfeb955..15cab6c197 100644 --- a/MediaBrowser.ServerApplication/BackgroundServiceInstaller.cs +++ b/MediaBrowser.ServerApplication/BackgroundServiceInstaller.cs @@ -25,7 +25,7 @@ namespace MediaBrowser.ServerApplication Description = "The windows background service for Media Browser Server.", // Will ensure the network is available - ServicesDependedOn = new[] { "LanmanServer" } + ServicesDependedOn = new[] { "LanmanServer", "Tcpip" } }; // Microsoft didn't add the ability to add a -- cgit v1.2.3 From cefd565e67ce3b8225eb2fa8a7338dc4d85b458d Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 18 Jan 2015 14:53:34 -0500 Subject: display server name in dashboard --- MediaBrowser.Api/Playback/BaseStreamingService.cs | 2 +- .../MediaEncoding/ISubtitleEncoder.cs | 3 +- MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs | 2 +- .../Subtitles/SubtitleEncoder.cs | 65 +++++++++++++--------- .../Configuration/ServerConfiguration.cs | 3 - MediaBrowser.Providers/Movies/MovieDbSearch.cs | 9 +-- .../HttpServer/HttpListenerHost.cs | 11 ---- .../HttpServer/ServerFactory.cs | 6 +- .../Localization/JavaScript/javascript.json | 3 + .../Localization/Server/server.json | 4 +- .../ApplicationHost.cs | 14 +---- 11 files changed, 52 insertions(+), 70 deletions(-) (limited to 'MediaBrowser.Controller') diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index 56dc38e91f..9253bc369b 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -629,7 +629,7 @@ namespace MediaBrowser.Api.Playback if (!string.IsNullOrEmpty(state.SubtitleStream.Language)) { - var charenc = SubtitleEncoder.GetSubtitleFileCharacterSet(subtitlePath, state.SubtitleStream.Language); + var charenc = SubtitleEncoder.GetSubtitleFileCharacterSet(subtitlePath); if (!string.IsNullOrEmpty(charenc)) { diff --git a/MediaBrowser.Controller/MediaEncoding/ISubtitleEncoder.cs b/MediaBrowser.Controller/MediaEncoding/ISubtitleEncoder.cs index 9e32fc32b0..37c2bf4d2e 100644 --- a/MediaBrowser.Controller/MediaEncoding/ISubtitleEncoder.cs +++ b/MediaBrowser.Controller/MediaEncoding/ISubtitleEncoder.cs @@ -47,9 +47,8 @@ namespace MediaBrowser.Controller.MediaEncoding /// Gets the subtitle language encoding parameter. /// /// The path. - /// The language. /// System.String. - string GetSubtitleFileCharacterSet(string path, string language); + string GetSubtitleFileCharacterSet(string path); } } diff --git a/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs index b357b04178..344eb9fbdf 100644 --- a/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs +++ b/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs @@ -1015,7 +1015,7 @@ namespace MediaBrowser.MediaEncoding.Encoder if (!string.IsNullOrEmpty(state.SubtitleStream.Language)) { - var charenc = SubtitleEncoder.GetSubtitleFileCharacterSet(subtitlePath, state.SubtitleStream.Language); + var charenc = SubtitleEncoder.GetSubtitleFileCharacterSet(subtitlePath); if (!string.IsNullOrEmpty(charenc)) { diff --git a/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs b/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs index 10d8112ff0..4723525e38 100644 --- a/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs +++ b/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs @@ -149,22 +149,22 @@ namespace MediaBrowser.MediaEncoding.Subtitles var fileInfo = await GetReadableFile(mediaSource.Path, inputFiles, mediaSource.Protocol, subtitleStream, cancellationToken).ConfigureAwait(false); - var stream = await GetSubtitleStream(fileInfo.Item1, subtitleStream.Language, fileInfo.Item3).ConfigureAwait(false); + var stream = await GetSubtitleStream(fileInfo.Item1, fileInfo.Item3).ConfigureAwait(false); return new Tuple(stream, fileInfo.Item2); } - private async Task GetSubtitleStream(string path, string language, bool requiresCharset) + private async Task GetSubtitleStream(string path, bool requiresCharset) { - if (requiresCharset && !string.IsNullOrEmpty(language)) + if (requiresCharset) { - var charset = GetSubtitleFileCharacterSet(path, language); + var charset = GetSubtitleFileCharacterSet(path); if (!string.IsNullOrEmpty(charset)) { using (var fs = _fileSystem.GetFileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, true)) { - using (var reader = new StreamReader(fs, Encoding.GetEncoding(charset))) + using (var reader = new StreamReader(fs, GetEncoding(charset))) { var text = await reader.ReadToEndAsync().ConfigureAwait(false); @@ -179,6 +179,23 @@ namespace MediaBrowser.MediaEncoding.Subtitles return File.OpenRead(path); } + private Encoding GetEncoding(string charset) + { + if (string.IsNullOrWhiteSpace(charset)) + { + throw new ArgumentNullException("charset"); + } + + try + { + return Encoding.GetEncoding(charset); + } + catch (ArgumentException) + { + return Encoding.GetEncoding(charset.Replace("-", string.Empty)); + } + } + private async Task> GetReadableFile(string mediaPath, string[] inputFiles, MediaProtocol protocol, @@ -227,8 +244,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles // Convert var outputPath = GetSubtitleCachePath(mediaPath, subtitleStream.Index, ".srt"); - await ConvertTextSubtitleToSrt(subtitleStream.Path, outputPath, subtitleStream.Language, cancellationToken) - .ConfigureAwait(false); + await ConvertTextSubtitleToSrt(subtitleStream.Path, outputPath, cancellationToken).ConfigureAwait(false); return new Tuple(outputPath, "srt", true); } @@ -321,11 +337,9 @@ namespace MediaBrowser.MediaEncoding.Subtitles /// /// The input path. /// The output path. - /// The language. /// The cancellation token. /// Task. - public async Task ConvertTextSubtitleToSrt(string inputPath, string outputPath, string language, - CancellationToken cancellationToken) + public async Task ConvertTextSubtitleToSrt(string inputPath, string outputPath, CancellationToken cancellationToken) { var semaphore = GetLock(outputPath); @@ -335,7 +349,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles { if (!File.Exists(outputPath)) { - await ConvertTextSubtitleToSrtInternal(inputPath, outputPath, language).ConfigureAwait(false); + await ConvertTextSubtitleToSrtInternal(inputPath, outputPath).ConfigureAwait(false); } } finally @@ -349,15 +363,12 @@ namespace MediaBrowser.MediaEncoding.Subtitles /// /// The input path. /// The output path. - /// The language. /// Task. - /// - /// inputPath + /// inputPath /// or - /// outputPath - /// + /// outputPath /// - private async Task ConvertTextSubtitleToSrtInternal(string inputPath, string outputPath, string language) + private async Task ConvertTextSubtitleToSrtInternal(string inputPath, string outputPath) { if (string.IsNullOrEmpty(inputPath)) { @@ -371,9 +382,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles Directory.CreateDirectory(Path.GetDirectoryName(outputPath)); - var encodingParam = string.IsNullOrEmpty(language) - ? string.Empty - : GetSubtitleFileCharacterSet(inputPath, language); + var encodingParam = GetSubtitleFileCharacterSet(inputPath); if (!string.IsNullOrEmpty(encodingParam)) { @@ -696,10 +705,14 @@ namespace MediaBrowser.MediaEncoding.Subtitles /// Gets the subtitle language encoding param. /// /// The path. - /// The language. /// System.String. - public string GetSubtitleFileCharacterSet(string path, string language) + public string GetSubtitleFileCharacterSet(string path) { + if (GetFileEncoding(path).Equals(Encoding.UTF8)) + { + return string.Empty; + } + var charset = DetectCharset(path); if (!string.IsNullOrWhiteSpace(charset)) @@ -712,11 +725,11 @@ namespace MediaBrowser.MediaEncoding.Subtitles return charset; } - if (GetFileEncoding(path).Equals(Encoding.UTF8)) - { - return string.Empty; - } + return null; + } + public string GetSubtitleFileCharacterSetFromLanguage(string language) + { switch (language.ToLower()) { case "pol": diff --git a/MediaBrowser.Model/Configuration/ServerConfiguration.cs b/MediaBrowser.Model/Configuration/ServerConfiguration.cs index e51cca7708..a2a909dcc5 100644 --- a/MediaBrowser.Model/Configuration/ServerConfiguration.cs +++ b/MediaBrowser.Model/Configuration/ServerConfiguration.cs @@ -191,8 +191,6 @@ namespace MediaBrowser.Model.Configuration public bool SaveMetadataHidden { get; set; } - public bool EnableWin8HttpListener { get; set; } - public NameValuePair[] ContentTypes { get; set; } public bool EnableAudioArchiveFiles { get; set; } @@ -214,7 +212,6 @@ namespace MediaBrowser.Model.Configuration EnableDashboardResourceMinification = true; EnableAutomaticRestart = true; - EnableWin8HttpListener = true; EnableUPnP = true; diff --git a/MediaBrowser.Providers/Movies/MovieDbSearch.cs b/MediaBrowser.Providers/Movies/MovieDbSearch.cs index ae176e4897..f1ccd1c304 100644 --- a/MediaBrowser.Providers/Movies/MovieDbSearch.cs +++ b/MediaBrowser.Providers/Movies/MovieDbSearch.cs @@ -183,14 +183,7 @@ namespace MediaBrowser.Providers.Movies if (DateTime.TryParseExact(result.release_date, "yyyy-MM-dd", EnUs, DateTimeStyles.None, out r)) { // Allow one year tolernace, preserve order from Tmdb - var variance = Math.Abs(r.Year - year.Value); - - if (variance <= 1) - { - return 0; - } - - return variance; + return Math.Abs(r.Year - year.Value); } } diff --git a/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs b/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs index 1d7e89d285..7022dc76d5 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs @@ -41,8 +41,6 @@ namespace MediaBrowser.Server.Implementations.HttpServer private readonly ReaderWriterLockSlim _localEndpointLock = new ReaderWriterLockSlim(); - private readonly bool _supportsNativeWebSocket; - private string _certificatePath; /// @@ -67,12 +65,10 @@ namespace MediaBrowser.Server.Implementations.HttpServer ILogManager logManager, string serviceName, string defaultRedirectPath, - bool supportsNativeWebSocket, params Assembly[] assembliesWithServices) : base(serviceName, assembliesWithServices) { DefaultRedirectPath = defaultRedirectPath; - _supportsNativeWebSocket = supportsNativeWebSocket; _logger = logManager.GetLogger("HttpServer"); @@ -210,13 +206,6 @@ namespace MediaBrowser.Server.Implementations.HttpServer private IHttpListener GetListener() { - if (_supportsNativeWebSocket && NativeWebSocket.IsSupported) - { - // Certificate location is ignored here. You need to use netsh - // to assign the certificate to the proper port. - return new HttpListenerServer(_logger, OnRequestReceived); - } - return new WebSocketSharpListener(_logger, OnRequestReceived, _certificatePath); } diff --git a/MediaBrowser.Server.Implementations/HttpServer/ServerFactory.cs b/MediaBrowser.Server.Implementations/HttpServer/ServerFactory.cs index 73d7610601..d1222ab746 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/ServerFactory.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/ServerFactory.cs @@ -17,17 +17,15 @@ namespace MediaBrowser.Server.Implementations.HttpServer /// The log manager. /// Name of the server. /// The default redirectpath. - /// if set to true [supports native web socket]. /// IHttpServer. public static IHttpServer CreateServer(IApplicationHost applicationHost, ILogManager logManager, string serverName, - string defaultRedirectpath, - bool supportsNativeWebSocket) + string defaultRedirectpath) { LogManager.LogFactory = new ServerLogFactory(logManager); - return new HttpListenerHost(applicationHost, logManager, serverName, defaultRedirectpath, supportsNativeWebSocket); + return new HttpListenerHost(applicationHost, logManager, serverName, defaultRedirectpath); } } } diff --git a/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json b/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json index ad7a0aef09..5235f46a9d 100644 --- a/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json +++ b/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json @@ -591,6 +591,8 @@ "MediaInfoStreamTypeEmbeddedImage": "Embedded Image", "MediaInfoRefFrames": "Ref frames", "TabPlayback": "Playback", + "TabNotifications": "Notifications", + "TabExpert": "Expert", "HeaderSelectCustomIntrosPath": "Select Custom Intros Path", "HeaderRateAndReview": "Rate and Review", "HeaderThankYou": "Thank You", @@ -625,6 +627,7 @@ "DashboardTourMobile": "The Media Browser dashboard works great on smartphones and tablets. Manage your server from the palm of your hand anytime, anywhere.", "MessageRefreshQueued": "Refresh queued", "TabDevices": "Devices", + "TabExtras": "Extras", "DeviceLastUsedByUserName": "Last used by {0}", "HeaderDeleteDevice": "Delete Device", "DeleteDeviceConfirmation": "Are you sure you wish to delete this device? It will reappear the next time a user signs in with it.", diff --git a/MediaBrowser.Server.Implementations/Localization/Server/server.json b/MediaBrowser.Server.Implementations/Localization/Server/server.json index 37948cb3f4..dc74c5f860 100644 --- a/MediaBrowser.Server.Implementations/Localization/Server/server.json +++ b/MediaBrowser.Server.Implementations/Localization/Server/server.json @@ -42,7 +42,7 @@ "ButtonTermsOfService": "Terms of Service", "HeaderDeveloperOptions": "Developer Options", "OptionEnableWebClientResponseCache": "Enable web client response caching", - "OptionDisableForDevelopmentHelp": "Disable these for web client development purposes", + "OptionDisableForDevelopmentHelp": "Configure these as needed for web client development purposes.", "OptionEnableWebClientResourceMinification": "Enable web client resource minification", "LabelDashboardSourcePath": "Web client source path:", "LabelDashboardSourcePathHelp": "If running the server from source, specify the path to the dashboard-ui folder. All web client files will be served from this location.", @@ -53,6 +53,7 @@ "HeaderAudio": "Audio", "HeaderVideo": "Video", "HeaderPaths": "Paths", + "TitleNotifications": "Notifications", "ButtonDonateWithPayPal": "Donate with PayPal", "OptionDetectArchiveFilesAsMedia": "Detect archive files as media", "OptionDetectArchiveFilesAsMediaHelp": "If enabled, files with .rar and .zip extensions will be detected as media files.", @@ -71,6 +72,7 @@ "FolderTypeTvShows": "TV", "FolderTypeInherit": "Inherit", "LabelContentType": "Content type:", + "TitleScheduledTasks": "Scheduled Tasks", "HeaderSetupLibrary": "Setup your media library", "ButtonAddMediaFolder": "Add media folder", "LabelFolderType": "Folder type:", diff --git a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs index e15b60d479..3867fc243f 100644 --- a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs +++ b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs @@ -460,19 +460,7 @@ namespace MediaBrowser.Server.Startup.Common RegisterSingleInstance(() => new SearchEngine(LogManager, LibraryManager, UserManager)); - if (IsFirstRun) - { - ServerConfigurationManager.Configuration.EnableWin8HttpListener = false; - ServerConfigurationManager.SaveConfiguration(); - _supportsNativeWebSocket = false; - } - - if (!ServerConfigurationManager.Configuration.EnableWin8HttpListener) - { - _supportsNativeWebSocket = false; - } - - HttpServer = ServerFactory.CreateServer(this, LogManager, "Media Browser", "web/index.html", false); + HttpServer = ServerFactory.CreateServer(this, LogManager, "Media Browser", "web/index.html"); RegisterSingleInstance(HttpServer, false); progress.Report(10); -- cgit v1.2.3 From de76156391655f726b5655f727e06822398827ca Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 18 Jan 2015 23:29:57 -0500 Subject: rework hosting options --- MediaBrowser.Api/Playback/BaseStreamingService.cs | 2 +- MediaBrowser.Controller/Entities/Movies/BoxSet.cs | 26 +++++ MediaBrowser.Controller/IServerApplicationHost.cs | 14 ++- MediaBrowser.Controller/Net/IHttpServer.cs | 7 +- MediaBrowser.Dlna/Main/DlnaEntryPoint.cs | 2 +- MediaBrowser.Dlna/PlayTo/PlayToManager.cs | 2 +- .../Configuration/ServerConfiguration.cs | 4 +- MediaBrowser.Model/System/SystemInfo.cs | 10 +- .../BoxSets/BoxSetMetadataService.cs | 18 +-- MediaBrowser.Providers/TV/SeriesMetadataService.cs | 13 --- .../Collections/CollectionManager.cs | 6 +- .../Connect/ConnectManager.cs | 31 +++++- .../EntryPoints/ExternalPortForwarding.cs | 80 ++++++++------ .../HttpServer/HttpListenerHost.cs | 7 +- .../SocketSharp/WebSocketSharpListener.cs | 2 +- .../Localization/JavaScript/javascript.json | 5 +- .../Localization/Server/server.json | 15 ++- MediaBrowser.Server.Mono/Program.cs | 2 +- .../ApplicationHost.cs | 122 +++++++++++---------- .../Browser/BrowserLauncher.cs | 4 +- MediaBrowser.ServerApplication/MainStartup.cs | 1 - MediaBrowser.WebDashboard/Api/PackageCreator.cs | 1 + .../MediaBrowser.WebDashboard.csproj | 6 + 23 files changed, 224 insertions(+), 156 deletions(-) (limited to 'MediaBrowser.Controller') diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index 9253bc369b..6d403c8986 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -858,7 +858,7 @@ namespace MediaBrowser.Api.Playback if (SupportsThrottleWithStream) { var url = "http://localhost:" + ServerConfigurationManager.Configuration.HttpServerPortNumber.ToString(UsCulture) + "/videos/" + state.Request.Id + "/stream?static=true&Throttle=true&mediaSourceId=" + state.Request.MediaSourceId; - + url += "&transcodingJobId=" + transcodingJobId; return string.Format("\"{0}\"", url); diff --git a/MediaBrowser.Controller/Entities/Movies/BoxSet.cs b/MediaBrowser.Controller/Entities/Movies/BoxSet.cs index 4483c7b0f2..e48b8d8457 100644 --- a/MediaBrowser.Controller/Entities/Movies/BoxSet.cs +++ b/MediaBrowser.Controller/Entities/Movies/BoxSet.cs @@ -1,4 +1,5 @@ using MediaBrowser.Common.Progress; +using MediaBrowser.Controller.Entities.TV; using MediaBrowser.Controller.Providers; using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Entities; @@ -93,6 +94,31 @@ namespace MediaBrowser.Controller.Entities.Movies return list; } + /// + /// Updates the official rating based on content and returns true or false indicating if it changed. + /// + /// + public bool UpdateRatingToContent() + { + var currentOfficialRating = OfficialRating; + + // Gather all possible ratings + var ratings = RecursiveChildren + .Concat(GetLinkedChildren()) + .Where(i => i is Movie || i is Series) + .Select(i => i.OfficialRating) + .Where(i => !string.IsNullOrEmpty(i)) + .Distinct(StringComparer.OrdinalIgnoreCase) + .Select(i => new Tuple(i, LocalizationManager.GetRatingLevel(i))) + .OrderBy(i => i.Item2 ?? 1000) + .Select(i => i.Item1); + + OfficialRating = ratings.FirstOrDefault() ?? currentOfficialRating; + + return !string.Equals(currentOfficialRating ?? string.Empty, OfficialRating ?? string.Empty, + StringComparison.OrdinalIgnoreCase); + } + public override IEnumerable GetChildren(User user, bool includeLinkedChildren) { var children = base.GetChildren(user, includeLinkedChildren); diff --git a/MediaBrowser.Controller/IServerApplicationHost.cs b/MediaBrowser.Controller/IServerApplicationHost.cs index 181c14debe..0b0f6d8287 100644 --- a/MediaBrowser.Controller/IServerApplicationHost.cs +++ b/MediaBrowser.Controller/IServerApplicationHost.cs @@ -28,7 +28,19 @@ namespace MediaBrowser.Controller /// Gets the HTTP server port. /// /// The HTTP server port. - int HttpServerPort { get; } + int HttpPort { get; } + + /// + /// Gets the HTTPS port. + /// + /// The HTTPS port. + int HttpsPort { get; } + + /// + /// Gets a value indicating whether [supports HTTPS]. + /// + /// true if [supports HTTPS]; otherwise, false. + bool EnableHttps { get; } /// /// Gets a value indicating whether this instance has update available. diff --git a/MediaBrowser.Controller/Net/IHttpServer.cs b/MediaBrowser.Controller/Net/IHttpServer.cs index d56bee009e..315b48b837 100644 --- a/MediaBrowser.Controller/Net/IHttpServer.cs +++ b/MediaBrowser.Controller/Net/IHttpServer.cs @@ -1,4 +1,3 @@ -using MediaBrowser.Common.Net; using System; using System.Collections.Generic; @@ -15,6 +14,12 @@ namespace MediaBrowser.Controller.Net /// The URL prefix. IEnumerable UrlPrefixes { get; } + /// + /// Gets the certificate path. + /// + /// The certificate path. + string CertificatePath { get; } + /// /// Starts the specified server name. /// diff --git a/MediaBrowser.Dlna/Main/DlnaEntryPoint.cs b/MediaBrowser.Dlna/Main/DlnaEntryPoint.cs index bcb539ac8d..c75f2e40cd 100644 --- a/MediaBrowser.Dlna/Main/DlnaEntryPoint.cs +++ b/MediaBrowser.Dlna/Main/DlnaEntryPoint.cs @@ -167,7 +167,7 @@ namespace MediaBrowser.Dlna.Main var descriptorURI = "/dlna/" + guid.ToString("N") + "/description.xml"; - var uri = new Uri(string.Format("http://{0}:{1}{2}", address, _config.Configuration.HttpServerPortNumber, descriptorURI)); + var uri = new Uri(string.Format("http://{0}:{1}{2}", address, _appHost.HttpPort, descriptorURI)); var services = new List { diff --git a/MediaBrowser.Dlna/PlayTo/PlayToManager.cs b/MediaBrowser.Dlna/PlayTo/PlayToManager.cs index a60b5efa48..5e37417c66 100644 --- a/MediaBrowser.Dlna/PlayTo/PlayToManager.cs +++ b/MediaBrowser.Dlna/PlayTo/PlayToManager.cs @@ -152,7 +152,7 @@ namespace MediaBrowser.Dlna.PlayTo "http", localIp, - _appHost.HttpServerPort + _appHost.HttpPort ); } diff --git a/MediaBrowser.Model/Configuration/ServerConfiguration.cs b/MediaBrowser.Model/Configuration/ServerConfiguration.cs index a2a909dcc5..94bd30d0b4 100644 --- a/MediaBrowser.Model/Configuration/ServerConfiguration.cs +++ b/MediaBrowser.Model/Configuration/ServerConfiguration.cs @@ -36,7 +36,7 @@ namespace MediaBrowser.Model.Configuration /// Gets or sets a value indicating whether [use HTTPS]. /// /// true if [use HTTPS]; otherwise, false. - public bool UseHttps { get; set; } + public bool EnableHttps { get; set; } /// /// Gets or sets the value pointing to the file system where the ssl certiifcate is located.. @@ -206,7 +206,7 @@ namespace MediaBrowser.Model.Configuration PublicPort = 8096; HttpServerPortNumber = 8096; HttpsPortNumber = 8920; - UseHttps = false; + EnableHttps = false; CertificatePath = null; EnableDashboardResponseCaching = true; EnableDashboardResourceMinification = true; diff --git a/MediaBrowser.Model/System/SystemInfo.cs b/MediaBrowser.Model/System/SystemInfo.cs index 0d0c0cddbe..ff9d822dd1 100644 --- a/MediaBrowser.Model/System/SystemInfo.cs +++ b/MediaBrowser.Model/System/SystemInfo.cs @@ -122,11 +122,11 @@ namespace MediaBrowser.Model.System /// The HTTP server port number. public int HttpServerPortNumber { get; set; } - /// - /// Gets or sets the value pointing to the file system where the ssl certiifcate is located. - /// - /// The value pointing to the file system where the ssl certiifcate is located. - public bool UseHttps { get; set; } + /// + /// Gets or sets a value indicating whether [enable HTTPS]. + /// + /// true if [enable HTTPS]; otherwise, false. + public bool EnableHttps { get; set; } /// /// Gets or sets the HTTPS server port number. diff --git a/MediaBrowser.Providers/BoxSets/BoxSetMetadataService.cs b/MediaBrowser.Providers/BoxSets/BoxSetMetadataService.cs index 5e16ed69cf..e195df7dd7 100644 --- a/MediaBrowser.Providers/BoxSets/BoxSetMetadataService.cs +++ b/MediaBrowser.Providers/BoxSets/BoxSetMetadataService.cs @@ -60,23 +60,7 @@ namespace MediaBrowser.Providers.BoxSets { if (!item.LockedFields.Contains(MetadataFields.OfficialRating)) { - var currentOfficialRating = item.OfficialRating; - - // Gather all possible ratings - var ratings = item.RecursiveChildren - .Concat(item.GetLinkedChildren()) - .Where(i => i is Movie || i is Series) - .Select(i => i.OfficialRating) - .Where(i => !string.IsNullOrEmpty(i)) - .Distinct(StringComparer.OrdinalIgnoreCase) - .Select(i => new Tuple(i, _iLocalizationManager.GetRatingLevel(i))) - .OrderBy(i => i.Item2 ?? 1000) - .Select(i => i.Item1); - - item.OfficialRating = ratings.FirstOrDefault() ?? item.OfficialRating; - - if (!string.Equals(currentOfficialRating ?? string.Empty, item.OfficialRating ?? string.Empty, - StringComparison.OrdinalIgnoreCase)) + if (item.UpdateRatingToContent()) { updateType = updateType | ItemUpdateType.MetadataEdit; } diff --git a/MediaBrowser.Providers/TV/SeriesMetadataService.cs b/MediaBrowser.Providers/TV/SeriesMetadataService.cs index 62e5ff4fc6..e03104a23b 100644 --- a/MediaBrowser.Providers/TV/SeriesMetadataService.cs +++ b/MediaBrowser.Providers/TV/SeriesMetadataService.cs @@ -8,8 +8,6 @@ using MediaBrowser.Model.Entities; using MediaBrowser.Model.Logging; using MediaBrowser.Providers.Manager; using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; namespace MediaBrowser.Providers.TV { @@ -61,16 +59,5 @@ namespace MediaBrowser.Providers.TV target.DisplaySpecialsWithSeasons = source.DisplaySpecialsWithSeasons; } } - - protected override async Task BeforeSave(Series item, bool isFullRefresh, ItemUpdateType currentUpdateType) - { - var updateType = await base.BeforeSave(item, isFullRefresh, currentUpdateType).ConfigureAwait(false); - - //var provider = new DummySeasonProvider(ServerConfigurationManager, Logger, _localization, _libraryManager); - - //await provider.Run(item, CancellationToken.None).ConfigureAwait(false); - - return updateType; - } } } diff --git a/MediaBrowser.Server.Implementations/Collections/CollectionManager.cs b/MediaBrowser.Server.Implementations/Collections/CollectionManager.cs index 05efcaa1c9..28f3ed89cf 100644 --- a/MediaBrowser.Server.Implementations/Collections/CollectionManager.cs +++ b/MediaBrowser.Server.Implementations/Collections/CollectionManager.cs @@ -184,8 +184,9 @@ namespace MediaBrowser.Server.Implementations.Collections collection.LinkedChildren.AddRange(list); - await collection.UpdateToRepository(ItemUpdateType.MetadataEdit, CancellationToken.None).ConfigureAwait(false); + collection.UpdateRatingToContent(); + await collection.UpdateToRepository(ItemUpdateType.MetadataEdit, CancellationToken.None).ConfigureAwait(false); await collection.RefreshMetadata(CancellationToken.None).ConfigureAwait(false); if (fireEvent) @@ -274,8 +275,9 @@ namespace MediaBrowser.Server.Implementations.Collections } } - await collection.UpdateToRepository(ItemUpdateType.MetadataEdit, CancellationToken.None).ConfigureAwait(false); + collection.UpdateRatingToContent(); + await collection.UpdateToRepository(ItemUpdateType.MetadataEdit, CancellationToken.None).ConfigureAwait(false); await collection.RefreshMetadata(CancellationToken.None).ConfigureAwait(false); EventHelper.FireEventIfNotNull(ItemsRemovedFromCollection, this, new CollectionModifiedEventArgs diff --git a/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs b/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs index 194a8a4a23..d3a29f4205 100644 --- a/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs +++ b/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs @@ -78,7 +78,7 @@ namespace MediaBrowser.Server.Implementations.Connect if (!ip.StartsWith("http://", StringComparison.OrdinalIgnoreCase) && !ip.StartsWith("https://", StringComparison.OrdinalIgnoreCase)) { - ip = (_config.Configuration.UseHttps ? "https://" : "http://") + ip; + ip = (_appHost.EnableHttps ? "https://" : "http://") + ip; } return ip + ":" + _config.Configuration.PublicPort.ToString(CultureInfo.InvariantCulture); @@ -90,7 +90,7 @@ namespace MediaBrowser.Server.Implementations.Connect private string XApplicationValue { - get { return "Media Browser Server/" + _appHost.ApplicationVersion; } + get { return _appHost.Name + "/" + _appHost.ApplicationVersion; } } public ConnectManager(ILogger logger, @@ -112,6 +112,7 @@ namespace MediaBrowser.Server.Implementations.Connect _providerManager = providerManager; _userManager.UserConfigurationUpdated += _userManager_UserConfigurationUpdated; + _config.ConfigurationUpdated += _config_ConfigurationUpdated; LoadCachedData(); } @@ -164,8 +165,7 @@ namespace MediaBrowser.Server.Implementations.Connect } catch (HttpException ex) { - if (!ex.StatusCode.HasValue || - !new[] { HttpStatusCode.NotFound, HttpStatusCode.Unauthorized }.Contains(ex.StatusCode.Value)) + if (!ex.StatusCode.HasValue || !new[] { HttpStatusCode.NotFound, HttpStatusCode.Unauthorized }.Contains(ex.StatusCode.Value)) { throw; } @@ -179,6 +179,8 @@ namespace MediaBrowser.Server.Implementations.Connect await CreateServerRegistration(wanApiAddress, localAddress).ConfigureAwait(false); } + _lastReportedIdentifier = GetConnectReportingIdentifier(localAddress, wanApiAddress); + await RefreshAuthorizationsInternal(true, CancellationToken.None).ConfigureAwait(false); } catch (Exception ex) @@ -187,6 +189,27 @@ namespace MediaBrowser.Server.Implementations.Connect } } + private string _lastReportedIdentifier; + private string GetConnectReportingIdentifier() + { + return GetConnectReportingIdentifier(_appHost.GetSystemInfo().LocalAddress, WanApiAddress); + } + private string GetConnectReportingIdentifier(string localAddress, string remoteAddress) + { + return (remoteAddress ?? string.Empty) + (localAddress ?? string.Empty); + } + + void _config_ConfigurationUpdated(object sender, EventArgs e) + { + // If info hasn't changed, don't report anything + if (string.Equals(_lastReportedIdentifier, GetConnectReportingIdentifier(), StringComparison.OrdinalIgnoreCase)) + { + return; + } + + UpdateConnectInfo(); + } + private async Task CreateServerRegistration(string wanApiAddress, string localAddress) { if (string.IsNullOrWhiteSpace(wanApiAddress)) diff --git a/MediaBrowser.Server.Implementations/EntryPoints/ExternalPortForwarding.cs b/MediaBrowser.Server.Implementations/EntryPoints/ExternalPortForwarding.cs index e32068905d..4371739b76 100644 --- a/MediaBrowser.Server.Implementations/EntryPoints/ExternalPortForwarding.cs +++ b/MediaBrowser.Server.Implementations/EntryPoints/ExternalPortForwarding.cs @@ -5,6 +5,7 @@ using MediaBrowser.Model.Logging; using Mono.Nat; using System; using System.Collections.Generic; +using System.Globalization; using System.IO; using System.Text; using System.Threading; @@ -17,30 +18,44 @@ namespace MediaBrowser.Server.Implementations.EntryPoints private readonly ILogger _logger; private readonly IServerConfigurationManager _config; - private bool _isStarted; - private Timer _timer; + private bool _isStarted; public ExternalPortForwarding(ILogManager logmanager, IServerApplicationHost appHost, IServerConfigurationManager config) { _logger = logmanager.GetLogger("PortMapper"); _appHost = appHost; _config = config; + } - _config.ConfigurationUpdated += _config_ConfigurationUpdated; + private string _lastConfigIdentifier; + private string GetConfigIdentifier() + { + var values = new List(); + var config = _config.Configuration; + + values.Add(config.EnableUPnP.ToString()); + values.Add(config.PublicPort.ToString(CultureInfo.InvariantCulture)); + values.Add(_appHost.HttpPort.ToString(CultureInfo.InvariantCulture)); + values.Add(_appHost.HttpsPort.ToString(CultureInfo.InvariantCulture)); + values.Add(config.EnableHttps.ToString()); + values.Add(_appHost.EnableHttps.ToString()); + + return string.Join("|", values.ToArray()); } void _config_ConfigurationUpdated(object sender, EventArgs e) { - var enable = _config.Configuration.EnableUPnP; - - if (enable && !_isStarted) - { - Reload(); - } - else if (!enable && _isStarted) + _config.ConfigurationUpdated -= _config_ConfigurationUpdated; + + if (!string.Equals(_lastConfigIdentifier, GetConfigIdentifier(), StringComparison.OrdinalIgnoreCase)) { - DisposeNat(); + if (_isStarted) + { + DisposeNat(); + } + + Run(); } } @@ -48,31 +63,36 @@ namespace MediaBrowser.Server.Implementations.EntryPoints { //NatUtility.Logger = new LogWriter(_logger); - Reload(); + if (_config.Configuration.EnableUPnP) + { + Start(); + } + + _config.ConfigurationUpdated -= _config_ConfigurationUpdated; + _config.ConfigurationUpdated += _config_ConfigurationUpdated; } - private void Reload() + private void Start() { - if (_config.Configuration.EnableUPnP) - { - _logger.Debug("Starting NAT discovery"); + _logger.Debug("Starting NAT discovery"); - NatUtility.DeviceFound += NatUtility_DeviceFound; + NatUtility.DeviceFound += NatUtility_DeviceFound; - // Mono.Nat does never rise this event. The event is there however it is useless. - // You could remove it with no risk. - NatUtility.DeviceLost += NatUtility_DeviceLost; + // Mono.Nat does never rise this event. The event is there however it is useless. + // You could remove it with no risk. + NatUtility.DeviceLost += NatUtility_DeviceLost; - // it is hard to say what one should do when an unhandled exception is raised - // because there isn't anything one can do about it. Probably save a log or ignored it. - NatUtility.UnhandledException += NatUtility_UnhandledException; - NatUtility.StartDiscovery(); + // it is hard to say what one should do when an unhandled exception is raised + // because there isn't anything one can do about it. Probably save a log or ignored it. + NatUtility.UnhandledException += NatUtility_UnhandledException; + NatUtility.StartDiscovery(); - _isStarted = true; + _timer = new Timer(s => _createdRules = new List(), null, TimeSpan.FromMinutes(5), TimeSpan.FromMinutes(5)); - _timer = new Timer(s => _createdRules = new List(), null, TimeSpan.FromMinutes(10), TimeSpan.FromMinutes(10)); - } + _lastConfigIdentifier = GetConfigIdentifier(); + + _isStarted = true; } void NatUtility_UnhandledException(object sender, UnhandledExceptionEventArgs e) @@ -124,9 +144,7 @@ namespace MediaBrowser.Server.Implementations.EntryPoints { _createdRules.Add(address); - var info = _appHost.GetSystemInfo(); - - CreatePortMap(device, info.HttpServerPortNumber, _config.Configuration.PublicPort); + CreatePortMap(device, _appHost.HttpPort, _config.Configuration.PublicPort); } } @@ -136,7 +154,7 @@ namespace MediaBrowser.Server.Implementations.EntryPoints device.CreatePortMap(new Mapping(Protocol.Tcp, privatePort, publicPort) { - Description = "Media Browser Server" + Description = _appHost.Name }); } diff --git a/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs b/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs index 7022dc76d5..f64e29e4db 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs @@ -3,7 +3,6 @@ using MediaBrowser.Common; using MediaBrowser.Common.Extensions; using MediaBrowser.Controller.Net; using MediaBrowser.Model.Logging; -using MediaBrowser.Server.Implementations.HttpServer.NetListener; using MediaBrowser.Server.Implementations.HttpServer.SocketSharp; using ServiceStack; using ServiceStack.Api.Swagger; @@ -41,7 +40,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer private readonly ReaderWriterLockSlim _localEndpointLock = new ReaderWriterLockSlim(); - private string _certificatePath; + public string CertificatePath { get; private set; } /// /// Gets the local end points. @@ -206,7 +205,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer private IHttpListener GetListener() { - return new WebSocketSharpListener(_logger, OnRequestReceived, _certificatePath); + return new WebSocketSharpListener(_logger, OnRequestReceived, CertificatePath); } private void WebSocketHandler(WebSocketConnectEventArgs args) @@ -434,7 +433,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer public void StartServer(IEnumerable urlPrefixes, string certificatePath) { - _certificatePath = certificatePath; + CertificatePath = certificatePath; UrlPrefixes = urlPrefixes.ToList(); Start(UrlPrefixes.First()); } diff --git a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpListener.cs b/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpListener.cs index 1cf523ad29..0c5c9e9bf1 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpListener.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpListener.cs @@ -3,12 +3,12 @@ using MediaBrowser.Model.Logging; using MediaBrowser.Server.Implementations.Logging; using ServiceStack; using ServiceStack.Web; +using SocketHttpListener.Net; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using SocketHttpListener.Net; namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp { diff --git a/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json b/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json index 5235f46a9d..8e41dda307 100644 --- a/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json +++ b/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json @@ -192,9 +192,10 @@ "LabelPlayMethodDirectPlay": "Direct Playing", "LabelAudioCodec": "Audio: {0}", "LabelVideoCodec": "Video: {0}", + "LabelLocalAccessUrl": "Local access: {0}", "LabelRemoteAccessUrl": "Remote access: {0}", - "LabelRunningOnPort": "Running on port {0}.", - "LabelRunningOnHttpsPort": "Running on SSL port {0}.", + "LabelRunningOnPort": "Running on http port {0}.", + "LabelRunningOnPorts": "Running on http port {0}, and https port {1}.", "HeaderLatestFromChannel": "Latest from {0}", "ButtonDownload": "Download", "LabelUnknownLanaguage": "Unknown language", diff --git a/MediaBrowser.Server.Implementations/Localization/Server/server.json b/MediaBrowser.Server.Implementations/Localization/Server/server.json index dc74c5f860..683a5a6392 100644 --- a/MediaBrowser.Server.Implementations/Localization/Server/server.json +++ b/MediaBrowser.Server.Implementations/Localization/Server/server.json @@ -519,19 +519,17 @@ "LabelLocalHttpServerPortNumberHelp": "The tcp port number that Media Browser's http server should bind to.", "LabelPublicPort": "Public port number:", "LabelPublicPortHelp": "The public port number that should be mapped to the local port.", - - "LabelUseHttps": "Enable SSL", - "LabelUseHttpsHelp": "Check to enable SSL hosting.", - "LabelHttpsPort": "Local http port:", + "LabelEnableHttps": "Enable https for remote connections", + "LabelEnableHttpsHelp": "If enabled, the server will report an https url as it's external address.", + "LabelHttpsPort": "Local https port:", "LabelHttpsPortHelp": "The tcp port number that Media Browser's https server should bind to.", "LabelCertificatePath": "SSL Certificate path:", - "LabelCertificatePathHelp": "The path on the filesystem to the ssl certificate pfx file.", - + "LabelCertificatePathHelp": "The path on the file system to the ssl certificate .pfx file.", "LabelWebSocketPortNumber": "Web socket port number:", "LabelEnableAutomaticPortMap": "Enable automatic port mapping", "LabelEnableAutomaticPortMapHelp": "Attempt to automatically map the public port to the local port via UPnP. This may not work with some router models.", - "LabelExternalDDNS": "External DDNS:", - "LabelExternalDDNSHelp": "If you have a dynamic DNS enter it here. Media Browser apps will use it when connecting remotely.", + "LabelExternalDDNS": "External WAN Address:", + "LabelExternalDDNSHelp": "If you have a dynamic DNS enter it here. Media Browser apps will use it when connecting remotely. Leave empty for automatic detection.", "TabResume": "Resume", "TabWeather": "Weather", "TitleAppSettings": "App Settings", @@ -600,6 +598,7 @@ "ButtonRestart": "Restart", "ButtonShutdown": "Shutdown", "ButtonUpdateNow": "Update Now", + "TabHosting": "Hosting", "PleaseUpdateManually": "Please shutdown the server and update manually.", "NewServerVersionAvailable": "A new version of Media Browser Server is available!", "ServerUpToDate": "Media Browser Server is up to date", diff --git a/MediaBrowser.Server.Mono/Program.cs b/MediaBrowser.Server.Mono/Program.cs index 1cd0b5ae6b..10a6c6fb91 100644 --- a/MediaBrowser.Server.Mono/Program.cs +++ b/MediaBrowser.Server.Mono/Program.cs @@ -78,7 +78,7 @@ namespace MediaBrowser.Server.Mono var nativeApp = new NativeApp(); - _appHost = new ApplicationHost(appPaths, logManager, options, fileSystem, "MBServer.Mono", false, nativeApp); + _appHost = new ApplicationHost(appPaths, logManager, options, fileSystem, "MBServer.Mono", nativeApp); if (options.ContainsOption("-v")) { Console.WriteLine (_appHost.ApplicationVersion.ToString()); diff --git a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs index b71aa2adb6..16cf4258a4 100644 --- a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs +++ b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs @@ -110,38 +110,6 @@ namespace MediaBrowser.Server.Startup.Common get { return (IServerConfigurationManager)ConfigurationManager; } } - /// - /// Gets the name of the web application that can be used for url building. - /// All api urls will be of the form {protocol}://{host}:{port}/{appname}/... - /// - /// The name of the web application. - public string WebApplicationName - { - get { return "mediabrowser"; } - } - - /// - /// Gets the HTTP server URL prefix. - /// - /// The HTTP server URL prefix. - private IEnumerable HttpServerUrlPrefixes - { - get - { - var list = new List - { - "http://+:" + ServerConfigurationManager.Configuration.HttpServerPortNumber + "/" - }; - - if (ServerConfigurationManager.Configuration.UseHttps) - { - list.Add("https://+:" + ServerConfigurationManager.Configuration.HttpsPortNumber + "/"); - } - - return list; - } - } - /// /// Gets the configuration manager. /// @@ -230,8 +198,6 @@ namespace MediaBrowser.Server.Startup.Common private readonly StartupOptions _startupOptions; private readonly string _remotePackageName; - private bool _supportsNativeWebSocket; - internal INativeApp NativeApp { get; set; } /// @@ -242,20 +208,17 @@ namespace MediaBrowser.Server.Startup.Common /// The options. /// The file system. /// Name of the remote package. - /// if set to true [supports native web socket]. /// The native application. public ApplicationHost(ServerApplicationPaths applicationPaths, ILogManager logManager, StartupOptions options, IFileSystem fileSystem, string remotePackageName, - bool supportsNativeWebSocket, INativeApp nativeApp) : base(applicationPaths, logManager, fileSystem) { _startupOptions = options; _remotePackageName = remotePackageName; - _supportsNativeWebSocket = supportsNativeWebSocket; NativeApp = nativeApp; SetBaseExceptionMessage(); @@ -359,6 +322,9 @@ namespace MediaBrowser.Server.Startup.Common public override async Task Init(IProgress progress) { + HttpPort = ServerConfigurationManager.Configuration.HttpServerPortNumber; + HttpsPort = ServerConfigurationManager.Configuration.HttpsPortNumber; + PerformPreInitMigrations(); await base.Init(progress).ConfigureAwait(false); @@ -586,10 +552,10 @@ namespace MediaBrowser.Server.Startup.Common new FFmpegValidator(Logger, ApplicationPaths).Validate(info); - MediaEncoder = new MediaEncoder(LogManager.GetLogger("MediaEncoder"), - JsonSerializer, - info.EncoderPath, - info.ProbePath, + MediaEncoder = new MediaEncoder(LogManager.GetLogger("MediaEncoder"), + JsonSerializer, + info.EncoderPath, + info.ProbePath, info.Version, ServerConfigurationManager, FileSystemManager, @@ -791,6 +757,21 @@ namespace MediaBrowser.Server.Startup.Common SyncManager.AddParts(GetExports()); } + private IEnumerable GetUrlPrefixes() + { + var prefixes = new List + { + "http://+:" + ServerConfigurationManager.Configuration.HttpServerPortNumber + "/" + }; + + if (!string.IsNullOrWhiteSpace(ServerConfigurationManager.Configuration.CertificatePath)) + { + prefixes.Add("https://+:" + ServerConfigurationManager.Configuration.HttpsPortNumber + "/"); + } + + return prefixes; + } + /// /// Starts the server. /// @@ -798,7 +779,7 @@ namespace MediaBrowser.Server.Startup.Common { try { - ServerManager.Start(HttpServerUrlPrefixes, ServerConfigurationManager.Configuration.CertificatePath); + ServerManager.Start(GetUrlPrefixes(), ServerConfigurationManager.Configuration.CertificatePath); } catch (Exception ex) { @@ -817,11 +798,29 @@ namespace MediaBrowser.Server.Startup.Common { base.OnConfigurationUpdated(sender, e); - if (!HttpServer.UrlPrefixes.SequenceEqual(HttpServerUrlPrefixes, StringComparer.OrdinalIgnoreCase)) + var requiresRestart = false; + + // Don't do anything if these haven't been set yet + if (HttpPort != 0 && HttpsPort != 0) + { + // Need to restart if ports have changed + if (ServerConfigurationManager.Configuration.HttpServerPortNumber != HttpPort || + ServerConfigurationManager.Configuration.HttpsPortNumber != HttpsPort) + { + ServerConfigurationManager.Configuration.IsPortAuthorized = false; + ServerConfigurationManager.SaveConfiguration(); + + requiresRestart = true; + } + } + + if (!HttpServer.UrlPrefixes.SequenceEqual(GetUrlPrefixes(), StringComparer.OrdinalIgnoreCase)) { - ServerConfigurationManager.Configuration.IsPortAuthorized = false; - ServerConfigurationManager.SaveConfiguration(); + requiresRestart = true; + } + if (requiresRestart) + { NotifyPendingRestart(); } } @@ -953,7 +952,7 @@ namespace MediaBrowser.Server.Startup.Common HasPendingRestart = HasPendingRestart, Version = ApplicationVersion.ToString(), IsNetworkDeployed = CanSelfUpdate, - WebSocketPortNumber = HttpServerPort, + WebSocketPortNumber = HttpPort, FailedPluginAssemblies = FailedAssemblies.ToList(), InProgressInstallations = InstallationManager.CurrentInstallations.Select(i => i.Item1).ToList(), CompletedInstallations = InstallationManager.CompletedInstallations.ToList(), @@ -964,9 +963,9 @@ namespace MediaBrowser.Server.Startup.Common InternalMetadataPath = ApplicationPaths.InternalMetadataPath, CachePath = ApplicationPaths.CachePath, MacAddress = GetMacAddress(), - HttpServerPortNumber = HttpServerPort, - UseHttps = this.ServerConfigurationManager.Configuration.UseHttps, - HttpsPortNumber = HttpsServerPort, + HttpServerPortNumber = HttpPort, + EnableHttps = EnableHttps, + HttpsPortNumber = HttpsPort, OperatingSystem = OperatingSystemDisplayName, CanSelfRestart = CanSelfRestart, CanSelfUpdate = CanSelfUpdate, @@ -981,6 +980,19 @@ namespace MediaBrowser.Server.Startup.Common }; } + public bool EnableHttps + { + get + { + return SupportsHttps && ServerConfigurationManager.Configuration.EnableHttps; + } + } + + public bool SupportsHttps + { + get { return !string.IsNullOrWhiteSpace(HttpServer.CertificatePath); } + } + /// /// Gets the local ip address. /// @@ -994,7 +1006,7 @@ namespace MediaBrowser.Server.Startup.Common { address = string.Format("http://{0}:{1}", address, - ServerConfigurationManager.Configuration.HttpServerPortNumber.ToString(CultureInfo.InvariantCulture)); + HttpPort.ToString(CultureInfo.InvariantCulture)); } return address; @@ -1036,15 +1048,9 @@ namespace MediaBrowser.Server.Startup.Common } } - public int HttpServerPort - { - get { return ServerConfigurationManager.Configuration.HttpServerPortNumber; } - } + public int HttpPort { get; private set; } - public int HttpsServerPort - { - get { return ServerConfigurationManager.Configuration.HttpsPortNumber; } - } + public int HttpsPort { get; private set; } /// /// Gets the mac address. diff --git a/MediaBrowser.Server.Startup.Common/Browser/BrowserLauncher.cs b/MediaBrowser.Server.Startup.Common/Browser/BrowserLauncher.cs index bb78cc02f8..617ff4cae2 100644 --- a/MediaBrowser.Server.Startup.Common/Browser/BrowserLauncher.cs +++ b/MediaBrowser.Server.Startup.Common/Browser/BrowserLauncher.cs @@ -18,7 +18,7 @@ namespace MediaBrowser.Server.Startup.Common.Browser /// The logger. public static void OpenDashboardPage(string page, IServerApplicationHost appHost, ILogger logger) { - var url = "http://localhost:" + appHost.HttpServerPort + "/web/" + page; + var url = "http://localhost:" + appHost.HttpPort + "/web/" + page; OpenUrl(url, logger); } @@ -68,7 +68,7 @@ namespace MediaBrowser.Server.Startup.Common.Browser /// The logger. public static void OpenSwagger(IServerApplicationHost appHost, ILogger logger) { - OpenUrl("http://localhost:" + appHost.HttpServerPort + "/swagger-ui/index.html", logger); + OpenUrl("http://localhost:" + appHost.HttpPort + "/swagger-ui/index.html", logger); } /// diff --git a/MediaBrowser.ServerApplication/MainStartup.cs b/MediaBrowser.ServerApplication/MainStartup.cs index 7532a2edd3..6e8774eea1 100644 --- a/MediaBrowser.ServerApplication/MainStartup.cs +++ b/MediaBrowser.ServerApplication/MainStartup.cs @@ -213,7 +213,6 @@ namespace MediaBrowser.ServerApplication options, fileSystem, "MBServer", - true, nativeApp); var initProgress = new Progress(); diff --git a/MediaBrowser.WebDashboard/Api/PackageCreator.cs b/MediaBrowser.WebDashboard/Api/PackageCreator.cs index 46616043b2..aec7a539ca 100644 --- a/MediaBrowser.WebDashboard/Api/PackageCreator.cs +++ b/MediaBrowser.WebDashboard/Api/PackageCreator.cs @@ -381,6 +381,7 @@ namespace MediaBrowser.WebDashboard.Api "channelsettings.js", "connectlogin.js", "dashboardgeneral.js", + "dashboardhosting.js", "dashboardpage.js", "device.js", "devices.js", diff --git a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj index dbc701b6db..90a358d5cc 100644 --- a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj +++ b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj @@ -96,6 +96,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest @@ -105,6 +108,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest -- cgit v1.2.3 From 1d5f1bc474c3d685e04f409b956ccc431cd05ee5 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 20 Jan 2015 00:19:13 -0500 Subject: sync updates --- MediaBrowser.Api/ConnectService.cs | 8 ++--- MediaBrowser.Api/Playback/BaseStreamingService.cs | 30 ++++++++++++++--- MediaBrowser.Api/Playback/Hls/BaseHlsService.cs | 11 +++---- MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs | 32 ++++++++---------- MediaBrowser.Api/Playback/Hls/MpegDashService.cs | 8 ++--- MediaBrowser.Api/Playback/Hls/VideoHlsService.cs | 4 +-- .../Playback/Progressive/AudioService.cs | 3 +- .../Progressive/BaseProgressiveStreamingService.cs | 8 ++--- .../Playback/Progressive/VideoService.cs | 3 +- MediaBrowser.Api/Session/SessionsService.cs | 8 ++--- MediaBrowser.Controller/Entities/Folder.cs | 5 +-- MediaBrowser.Model/Connect/ConnectAuthorization.cs | 4 +-- .../Connect/ConnectAuthorizationRequest.cs | 4 +-- MediaBrowser.Model/Devices/DeviceQuery.cs | 2 +- MediaBrowser.Model/Session/ClientCapabilities.cs | 9 +++-- MediaBrowser.Model/Users/UserPolicy.cs | 12 +++++-- .../Connect/ConnectManager.cs | 11 ++++--- .../Devices/DeviceManager.cs | 13 +++++--- .../Library/UserManager.cs | 38 +++++++++++++++++++++- .../Localization/JavaScript/javascript.json | 3 ++ .../Localization/Server/server.json | 2 ++ .../ApplicationHost.cs | 2 +- 22 files changed, 146 insertions(+), 74 deletions(-) (limited to 'MediaBrowser.Controller') diff --git a/MediaBrowser.Api/ConnectService.cs b/MediaBrowser.Api/ConnectService.cs index a5ddcb6f1d..4bcd33d9e3 100644 --- a/MediaBrowser.Api/ConnectService.cs +++ b/MediaBrowser.Api/ConnectService.cs @@ -39,8 +39,8 @@ namespace MediaBrowser.Api [ApiMember(Name = "SendingUserId", Description = "Sending User Id", IsRequired = true, DataType = "string", ParameterType = "body", Verb = "POST")] public string SendingUserId { get; set; } - [ApiMember(Name = "ExcludeLibraries", Description = "ExcludeLibraries", IsRequired = true, DataType = "string", ParameterType = "body", Verb = "POST")] - public string ExcludedLibraries { get; set; } + [ApiMember(Name = "EnabledLibraries", Description = "EnabledLibraries", IsRequired = true, DataType = "string", ParameterType = "body", Verb = "POST")] + public string EnabledLibraries { get; set; } [ApiMember(Name = "EnabledChannels", Description = "EnabledChannels", IsRequired = true, DataType = "string", ParameterType = "body", Verb = "POST")] public string EnabledChannels { get; set; } @@ -91,7 +91,7 @@ namespace MediaBrowser.Api public object Post(CreateConnectInvite request) { - var excludeLibraries = (request.ExcludedLibraries ?? string.Empty) + var enabledLibraries = (request.EnabledLibraries ?? string.Empty) .Split(',') .Where(i => !string.IsNullOrWhiteSpace(i)) .ToArray(); @@ -105,7 +105,7 @@ namespace MediaBrowser.Api { ConnectUserName = request.ConnectUsername, SendingUserId = request.SendingUserId, - ExcludedLibraries = excludeLibraries, + EnabledLibraries = enabledLibraries, EnabledChannels = enabledChannels, EnableLiveTv = request.EnableLiveTv }); diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index 271c20f4eb..b3610bc389 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Model.Extensions; +using MediaBrowser.Controller.Devices; +using MediaBrowser.Model.Extensions; using MediaBrowser.Common.Extensions; using MediaBrowser.Common.IO; using MediaBrowser.Controller.Channels; @@ -66,14 +67,16 @@ namespace MediaBrowser.Api.Playback protected ILiveTvManager LiveTvManager { get; private set; } protected IDlnaManager DlnaManager { get; private set; } + protected IDeviceManager DeviceManager { get; private set; } protected IChannelManager ChannelManager { get; private set; } protected ISubtitleEncoder SubtitleEncoder { get; private set; } /// /// Initializes a new instance of the class. /// - protected BaseStreamingService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IFileSystem fileSystem, ILiveTvManager liveTvManager, IDlnaManager dlnaManager, IChannelManager channelManager, ISubtitleEncoder subtitleEncoder) + protected BaseStreamingService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IFileSystem fileSystem, ILiveTvManager liveTvManager, IDlnaManager dlnaManager, IChannelManager channelManager, ISubtitleEncoder subtitleEncoder, IDeviceManager deviceManager) { + DeviceManager = deviceManager; SubtitleEncoder = subtitleEncoder; ChannelManager = channelManager; DlnaManager = dlnaManager; @@ -2030,9 +2033,26 @@ namespace MediaBrowser.Api.Playback headers[key] = Request.Headers[key]; } - state.DeviceProfile = string.IsNullOrWhiteSpace(state.Request.DeviceProfileId) ? - DlnaManager.GetProfile(headers) : - DlnaManager.GetProfile(state.Request.DeviceProfileId); + if (!string.IsNullOrWhiteSpace(state.Request.DeviceProfileId)) + { + state.DeviceProfile = DlnaManager.GetProfile(state.Request.DeviceProfileId); + } + else + { + if (!string.IsNullOrWhiteSpace(state.Request.DeviceId)) + { + var caps = DeviceManager.GetCapabilities(state.Request.DeviceId); + + if (caps != null) + { + state.DeviceProfile = caps.DeviceProfile; + } + else + { + state.DeviceProfile = DlnaManager.GetProfile(headers); + } + } + } var profile = state.DeviceProfile; diff --git a/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs b/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs index 08fa95919b..2da5c33ce8 100644 --- a/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs +++ b/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs @@ -1,20 +1,20 @@ -using MediaBrowser.Model.Extensions; -using MediaBrowser.Common.IO; -using MediaBrowser.Common.Net; +using MediaBrowser.Common.IO; using MediaBrowser.Controller.Channels; using MediaBrowser.Controller.Configuration; +using MediaBrowser.Controller.Devices; using MediaBrowser.Controller.Dlna; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.LiveTv; using MediaBrowser.Controller.MediaEncoding; +using MediaBrowser.Model.Extensions; using MediaBrowser.Model.IO; +using MediaBrowser.Model.Net; using System; using System.Collections.Generic; using System.IO; using System.Text; using System.Threading; using System.Threading.Tasks; -using MediaBrowser.Model.Net; namespace MediaBrowser.Api.Playback.Hls { @@ -23,8 +23,7 @@ namespace MediaBrowser.Api.Playback.Hls /// public abstract class BaseHlsService : BaseStreamingService { - protected BaseHlsService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IFileSystem fileSystem, ILiveTvManager liveTvManager, IDlnaManager dlnaManager, IChannelManager channelManager, ISubtitleEncoder subtitleEncoder) - : base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, fileSystem, liveTvManager, dlnaManager, channelManager, subtitleEncoder) + protected BaseHlsService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IFileSystem fileSystem, ILiveTvManager liveTvManager, IDlnaManager dlnaManager, IChannelManager channelManager, ISubtitleEncoder subtitleEncoder, IDeviceManager deviceManager) : base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, fileSystem, liveTvManager, dlnaManager, channelManager, subtitleEncoder, deviceManager) { } diff --git a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs index 6044c8c5aa..e639dbdfe3 100644 --- a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs +++ b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Model.Extensions; +using MediaBrowser.Controller.Devices; +using MediaBrowser.Model.Extensions; using MediaBrowser.Common.IO; using MediaBrowser.Common.Net; using MediaBrowser.Controller.Channels; @@ -62,38 +63,31 @@ namespace MediaBrowser.Api.Playback.Hls public class DynamicHlsService : BaseHlsService { - protected INetworkManager NetworkManager { get; private set; } - - public DynamicHlsService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IFileSystem fileSystem, ILiveTvManager liveTvManager, IDlnaManager dlnaManager, IChannelManager channelManager, ISubtitleEncoder subtitleEncoder, INetworkManager networkManager) - : base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, fileSystem, liveTvManager, dlnaManager, channelManager, subtitleEncoder) + public DynamicHlsService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IFileSystem fileSystem, ILiveTvManager liveTvManager, IDlnaManager dlnaManager, IChannelManager channelManager, ISubtitleEncoder subtitleEncoder, IDeviceManager deviceManager, INetworkManager networkManager) : base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, fileSystem, liveTvManager, dlnaManager, channelManager, subtitleEncoder, deviceManager) { NetworkManager = networkManager; } - public object Get(GetMasterHlsVideoStream request) - { - var result = GetAsync(request, "GET").Result; + protected INetworkManager NetworkManager { get; private set; } - return result; + public Task Get(GetMasterHlsVideoStream request) + { + return GetAsync(request, "GET"); } - public object Head(GetMasterHlsVideoStream request) + public Task Head(GetMasterHlsVideoStream request) { - var result = GetAsync(request, "HEAD").Result; - - return result; + return GetAsync(request, "HEAD"); } - public object Get(GetMainHlsVideoStream request) + public Task Get(GetMainHlsVideoStream request) { - var result = GetPlaylistAsync(request, "main").Result; - - return result; + return GetPlaylistAsync(request, "main"); } - public object Get(GetDynamicHlsVideoSegment request) + public Task Get(GetDynamicHlsVideoSegment request) { - return GetDynamicSegment(request, request.SegmentId).Result; + return GetDynamicSegment(request, request.SegmentId); } private async Task GetDynamicSegment(VideoStreamRequest request, string segmentId) diff --git a/MediaBrowser.Api/Playback/Hls/MpegDashService.cs b/MediaBrowser.Api/Playback/Hls/MpegDashService.cs index a0b67a2209..80451c0cc8 100644 --- a/MediaBrowser.Api/Playback/Hls/MpegDashService.cs +++ b/MediaBrowser.Api/Playback/Hls/MpegDashService.cs @@ -2,6 +2,7 @@ using MediaBrowser.Common.Net; using MediaBrowser.Controller.Channels; using MediaBrowser.Controller.Configuration; +using MediaBrowser.Controller.Devices; using MediaBrowser.Controller.Dlna; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.LiveTv; @@ -50,14 +51,13 @@ namespace MediaBrowser.Api.Playback.Hls public class MpegDashService : BaseHlsService { - protected INetworkManager NetworkManager { get; private set; } - - public MpegDashService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IFileSystem fileSystem, ILiveTvManager liveTvManager, IDlnaManager dlnaManager, IChannelManager channelManager, ISubtitleEncoder subtitleEncoder, INetworkManager networkManager) - : base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, fileSystem, liveTvManager, dlnaManager, channelManager, subtitleEncoder) + public MpegDashService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IFileSystem fileSystem, ILiveTvManager liveTvManager, IDlnaManager dlnaManager, IChannelManager channelManager, ISubtitleEncoder subtitleEncoder, IDeviceManager deviceManager, INetworkManager networkManager) : base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, fileSystem, liveTvManager, dlnaManager, channelManager, subtitleEncoder, deviceManager) { NetworkManager = networkManager; } + protected INetworkManager NetworkManager { get; private set; } + public object Get(GetMasterManifest request) { var result = GetAsync(request, "GET").Result; diff --git a/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs b/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs index de845c88d8..8de52ea028 100644 --- a/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs +++ b/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs @@ -1,6 +1,7 @@ using MediaBrowser.Common.IO; using MediaBrowser.Controller.Channels; using MediaBrowser.Controller.Configuration; +using MediaBrowser.Controller.Devices; using MediaBrowser.Controller.Dlna; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.LiveTv; @@ -56,8 +57,7 @@ namespace MediaBrowser.Api.Playback.Hls /// public class VideoHlsService : BaseHlsService { - public VideoHlsService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IFileSystem fileSystem, ILiveTvManager liveTvManager, IDlnaManager dlnaManager, IChannelManager channelManager, ISubtitleEncoder subtitleEncoder) - : base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, fileSystem, liveTvManager, dlnaManager, channelManager, subtitleEncoder) + public VideoHlsService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IFileSystem fileSystem, ILiveTvManager liveTvManager, IDlnaManager dlnaManager, IChannelManager channelManager, ISubtitleEncoder subtitleEncoder, IDeviceManager deviceManager) : base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, fileSystem, liveTvManager, dlnaManager, channelManager, subtitleEncoder, deviceManager) { } diff --git a/MediaBrowser.Api/Playback/Progressive/AudioService.cs b/MediaBrowser.Api/Playback/Progressive/AudioService.cs index 725526ecdc..37155b8f94 100644 --- a/MediaBrowser.Api/Playback/Progressive/AudioService.cs +++ b/MediaBrowser.Api/Playback/Progressive/AudioService.cs @@ -2,6 +2,7 @@ using MediaBrowser.Common.Net; using MediaBrowser.Controller.Channels; using MediaBrowser.Controller.Configuration; +using MediaBrowser.Controller.Devices; using MediaBrowser.Controller.Dlna; using MediaBrowser.Controller.Drawing; using MediaBrowser.Controller.Library; @@ -31,7 +32,7 @@ namespace MediaBrowser.Api.Playback.Progressive /// public class AudioService : BaseProgressiveStreamingService { - public AudioService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IFileSystem fileSystem, ILiveTvManager liveTvManager, IDlnaManager dlnaManager, IChannelManager channelManager, ISubtitleEncoder subtitleEncoder, IImageProcessor imageProcessor, IHttpClient httpClient) : base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, fileSystem, liveTvManager, dlnaManager, channelManager, subtitleEncoder, imageProcessor, httpClient) + public AudioService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IFileSystem fileSystem, ILiveTvManager liveTvManager, IDlnaManager dlnaManager, IChannelManager channelManager, ISubtitleEncoder subtitleEncoder, IDeviceManager deviceManager, IImageProcessor imageProcessor, IHttpClient httpClient) : base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, fileSystem, liveTvManager, dlnaManager, channelManager, subtitleEncoder, deviceManager, imageProcessor, httpClient) { } diff --git a/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs b/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs index 6bec387d42..9dbe3389e6 100644 --- a/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs +++ b/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs @@ -1,8 +1,8 @@ -using System.Linq; -using MediaBrowser.Common.IO; +using MediaBrowser.Common.IO; using MediaBrowser.Common.Net; using MediaBrowser.Controller.Channels; using MediaBrowser.Controller.Configuration; +using MediaBrowser.Controller.Devices; using MediaBrowser.Controller.Dlna; using MediaBrowser.Controller.Drawing; using MediaBrowser.Controller.Library; @@ -15,6 +15,7 @@ using ServiceStack.Web; using System; using System.Collections.Generic; using System.IO; +using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -28,8 +29,7 @@ namespace MediaBrowser.Api.Playback.Progressive protected readonly IImageProcessor ImageProcessor; protected readonly IHttpClient HttpClient; - protected BaseProgressiveStreamingService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IFileSystem fileSystem, ILiveTvManager liveTvManager, IDlnaManager dlnaManager, IChannelManager channelManager, ISubtitleEncoder subtitleEncoder, IImageProcessor imageProcessor, IHttpClient httpClient) - : base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, fileSystem, liveTvManager, dlnaManager, channelManager, subtitleEncoder) + protected BaseProgressiveStreamingService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IFileSystem fileSystem, ILiveTvManager liveTvManager, IDlnaManager dlnaManager, IChannelManager channelManager, ISubtitleEncoder subtitleEncoder, IDeviceManager deviceManager, IImageProcessor imageProcessor, IHttpClient httpClient) : base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, fileSystem, liveTvManager, dlnaManager, channelManager, subtitleEncoder, deviceManager) { ImageProcessor = imageProcessor; HttpClient = httpClient; diff --git a/MediaBrowser.Api/Playback/Progressive/VideoService.cs b/MediaBrowser.Api/Playback/Progressive/VideoService.cs index 5ef72a4952..8924bb38f6 100644 --- a/MediaBrowser.Api/Playback/Progressive/VideoService.cs +++ b/MediaBrowser.Api/Playback/Progressive/VideoService.cs @@ -2,6 +2,7 @@ using MediaBrowser.Common.IO; using MediaBrowser.Common.Net; using MediaBrowser.Controller.Channels; using MediaBrowser.Controller.Configuration; +using MediaBrowser.Controller.Devices; using MediaBrowser.Controller.Dlna; using MediaBrowser.Controller.Drawing; using MediaBrowser.Controller.Library; @@ -62,7 +63,7 @@ namespace MediaBrowser.Api.Playback.Progressive /// public class VideoService : BaseProgressiveStreamingService { - public VideoService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IFileSystem fileSystem, ILiveTvManager liveTvManager, IDlnaManager dlnaManager, IChannelManager channelManager, ISubtitleEncoder subtitleEncoder, IImageProcessor imageProcessor, IHttpClient httpClient) : base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, fileSystem, liveTvManager, dlnaManager, channelManager, subtitleEncoder, imageProcessor, httpClient) + public VideoService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IFileSystem fileSystem, ILiveTvManager liveTvManager, IDlnaManager dlnaManager, IChannelManager channelManager, ISubtitleEncoder subtitleEncoder, IDeviceManager deviceManager, IImageProcessor imageProcessor, IHttpClient httpClient) : base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, fileSystem, liveTvManager, dlnaManager, channelManager, subtitleEncoder, deviceManager, imageProcessor, httpClient) { } diff --git a/MediaBrowser.Api/Session/SessionsService.cs b/MediaBrowser.Api/Session/SessionsService.cs index e5fe69b622..319b3d28c6 100644 --- a/MediaBrowser.Api/Session/SessionsService.cs +++ b/MediaBrowser.Api/Session/SessionsService.cs @@ -243,12 +243,12 @@ namespace MediaBrowser.Api.Session [ApiMember(Name = "SupportsSync", Description = "Determines whether sync is supported.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "POST")] public bool SupportsSync { get; set; } - [ApiMember(Name = "SupportsUniqueIdentifier", Description = "Determines whether the device supports a unique identifier.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "POST")] - public bool SupportsUniqueIdentifier { get; set; } + [ApiMember(Name = "SupportsPersistentIdentifier", Description = "Determines whether the device supports a unique identifier.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "POST")] + public bool SupportsPersistentIdentifier { get; set; } public PostCapabilities() { - SupportsUniqueIdentifier = true; + SupportsPersistentIdentifier = true; } } @@ -561,7 +561,7 @@ namespace MediaBrowser.Api.Session SupportsSync = request.SupportsSync, - SupportsUniqueIdentifier = request.SupportsUniqueIdentifier + SupportsPersistentIdentifier = request.SupportsPersistentIdentifier }); } diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index 2761aa5d7e..8faab4c36f 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -303,10 +303,7 @@ namespace MediaBrowser.Controller.Entities { if (this is ICollectionFolder) { - if (user.Policy.BlockedMediaFolders.Contains(Id.ToString("N"), StringComparer.OrdinalIgnoreCase) || - - // Backwards compatibility - user.Policy.BlockedMediaFolders.Contains(Name, StringComparer.OrdinalIgnoreCase)) + if (!user.Policy.EnableAllFolders && !user.Policy.EnabledFolders.Contains(Id.ToString("N"), StringComparer.OrdinalIgnoreCase)) { return false; } diff --git a/MediaBrowser.Model/Connect/ConnectAuthorization.cs b/MediaBrowser.Model/Connect/ConnectAuthorization.cs index 9e4537d65a..e8baf72692 100644 --- a/MediaBrowser.Model/Connect/ConnectAuthorization.cs +++ b/MediaBrowser.Model/Connect/ConnectAuthorization.cs @@ -7,13 +7,13 @@ namespace MediaBrowser.Model.Connect public string UserName { get; set; } public string ImageUrl { get; set; } public string Id { get; set; } - public string[] ExcludedLibraries { get; set; } + public string[] EnabledLibraries { get; set; } public bool EnableLiveTv { get; set; } public string[] EnabledChannels { get; set; } public ConnectAuthorization() { - ExcludedLibraries = new string[] { }; + EnabledLibraries = new string[] { }; EnabledChannels = new string[] { }; } } diff --git a/MediaBrowser.Model/Connect/ConnectAuthorizationRequest.cs b/MediaBrowser.Model/Connect/ConnectAuthorizationRequest.cs index 77c574f8bd..6baea15a9d 100644 --- a/MediaBrowser.Model/Connect/ConnectAuthorizationRequest.cs +++ b/MediaBrowser.Model/Connect/ConnectAuthorizationRequest.cs @@ -5,13 +5,13 @@ namespace MediaBrowser.Model.Connect { public string SendingUserId { get; set; } public string ConnectUserName { get; set; } - public string[] ExcludedLibraries { get; set; } + public string[] EnabledLibraries { get; set; } public bool EnableLiveTv { get; set; } public string[] EnabledChannels { get; set; } public ConnectAuthorizationRequest() { - ExcludedLibraries = new string[] { }; + EnabledLibraries = new string[] { }; EnabledChannels = new string[] { }; } } diff --git a/MediaBrowser.Model/Devices/DeviceQuery.cs b/MediaBrowser.Model/Devices/DeviceQuery.cs index 2cd2389d89..9ae4986062 100644 --- a/MediaBrowser.Model/Devices/DeviceQuery.cs +++ b/MediaBrowser.Model/Devices/DeviceQuery.cs @@ -12,7 +12,7 @@ namespace MediaBrowser.Model.Devices /// Gets or sets a value indicating whether [supports unique identifier]. /// /// null if [supports unique identifier] contains no value, true if [supports unique identifier]; otherwise, false. - public bool? SupportsUniqueIdentifier { get; set; } + public bool? SupportsPersistentIdentifier { get; set; } /// /// Gets or sets a value indicating whether [supports synchronize]. /// diff --git a/MediaBrowser.Model/Session/ClientCapabilities.cs b/MediaBrowser.Model/Session/ClientCapabilities.cs index 5a806a8675..6c1b6e8b2d 100644 --- a/MediaBrowser.Model/Session/ClientCapabilities.cs +++ b/MediaBrowser.Model/Session/ClientCapabilities.cs @@ -14,16 +14,21 @@ namespace MediaBrowser.Model.Session public string MessageCallbackUrl { get; set; } public bool SupportsContentUploading { get; set; } - public bool SupportsUniqueIdentifier { get; set; } + public bool SupportsPersistentIdentifier { get; set; } public bool SupportsSync { get; set; } public DeviceProfile DeviceProfile { get; set; } + /// + /// Usage should be migrated to SupportsPersistentIdentifier. Keeping this to preserve data. + /// + public bool? SupportsUniqueIdentifier { get; set; } + public ClientCapabilities() { PlayableMediaTypes = new List(); SupportedCommands = new List(); - SupportsUniqueIdentifier = true; + SupportsPersistentIdentifier = true; } } } \ No newline at end of file diff --git a/MediaBrowser.Model/Users/UserPolicy.cs b/MediaBrowser.Model/Users/UserPolicy.cs index eb8dbc6f0b..cdc5077b02 100644 --- a/MediaBrowser.Model/Users/UserPolicy.cs +++ b/MediaBrowser.Model/Users/UserPolicy.cs @@ -54,6 +54,9 @@ namespace MediaBrowser.Model.Users public string[] EnabledChannels { get; set; } public bool EnableAllChannels { get; set; } + + public string[] EnabledFolders { get; set; } + public bool EnableAllFolders { get; set; } public UserPolicy() { @@ -62,9 +65,6 @@ namespace MediaBrowser.Model.Users EnableLiveTvAccess = true; EnableSharedDeviceControl = true; - EnabledChannels = new string[] { }; - - BlockedMediaFolders = new string[] { }; BlockedTags = new string[] { }; BlockUnratedItems = new UnratedItem[] { }; @@ -72,6 +72,12 @@ namespace MediaBrowser.Model.Users AccessSchedules = new AccessSchedule[] { }; + EnableAllChannels = true; + EnabledChannels = new string[] { }; + + EnableAllFolders = true; + EnabledFolders = new string[] { }; + EnabledDevices = new string[] { }; EnableAllDevices = true; } diff --git a/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs b/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs index 1cc3365e59..bb89f01fa5 100644 --- a/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs +++ b/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs @@ -572,7 +572,7 @@ namespace MediaBrowser.Server.Implementations.Connect Id = response.Id, ImageUrl = response.UserImageUrl, UserName = response.UserName, - ExcludedLibraries = request.ExcludedLibraries, + EnabledLibraries = request.EnabledLibraries, EnabledChannels = request.EnabledChannels, EnableLiveTv = request.EnableLiveTv, AccessToken = accessToken @@ -833,10 +833,13 @@ namespace MediaBrowser.Server.Implementations.Connect if (currentPendingEntry != null) { - user.Policy.EnableLiveTvAccess = currentPendingEntry.EnableLiveTv; - user.Policy.BlockedMediaFolders = currentPendingEntry.ExcludedLibraries; + user.Policy.EnabledFolders = currentPendingEntry.EnabledLibraries; + user.Policy.EnableAllFolders = false; + user.Policy.EnabledChannels = currentPendingEntry.EnabledChannels; user.Policy.EnableAllChannels = false; + + user.Policy.EnableLiveTvAccess = currentPendingEntry.EnableLiveTv; } await _userManager.UpdateConfiguration(user.Id.ToString("N"), user.Configuration); @@ -964,7 +967,7 @@ namespace MediaBrowser.Server.Implementations.Connect ConnectUserId = i.ConnectUserId, EnableLiveTv = i.EnableLiveTv, EnabledChannels = i.EnabledChannels, - ExcludedLibraries = i.ExcludedLibraries, + EnabledLibraries = i.EnabledLibraries, Id = i.Id, ImageUrl = i.ImageUrl, UserName = i.UserName diff --git a/MediaBrowser.Server.Implementations/Devices/DeviceManager.cs b/MediaBrowser.Server.Implementations/Devices/DeviceManager.cs index ddd5ef58d8..e057ec5cdd 100644 --- a/MediaBrowser.Server.Implementations/Devices/DeviceManager.cs +++ b/MediaBrowser.Server.Implementations/Devices/DeviceManager.cs @@ -100,11 +100,16 @@ namespace MediaBrowser.Server.Implementations.Devices devices = devices.Where(i => GetCapabilities(i.Id).SupportsSync == val); } - if (query.SupportsUniqueIdentifier.HasValue) + if (query.SupportsPersistentIdentifier.HasValue) { - var val = query.SupportsUniqueIdentifier.Value; + var val = query.SupportsPersistentIdentifier.Value; - devices = devices.Where(i => GetCapabilities(i.Id).SupportsUniqueIdentifier == val); + devices = devices.Where(i => + { + var caps = GetCapabilities(i.Id); + var deviceVal = caps.SupportsUniqueIdentifier ?? caps.SupportsPersistentIdentifier; + return deviceVal == val; + }); } if (!string.IsNullOrWhiteSpace(query.UserId)) @@ -212,7 +217,7 @@ namespace MediaBrowser.Server.Implementations.Devices { var capabilities = GetCapabilities(deviceId); - if (capabilities.SupportsUniqueIdentifier) + if (capabilities != null && capabilities.SupportsPersistentIdentifier) { return false; } diff --git a/MediaBrowser.Server.Implementations/Library/UserManager.cs b/MediaBrowser.Server.Implementations/Library/UserManager.cs index edcf7255d7..3d64326363 100644 --- a/MediaBrowser.Server.Implementations/Library/UserManager.cs +++ b/MediaBrowser.Server.Implementations/Library/UserManager.cs @@ -73,10 +73,11 @@ namespace MediaBrowser.Server.Implementations.Library private readonly Func _dtoServiceFactory; private readonly Func _connectFactory; private readonly Func _channelManager; + private readonly Func _libraryManager; private readonly IServerApplicationHost _appHost; private readonly IFileSystem _fileSystem; - public UserManager(ILogger logger, IServerConfigurationManager configurationManager, IUserRepository userRepository, IXmlSerializer xmlSerializer, INetworkManager networkManager, Func imageProcessorFactory, Func dtoServiceFactory, Func connectFactory, IServerApplicationHost appHost, IJsonSerializer jsonSerializer, IFileSystem fileSystem, Func channelManager) + public UserManager(ILogger logger, IServerConfigurationManager configurationManager, IUserRepository userRepository, IXmlSerializer xmlSerializer, INetworkManager networkManager, Func imageProcessorFactory, Func dtoServiceFactory, Func connectFactory, IServerApplicationHost appHost, IJsonSerializer jsonSerializer, IFileSystem fileSystem, Func channelManager, Func libraryManager) { _logger = logger; UserRepository = userRepository; @@ -89,6 +90,7 @@ namespace MediaBrowser.Server.Implementations.Library _jsonSerializer = jsonSerializer; _fileSystem = fileSystem; _channelManager = channelManager; + _libraryManager = libraryManager; ConfigurationManager = configurationManager; Users = new List(); @@ -173,6 +175,7 @@ namespace MediaBrowser.Server.Implementations.Library { await DoPolicyMigration(user).ConfigureAwait(false); await DoChannelMigration(user).ConfigureAwait(false); + await DoLibraryMigration(user).ConfigureAwait(false); } // If there are no local users with admin rights, make them all admins @@ -389,6 +392,39 @@ namespace MediaBrowser.Server.Implementations.Library } } + private async Task DoLibraryMigration(User user) + { + if (user.Policy.BlockedMediaFolders != null) + { + if (user.Policy.BlockedMediaFolders.Length > 0) + { + user.Policy.EnableAllFolders = false; + + try + { + user.Policy.EnabledFolders = _libraryManager().RootFolder + .Children + .Where(i => !user.Policy.BlockedMediaFolders.Contains(i.Name, StringComparer.OrdinalIgnoreCase) && !user.Policy.BlockedMediaFolders.Contains(i.Id.ToString("N"), StringComparer.OrdinalIgnoreCase)) + .Select(i => i.Id.ToString("N")) + .ToArray(); + } + catch + { + user.Policy.EnabledFolders = new string[] { }; + } + } + else + { + user.Policy.EnableAllFolders = true; + user.Policy.EnabledFolders = new string[] { }; + } + + user.Policy.BlockedMediaFolders = null; + + await UpdateUserPolicy(user, user.Policy, false); + } + } + public UserDto GetUserDto(User user, string remoteEndPoint = null) { if (user == null) diff --git a/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json b/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json index 8e41dda307..afc9bff62f 100644 --- a/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json +++ b/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json @@ -6,6 +6,8 @@ "Administrator": "Administrator", "Password": "Password", "DeleteImage": "Delete Image", + "MessageThankYouForSupporting": "Thank you for supporting Media Browser.", + "MessagePleaseSupportMediaBrowser": "Please support Media Browser.", "DeleteImageConfirmation": "Are you sure you wish to delete this image?", "FileReadCancelled": "The file read has been canceled.", "FileNotFound": "File not found.", @@ -219,6 +221,7 @@ "ButtonResume": "Resume", "HeaderScenes": "Scenes", "HeaderAudioTracks": "Audio Tracks", + "HeaderLibraries": "Libraries", "LabelUnknownLanguage": "Unknown language", "HeaderSubtitles": "Subtitles", "HeaderVideoQuality": "Video Quality", diff --git a/MediaBrowser.Server.Implementations/Localization/Server/server.json b/MediaBrowser.Server.Implementations/Localization/Server/server.json index 4bd6052a00..ccba2e6979 100644 --- a/MediaBrowser.Server.Implementations/Localization/Server/server.json +++ b/MediaBrowser.Server.Implementations/Localization/Server/server.json @@ -79,6 +79,7 @@ "ReferToMediaLibraryWiki": "Refer to the media library wiki.", "LabelCountry": "Country:", "LabelLanguage": "Language:", + "ButtonJoinTheDevelopmentTeam": "Join the Development Team", "HeaderPreferredMetadataLanguage": "Preferred metadata language:", "LabelSaveLocalMetadata": "Save artwork and metadata into media folders", "LabelSaveLocalMetadataHelp": "Saving artwork and metadata directly into media folders will put them in a place where they can be easily edited.", @@ -97,6 +98,7 @@ "HeaderDeviceAccess": "Device Access", "OptionEnableAccessFromAllDevices": "Enable access from all devices", "OptionEnableAccessToAllChannels": "Enable access to all channels", + "OptionEnableAccessToAllLibraries": "Enable access to all libraries", "DeviceAccessHelp": "This only applies to devices that can be uniquely identified and will not prevent browser access. Filtering user device access will prevent them from using new devices until they've been approved here.", "LabelDisplayMissingEpisodesWithinSeasons": "Display missing episodes within seasons", "LabelUnairedMissingEpisodesWithinSeasons": "Display unaired episodes within seasons", diff --git a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs index 2695ddaf69..49cc672abd 100644 --- a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs +++ b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs @@ -407,7 +407,7 @@ namespace MediaBrowser.Server.Startup.Common SyncRepository = await GetSyncRepository().ConfigureAwait(false); RegisterSingleInstance(SyncRepository); - UserManager = new UserManager(LogManager.GetLogger("UserManager"), ServerConfigurationManager, UserRepository, XmlSerializer, NetworkManager, () => ImageProcessor, () => DtoService, () => ConnectManager, this, JsonSerializer, FileSystemManager, () => ChannelManager); + UserManager = new UserManager(LogManager.GetLogger("UserManager"), ServerConfigurationManager, UserRepository, XmlSerializer, NetworkManager, () => ImageProcessor, () => DtoService, () => ConnectManager, this, JsonSerializer, FileSystemManager, () => ChannelManager, () => LibraryManager); RegisterSingleInstance(UserManager); LibraryManager = new LibraryManager(Logger, TaskManager, UserManager, ServerConfigurationManager, UserDataManager, () => LibraryMonitor, FileSystemManager, () => ProviderManager); -- cgit v1.2.3 From f636c10e24a6f26f1c8e41ba6d3751334d6dcb90 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 20 Jan 2015 22:54:45 -0500 Subject: sync updates --- .../Library/LibraryStructureService.cs | 32 +------- .../ScheduledTasks/ScheduledTaskService.cs | 2 +- MediaBrowser.Api/StartupWizardService.cs | 1 + MediaBrowser.Api/Sync/SyncService.cs | 28 +++++++ MediaBrowser.Controller/Channels/Channel.cs | 14 +++- MediaBrowser.Controller/Entities/Folder.cs | 21 +++++- MediaBrowser.Controller/Library/ILibraryManager.cs | 9 +-- MediaBrowser.Controller/Sync/ISyncManager.cs | 19 +++++ .../Configuration/ServerConfiguration.cs | 1 + MediaBrowser.Model/Sync/SyncJobItem.cs | 2 + .../Configuration/ServerConfigurationManager.cs | 12 ++- .../Library/LibraryManager.cs | 12 +-- .../Library/UserManager.cs | 88 +--------------------- .../Localization/JavaScript/javascript.json | 5 ++ .../Sync/SyncJobProcessor.cs | 20 +++-- .../Sync/SyncManager.cs | 83 +++++++++++++++++++- .../Sync/SyncRepository.cs | 12 ++- .../ApplicationHost.cs | 2 +- 18 files changed, 206 insertions(+), 157 deletions(-) (limited to 'MediaBrowser.Controller') diff --git a/MediaBrowser.Api/Library/LibraryStructureService.cs b/MediaBrowser.Api/Library/LibraryStructureService.cs index 23f4e4e5c1..27944a4ea7 100644 --- a/MediaBrowser.Api/Library/LibraryStructureService.cs +++ b/MediaBrowser.Api/Library/LibraryStructureService.cs @@ -3,7 +3,6 @@ using MediaBrowser.Controller; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Net; using MediaBrowser.Model.Entities; -using MediaBrowser.Model.Logging; using ServiceStack; using System; using System.Collections.Generic; @@ -18,7 +17,6 @@ namespace MediaBrowser.Api.Library /// Class GetDefaultVirtualFolders /// [Route("/Library/VirtualFolders", "GET")] - [Route("/Users/{UserId}/VirtualFolders", "GET")] public class GetVirtualFolders : IReturn> { /// @@ -143,11 +141,6 @@ namespace MediaBrowser.Api.Library /// private readonly IServerApplicationPaths _appPaths; - /// - /// The _user manager - /// - private readonly IUserManager _userManager; - /// /// The _library manager /// @@ -156,27 +149,21 @@ namespace MediaBrowser.Api.Library private readonly ILibraryMonitor _libraryMonitor; private readonly IFileSystem _fileSystem; - private readonly ILogger _logger; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// - /// The app paths. - /// The user manager. - /// The library manager. - public LibraryStructureService(IServerApplicationPaths appPaths, IUserManager userManager, ILibraryManager libraryManager, ILibraryMonitor libraryMonitor, IFileSystem fileSystem, ILogger logger) + public LibraryStructureService(IServerApplicationPaths appPaths, ILibraryManager libraryManager, ILibraryMonitor libraryMonitor, IFileSystem fileSystem) { if (appPaths == null) { throw new ArgumentNullException("appPaths"); } - _userManager = userManager; _appPaths = appPaths; _libraryManager = libraryManager; _libraryMonitor = libraryMonitor; _fileSystem = fileSystem; - _logger = logger; } /// @@ -186,20 +173,9 @@ namespace MediaBrowser.Api.Library /// System.Object. public object Get(GetVirtualFolders request) { - if (string.IsNullOrEmpty(request.UserId)) - { - var result = _libraryManager.GetDefaultVirtualFolders().OrderBy(i => i.Name).ToList(); + var result = _libraryManager.GetVirtualFolders().OrderBy(i => i.Name).ToList(); - return ToOptimizedSerializedResultUsingCache(result); - } - else - { - var user = _userManager.GetUserById(request.UserId); - - var result = _libraryManager.GetVirtualFolders(user).OrderBy(i => i.Name).ToList(); - - return ToOptimizedSerializedResultUsingCache(result); - } + return ToOptimizedSerializedResultUsingCache(result); } /// diff --git a/MediaBrowser.Api/ScheduledTasks/ScheduledTaskService.cs b/MediaBrowser.Api/ScheduledTasks/ScheduledTaskService.cs index f5b3d173bd..947b99d35f 100644 --- a/MediaBrowser.Api/ScheduledTasks/ScheduledTaskService.cs +++ b/MediaBrowser.Api/ScheduledTasks/ScheduledTaskService.cs @@ -141,7 +141,7 @@ namespace MediaBrowser.Api.ScheduledTasks result = result.Where(i => { - var isEnabled = false; + var isEnabled = true; var configurableTask = i.ScheduledTask as IConfigurableScheduledTask; diff --git a/MediaBrowser.Api/StartupWizardService.cs b/MediaBrowser.Api/StartupWizardService.cs index 97401bbf84..cb0c54674a 100644 --- a/MediaBrowser.Api/StartupWizardService.cs +++ b/MediaBrowser.Api/StartupWizardService.cs @@ -63,6 +63,7 @@ namespace MediaBrowser.Api _config.Configuration.IsStartupWizardCompleted = true; _config.Configuration.EnableLocalizedGuids = true; _config.Configuration.StoreArtistsInMetadata = true; + _config.Configuration.EnableStandaloneMetadata = true; _config.Configuration.EnableLibraryMetadataSubFolder = true; _config.SaveConfiguration(); } diff --git a/MediaBrowser.Api/Sync/SyncService.cs b/MediaBrowser.Api/Sync/SyncService.cs index 8d5ec824f8..c763aa8df1 100644 --- a/MediaBrowser.Api/Sync/SyncService.cs +++ b/MediaBrowser.Api/Sync/SyncService.cs @@ -37,6 +37,20 @@ namespace MediaBrowser.Api.Sync { } + [Route("/Sync/JobItems/{Id}/Enable", "POST", Summary = "Enables a cancelled or queued sync job item")] + public class EnableSyncJobItem : IReturnVoid + { + [ApiMember(Name = "Id", Description = "Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "POST")] + public string Id { get; set; } + } + + [Route("/Sync/JobItems/{Id}", "DELETE", Summary = "Cancels a sync job item")] + public class CancelSyncJobItem : IReturnVoid + { + [ApiMember(Name = "Id", Description = "Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "DELETE")] + public string Id { get; set; } + } + [Route("/Sync/Jobs", "GET", Summary = "Gets sync jobs.")] public class GetSyncJobs : SyncJobQuery, IReturn> { @@ -271,5 +285,19 @@ namespace MediaBrowser.Api.Sync return ToStaticFileResult(file.Path); } + + public void Post(EnableSyncJobItem request) + { + var task = _syncManager.ReEnableJobItem(request.Id); + + Task.WaitAll(task); + } + + public void Delete(CancelSyncJobItem request) + { + var task = _syncManager.CancelJobItem(request.Id); + + Task.WaitAll(task); + } } } diff --git a/MediaBrowser.Controller/Channels/Channel.cs b/MediaBrowser.Controller/Channels/Channel.cs index 6ee6fe0062..32ad2ff122 100644 --- a/MediaBrowser.Controller/Channels/Channel.cs +++ b/MediaBrowser.Controller/Channels/Channel.cs @@ -14,9 +14,19 @@ namespace MediaBrowser.Controller.Channels public override bool IsVisible(User user) { - if (!user.Policy.EnableAllChannels && !user.Policy.EnabledChannels.Contains(Id.ToString("N"), StringComparer.OrdinalIgnoreCase)) + if (user.Policy.BlockedChannels != null) { - return false; + if (user.Policy.BlockedChannels.Contains(Id.ToString("N"), StringComparer.OrdinalIgnoreCase)) + { + return false; + } + } + else + { + if (!user.Policy.EnableAllChannels && !user.Policy.EnabledChannels.Contains(Id.ToString("N"), StringComparer.OrdinalIgnoreCase)) + { + return false; + } } return base.IsVisible(user); diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index 8faab4c36f..005f263f7c 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -303,9 +303,22 @@ namespace MediaBrowser.Controller.Entities { if (this is ICollectionFolder) { - if (!user.Policy.EnableAllFolders && !user.Policy.EnabledFolders.Contains(Id.ToString("N"), StringComparer.OrdinalIgnoreCase)) + if (user.Policy.BlockedMediaFolders != null) { - return false; + if (user.Policy.BlockedMediaFolders.Contains(Id.ToString("N"), StringComparer.OrdinalIgnoreCase) || + + // Backwards compatibility + user.Policy.BlockedMediaFolders.Contains(Name, StringComparer.OrdinalIgnoreCase)) + { + return false; + } + } + else + { + if (!user.Policy.EnableAllFolders && !user.Policy.EnabledFolders.Contains(Id.ToString("N"), StringComparer.OrdinalIgnoreCase)) + { + return false; + } } } @@ -675,12 +688,12 @@ namespace MediaBrowser.Controller.Entities path = System.IO.Path.GetDirectoryName(path); } - if (ContainsPath(LibraryManager.GetDefaultVirtualFolders(), originalPath)) + if (ContainsPath(LibraryManager.GetVirtualFolders(), originalPath)) { return true; } - return UserManager.Users.Any(user => ContainsPath(LibraryManager.GetVirtualFolders(user), originalPath)); + return ContainsPath(LibraryManager.GetVirtualFolders(), originalPath); } /// diff --git a/MediaBrowser.Controller/Library/ILibraryManager.cs b/MediaBrowser.Controller/Library/ILibraryManager.cs index 2ebd1cab93..9871ef3c5f 100644 --- a/MediaBrowser.Controller/Library/ILibraryManager.cs +++ b/MediaBrowser.Controller/Library/ILibraryManager.cs @@ -123,14 +123,7 @@ namespace MediaBrowser.Controller.Library /// Gets the default view. /// /// IEnumerable{VirtualFolderInfo}. - IEnumerable GetDefaultVirtualFolders(); - - /// - /// Gets the view. - /// - /// The user. - /// IEnumerable{VirtualFolderInfo}. - IEnumerable GetVirtualFolders(User user); + IEnumerable GetVirtualFolders(); /// /// Gets the item by id. diff --git a/MediaBrowser.Controller/Sync/ISyncManager.cs b/MediaBrowser.Controller/Sync/ISyncManager.cs index 59136c0e6f..8e4b6a44a0 100644 --- a/MediaBrowser.Controller/Sync/ISyncManager.cs +++ b/MediaBrowser.Controller/Sync/ISyncManager.cs @@ -1,8 +1,10 @@ using MediaBrowser.Controller.Entities; using MediaBrowser.Model.Dlna; +using MediaBrowser.Model.Events; using MediaBrowser.Model.Querying; using MediaBrowser.Model.Sync; using MediaBrowser.Model.Users; +using System; using System.Collections.Generic; using System.Threading.Tasks; @@ -10,6 +12,9 @@ namespace MediaBrowser.Controller.Sync { public interface ISyncManager { + event EventHandler> SyncJobCreated; + event EventHandler> SyncJobCancelled; + /// /// Creates the job. /// @@ -44,6 +49,20 @@ namespace MediaBrowser.Controller.Sync /// Task. Task UpdateJob(SyncJob job); + /// + /// Res the enable job item. + /// + /// The identifier. + /// Task. + Task ReEnableJobItem(string id); + + /// + /// Cnacels the job item. + /// + /// The identifier. + /// Task. + Task CancelJobItem(string id); + /// /// Cancels the job. /// diff --git a/MediaBrowser.Model/Configuration/ServerConfiguration.cs b/MediaBrowser.Model/Configuration/ServerConfiguration.cs index 71580f3535..c641edff7f 100644 --- a/MediaBrowser.Model/Configuration/ServerConfiguration.cs +++ b/MediaBrowser.Model/Configuration/ServerConfiguration.cs @@ -169,6 +169,7 @@ namespace MediaBrowser.Model.Configuration public string DashboardSourcePath { get; set; } public bool StoreArtistsInMetadata { get; set; } + public bool EnableStandaloneMetadata { get; set; } /// /// Gets or sets the image saving convention. diff --git a/MediaBrowser.Model/Sync/SyncJobItem.cs b/MediaBrowser.Model/Sync/SyncJobItem.cs index 943014c0d2..133065bf92 100644 --- a/MediaBrowser.Model/Sync/SyncJobItem.cs +++ b/MediaBrowser.Model/Sync/SyncJobItem.cs @@ -88,6 +88,8 @@ namespace MediaBrowser.Model.Sync public string TemporaryPath { get; set; } public List AdditionalFiles { get; set; } + public bool IsMarkedForRemoval { get; set; } + public SyncJobItem() { AdditionalFiles = new List(); diff --git a/MediaBrowser.Server.Implementations/Configuration/ServerConfigurationManager.cs b/MediaBrowser.Server.Implementations/Configuration/ServerConfigurationManager.cs index b3b8ccbd8e..5f7ccec4b9 100644 --- a/MediaBrowser.Server.Implementations/Configuration/ServerConfigurationManager.cs +++ b/MediaBrowser.Server.Implementations/Configuration/ServerConfigurationManager.cs @@ -99,10 +99,20 @@ namespace MediaBrowser.Server.Implementations.Configuration private void UpdateMetadataPath() { ((ServerApplicationPaths)ApplicationPaths).InternalMetadataPath = string.IsNullOrEmpty(Configuration.MetadataPath) ? - null : + GetInternalMetadataPath() : Configuration.MetadataPath; } + private string GetInternalMetadataPath() + { + if (Configuration.EnableStandaloneMetadata) + { + return Path.Combine(ApplicationPaths.ProgramDataPath, "metadata"); + } + + return null; + } + /// /// Updates the transcoding temporary path. /// diff --git a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs index eaab469f53..b28c987286 100644 --- a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs +++ b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs @@ -1124,21 +1124,11 @@ namespace MediaBrowser.Server.Implementations.Library /// Gets the default view. /// /// IEnumerable{VirtualFolderInfo}. - public IEnumerable GetDefaultVirtualFolders() + public IEnumerable GetVirtualFolders() { return GetView(ConfigurationManager.ApplicationPaths.DefaultUserViewsPath); } - /// - /// Gets the view. - /// - /// The user. - /// IEnumerable{VirtualFolderInfo}. - public IEnumerable GetVirtualFolders(User user) - { - return GetDefaultVirtualFolders(); - } - /// /// Gets the view. /// diff --git a/MediaBrowser.Server.Implementations/Library/UserManager.cs b/MediaBrowser.Server.Implementations/Library/UserManager.cs index 3020a224de..c4c0e53950 100644 --- a/MediaBrowser.Server.Implementations/Library/UserManager.cs +++ b/MediaBrowser.Server.Implementations/Library/UserManager.cs @@ -3,7 +3,6 @@ using MediaBrowser.Common.Extensions; using MediaBrowser.Common.IO; using MediaBrowser.Common.Net; using MediaBrowser.Controller; -using MediaBrowser.Controller.Channels; using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Connect; using MediaBrowser.Controller.Drawing; @@ -13,7 +12,6 @@ using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Net; using MediaBrowser.Controller.Persistence; using MediaBrowser.Controller.Providers; -using MediaBrowser.Model.Channels; using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Connect; using MediaBrowser.Model.Dto; @@ -72,12 +70,10 @@ namespace MediaBrowser.Server.Implementations.Library private readonly Func _imageProcessorFactory; private readonly Func _dtoServiceFactory; private readonly Func _connectFactory; - private readonly Func _channelManager; - private readonly Func _libraryManager; private readonly IServerApplicationHost _appHost; private readonly IFileSystem _fileSystem; - public UserManager(ILogger logger, IServerConfigurationManager configurationManager, IUserRepository userRepository, IXmlSerializer xmlSerializer, INetworkManager networkManager, Func imageProcessorFactory, Func dtoServiceFactory, Func connectFactory, IServerApplicationHost appHost, IJsonSerializer jsonSerializer, IFileSystem fileSystem, Func channelManager, Func libraryManager) + public UserManager(ILogger logger, IServerConfigurationManager configurationManager, IUserRepository userRepository, IXmlSerializer xmlSerializer, INetworkManager networkManager, Func imageProcessorFactory, Func dtoServiceFactory, Func connectFactory, IServerApplicationHost appHost, IJsonSerializer jsonSerializer, IFileSystem fileSystem) { _logger = logger; UserRepository = userRepository; @@ -89,8 +85,6 @@ namespace MediaBrowser.Server.Implementations.Library _appHost = appHost; _jsonSerializer = jsonSerializer; _fileSystem = fileSystem; - _channelManager = channelManager; - _libraryManager = libraryManager; ConfigurationManager = configurationManager; Users = new List(); @@ -174,8 +168,6 @@ namespace MediaBrowser.Server.Implementations.Library foreach (var user in users) { await DoPolicyMigration(user).ConfigureAwait(false); - await DoChannelMigration(user).ConfigureAwait(false); - await DoLibraryMigration(user).ConfigureAwait(false); } // If there are no local users with admin rights, make them all admins @@ -354,84 +346,6 @@ namespace MediaBrowser.Server.Implementations.Library } } - private async Task DoChannelMigration(User user) - { - if (user.Policy.BlockedChannels != null) - { - if (user.Policy.BlockedChannels.Length > 0) - { - user.Policy.EnableAllChannels = false; - - try - { - var channelResult = await _channelManager().GetChannelsInternal(new ChannelQuery - { - UserId = user.Id.ToString("N") - - }, CancellationToken.None).ConfigureAwait(false); - - user.Policy.EnabledChannels = channelResult.Items - .Select(i => i.Id.ToString("N")) - .Except(user.Policy.BlockedChannels) - .ToArray(); - } - catch - { - user.Policy.EnabledChannels = new string[] { }; - } - } - else - { - user.Policy.EnableAllChannels = true; - user.Policy.EnabledChannels = new string[] { }; - } - - user.Policy.BlockedChannels = null; - - await UpdateUserPolicy(user, user.Policy, false); - } - } - - private async Task DoLibraryMigration(User user) - { - if (user.Policy.BlockedMediaFolders != null) - { - if (user.Policy.BlockedMediaFolders.Length > 0) - { - user.Policy.EnableAllFolders = false; - - try - { - user.Policy.EnabledFolders = _libraryManager().RootFolder - .Children - .Where(i => !user.Policy.BlockedMediaFolders.Contains(i.Name, StringComparer.OrdinalIgnoreCase) && !user.Policy.BlockedMediaFolders.Contains(i.Id.ToString("N"), StringComparer.OrdinalIgnoreCase)) - .Select(i => i.Id.ToString("N")) - .ToArray(); - } - catch - { - user.Policy.EnabledFolders = new string[] { }; - user.Policy.EnableAllFolders = true; - } - } - else - { - user.Policy.EnableAllFolders = true; - user.Policy.EnabledFolders = new string[] { }; - } - - // Just to be safe - if (user.Policy.EnabledFolders.Length == 0) - { - user.Policy.EnableAllFolders = true; - } - - user.Policy.BlockedMediaFolders = null; - - await UpdateUserPolicy(user, user.Policy, false); - } - } - public UserDto GetUserDto(User user, string remoteEndPoint = null) { if (user == null) diff --git a/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json b/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json index afc9bff62f..e4d20d3a15 100644 --- a/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json +++ b/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json @@ -56,6 +56,9 @@ "HeaderChannelAccess": "Channel Access", "HeaderDeviceAccess": "Device Access", "HeaderSelectDevices": "Select Devices", + "ButtonCancelItem": "Cancel item", + "ButtonQueueForRetry": "Queue for retry", + "ButtonReenable": "Re-enable", "LabelAbortedByServerShutdown": "(Aborted by server shutdown)", "LabelScheduledTaskLastRan": "Last ran {0}, taking {1}.", "HeaderDeleteTaskTrigger": "Delete Task Trigger", @@ -71,6 +74,8 @@ "LabelForcedStream": "(Forced)", "LabelDefaultForcedStream": "(Default/Forced)", "LabelUnknownLanguage": "Unknown language", + "HeaderConfirmation": "Confirmation", + "MessageConfirmSyncJobItemCancellation": "Are you sure you wish to cancel this item?", "ButtonMute": "Mute", "ButtonUnmute": "Unmute", "ButtonStop": "Stop", diff --git a/MediaBrowser.Server.Implementations/Sync/SyncJobProcessor.cs b/MediaBrowser.Server.Implementations/Sync/SyncJobProcessor.cs index cf0138a295..67f9d363e2 100644 --- a/MediaBrowser.Server.Implementations/Sync/SyncJobProcessor.cs +++ b/MediaBrowser.Server.Implementations/Sync/SyncJobProcessor.cs @@ -1,5 +1,4 @@ -using System.Globalization; -using MediaBrowser.Common.Configuration; +using MediaBrowser.Common.Configuration; using MediaBrowser.Common.IO; using MediaBrowser.Common.Progress; using MediaBrowser.Controller.Entities; @@ -361,11 +360,20 @@ namespace MediaBrowser.Server.Implementations.Sync var innerProgress = new ActionableProgress(); innerProgress.RegisterAction(p => progress.Report(startingPercent + (percentPerItem * p))); - var job = _syncRepo.GetJob(item.JobId); - await ProcessJobItem(job, item, enableConversion, innerProgress, cancellationToken).ConfigureAwait(false); + // Pull it fresh from the db just to make sure it wasn't deleted or cancelled while another item was converting + var jobItem = enableConversion ? _syncRepo.GetJobItem(item.Id) : item; - job = _syncRepo.GetJob(item.JobId); - await UpdateJobStatus(job).ConfigureAwait(false); + if (jobItem != null) + { + var job = _syncRepo.GetJob(jobItem.JobId); + if (jobItem.Status != SyncJobItemStatus.Cancelled) + { + await ProcessJobItem(job, jobItem, enableConversion, innerProgress, cancellationToken).ConfigureAwait(false); + } + + job = _syncRepo.GetJob(jobItem.JobId); + await UpdateJobStatus(job).ConfigureAwait(false); + } numComplete++; double percent = numComplete; diff --git a/MediaBrowser.Server.Implementations/Sync/SyncManager.cs b/MediaBrowser.Server.Implementations/Sync/SyncManager.cs index b8d884cee5..7e4455ab36 100644 --- a/MediaBrowser.Server.Implementations/Sync/SyncManager.cs +++ b/MediaBrowser.Server.Implementations/Sync/SyncManager.cs @@ -1,5 +1,6 @@ using MediaBrowser.Common; using MediaBrowser.Common.Configuration; +using MediaBrowser.Common.Events; using MediaBrowser.Common.Extensions; using MediaBrowser.Common.IO; using MediaBrowser.Controller.Channels; @@ -16,6 +17,7 @@ using MediaBrowser.Controller.TV; using MediaBrowser.Model.Dlna; using MediaBrowser.Model.Dto; using MediaBrowser.Model.Entities; +using MediaBrowser.Model.Events; using MediaBrowser.Model.Logging; using MediaBrowser.Model.Querying; using MediaBrowser.Model.Sync; @@ -47,6 +49,9 @@ namespace MediaBrowser.Server.Implementations.Sync private ISyncProvider[] _providers = { }; + public event EventHandler> SyncJobCreated; + public event EventHandler> SyncJobCancelled; + public SyncManager(ILibraryManager libraryManager, ISyncRepository repo, IImageProcessor imageProcessor, ILogger logger, IUserManager userManager, Func dtoService, IApplicationHost appHost, ITVSeriesManager tvSeriesManager, Func mediaEncoder, IFileSystem fileSystem, Func subtitleEncoder, IConfigurationManager config) { _libraryManager = libraryManager; @@ -144,6 +149,15 @@ namespace MediaBrowser.Server.Implementations.Sync await processor.SyncJobItems(jobItemsResult.Items, false, new Progress(), CancellationToken.None) .ConfigureAwait(false); + if (SyncJobCreated != null) + { + EventHelper.FireEventIfNotNull(SyncJobCreated, this, new GenericEventArgs + { + Argument = job + + }, _logger); + } + return new SyncJobCreationResult { Job = GetJob(jobId) @@ -275,9 +289,25 @@ namespace MediaBrowser.Server.Implementations.Sync } } - public Task CancelJob(string id) + public async Task CancelJob(string id) { - return _repo.DeleteJob(id); + var job = GetJob(id); + + if (job == null) + { + throw new ArgumentException("Job not found."); + } + + await _repo.DeleteJob(id).ConfigureAwait(false); + + if (SyncJobCancelled != null) + { + EventHelper.FireEventIfNotNull(SyncJobCancelled, this, new GenericEventArgs + { + Argument = job + + }, _logger); + } } public SyncJob GetJob(string id) @@ -496,7 +526,7 @@ namespace MediaBrowser.Server.Implementations.Sync .FirstOrDefault(i => string.Equals(i.Id, jobItem.MediaSourceId)); syncedItem.Item.MediaSources = new List(); - + // This will be null for items that are not audio/video if (mediaSource == null) { @@ -545,7 +575,12 @@ namespace MediaBrowser.Server.Implementations.Sync var job = _repo.GetJob(jobItem.JobId); var user = _userManager.GetUserById(job.UserId); - if (user == null) + if (jobItem.IsMarkedForRemoval) + { + // Tell the device to remove it since it has been marked for removal + response.ItemIdsToRemove.Add(jobItem.ItemId); + } + else if (user == null) { // Tell the device to remove it since the user is gone now response.ItemIdsToRemove.Add(jobItem.ItemId); @@ -609,5 +644,45 @@ namespace MediaBrowser.Server.Implementations.Sync return true; } + + public async Task ReEnableJobItem(string id) + { + var jobItem = _repo.GetJobItem(id); + + if (jobItem.Status != SyncJobItemStatus.Failed && jobItem.Status != SyncJobItemStatus.Cancelled) + { + throw new ArgumentException("Operation is not valid for this job item"); + } + + jobItem.Status = SyncJobItemStatus.Queued; + jobItem.Progress = 0; + jobItem.IsMarkedForRemoval = false; + + await _repo.Update(jobItem).ConfigureAwait(false); + + var processor = GetSyncJobProcessor(); + + await processor.UpdateJobStatus(jobItem.JobId).ConfigureAwait(false); + } + + public async Task CancelJobItem(string id) + { + var jobItem = _repo.GetJobItem(id); + + if (jobItem.Status != SyncJobItemStatus.Queued && jobItem.Status != SyncJobItemStatus.Transferring && jobItem.Status != SyncJobItemStatus.Converting) + { + throw new ArgumentException("Operation is not valid for this job item"); + } + + jobItem.Status = SyncJobItemStatus.Cancelled; + jobItem.Progress = 0; + jobItem.IsMarkedForRemoval = true; + + await _repo.Update(jobItem).ConfigureAwait(false); + + var processor = GetSyncJobProcessor(); + + await processor.UpdateJobStatus(jobItem.JobId).ConfigureAwait(false); + } } } diff --git a/MediaBrowser.Server.Implementations/Sync/SyncRepository.cs b/MediaBrowser.Server.Implementations/Sync/SyncRepository.cs index ae91437104..1cd8e8a9d4 100644 --- a/MediaBrowser.Server.Implementations/Sync/SyncRepository.cs +++ b/MediaBrowser.Server.Implementations/Sync/SyncRepository.cs @@ -41,7 +41,7 @@ namespace MediaBrowser.Server.Implementations.Sync public async Task Initialize() { - var dbFile = Path.Combine(_appPaths.DataPath, "sync12.db"); + var dbFile = Path.Combine(_appPaths.DataPath, "sync13.db"); _connection = await SqliteExtensions.ConnectToDb(dbFile, _logger).ConfigureAwait(false); @@ -50,7 +50,7 @@ namespace MediaBrowser.Server.Implementations.Sync "create table if not exists SyncJobs (Id GUID PRIMARY KEY, TargetId TEXT NOT NULL, Name TEXT NOT NULL, Quality TEXT NOT NULL, Status TEXT NOT NULL, Progress FLOAT, UserId TEXT NOT NULL, ItemIds TEXT NOT NULL, Category TEXT, ParentId TEXT, UnwatchedOnly BIT, ItemLimit INT, SyncNewContent BIT, DateCreated DateTime, DateLastModified DateTime, ItemCount int)", "create index if not exists idx_SyncJobs on SyncJobs(Id)", - "create table if not exists SyncJobItems (Id GUID PRIMARY KEY, ItemId TEXT, ItemName TEXT, MediaSourceId TEXT, JobId TEXT, TemporaryPath TEXT, OutputPath TEXT, Status TEXT, TargetId TEXT, DateCreated DateTime, Progress FLOAT, AdditionalFiles TEXT, MediaSource TEXT)", + "create table if not exists SyncJobItems (Id GUID PRIMARY KEY, ItemId TEXT, ItemName TEXT, MediaSourceId TEXT, JobId TEXT, TemporaryPath TEXT, OutputPath TEXT, Status TEXT, TargetId TEXT, DateCreated DateTime, Progress FLOAT, AdditionalFiles TEXT, MediaSource TEXT, IsMarkedForRemoval BIT)", "create index if not exists idx_SyncJobItems on SyncJobs(Id)", //pragmas @@ -95,7 +95,7 @@ namespace MediaBrowser.Server.Implementations.Sync _saveJobCommand.Parameters.Add(_saveJobCommand, "@ItemCount"); _saveJobItemCommand = _connection.CreateCommand(); - _saveJobItemCommand.CommandText = "replace into SyncJobItems (Id, ItemId, ItemName, MediaSourceId, JobId, TemporaryPath, OutputPath, Status, TargetId, DateCreated, Progress, AdditionalFiles, MediaSource) values (@Id, @ItemId, @ItemName, @MediaSourceId, @JobId, @TemporaryPath, @OutputPath, @Status, @TargetId, @DateCreated, @Progress, @AdditionalFiles, @MediaSource)"; + _saveJobItemCommand.CommandText = "replace into SyncJobItems (Id, ItemId, ItemName, MediaSourceId, JobId, TemporaryPath, OutputPath, Status, TargetId, DateCreated, Progress, AdditionalFiles, MediaSource, IsMarkedForRemoval) values (@Id, @ItemId, @ItemName, @MediaSourceId, @JobId, @TemporaryPath, @OutputPath, @Status, @TargetId, @DateCreated, @Progress, @AdditionalFiles, @MediaSource, @IsMarkedForRemoval)"; _saveJobItemCommand.Parameters.Add(_saveJobItemCommand, "@Id"); _saveJobItemCommand.Parameters.Add(_saveJobItemCommand, "@ItemId"); @@ -110,10 +110,11 @@ namespace MediaBrowser.Server.Implementations.Sync _saveJobItemCommand.Parameters.Add(_saveJobItemCommand, "@Progress"); _saveJobItemCommand.Parameters.Add(_saveJobItemCommand, "@AdditionalFiles"); _saveJobItemCommand.Parameters.Add(_saveJobItemCommand, "@MediaSource"); + _saveJobItemCommand.Parameters.Add(_saveJobItemCommand, "@IsMarkedForRemoval"); } private const string BaseJobSelectText = "select Id, TargetId, Name, Quality, Status, Progress, UserId, ItemIds, Category, ParentId, UnwatchedOnly, ItemLimit, SyncNewContent, DateCreated, DateLastModified, ItemCount from SyncJobs"; - private const string BaseJobItemSelectText = "select Id, ItemId, ItemName, MediaSourceId, JobId, TemporaryPath, OutputPath, Status, TargetId, DateCreated, Progress, AdditionalFiles, MediaSource from SyncJobItems"; + private const string BaseJobItemSelectText = "select Id, ItemId, ItemName, MediaSourceId, JobId, TemporaryPath, OutputPath, Status, TargetId, DateCreated, Progress, AdditionalFiles, MediaSource, IsMarkedForRemoval from SyncJobItems"; public SyncJob GetJob(string id) { @@ -572,6 +573,7 @@ namespace MediaBrowser.Server.Implementations.Sync _saveJobItemCommand.GetParameter(index++).Value = jobItem.Progress; _saveJobItemCommand.GetParameter(index++).Value = _json.SerializeToString(jobItem.AdditionalFiles); _saveJobItemCommand.GetParameter(index++).Value = jobItem.MediaSource == null ? null : _json.SerializeToString(jobItem.MediaSource); + _saveJobItemCommand.GetParameter(index++).Value = jobItem.IsMarkedForRemoval; _saveJobItemCommand.Transaction = transaction; @@ -673,6 +675,8 @@ namespace MediaBrowser.Server.Implementations.Sync } } + info.IsMarkedForRemoval = reader.GetBoolean(13); + return info; } diff --git a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs index f481a902d0..7eb68187a3 100644 --- a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs +++ b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs @@ -407,7 +407,7 @@ namespace MediaBrowser.Server.Startup.Common SyncRepository = await GetSyncRepository().ConfigureAwait(false); RegisterSingleInstance(SyncRepository); - UserManager = new UserManager(LogManager.GetLogger("UserManager"), ServerConfigurationManager, UserRepository, XmlSerializer, NetworkManager, () => ImageProcessor, () => DtoService, () => ConnectManager, this, JsonSerializer, FileSystemManager, () => ChannelManager, () => LibraryManager); + UserManager = new UserManager(LogManager.GetLogger("UserManager"), ServerConfigurationManager, UserRepository, XmlSerializer, NetworkManager, () => ImageProcessor, () => DtoService, () => ConnectManager, this, JsonSerializer, FileSystemManager); RegisterSingleInstance(UserManager); LibraryManager = new LibraryManager(Logger, TaskManager, UserManager, ServerConfigurationManager, UserDataManager, () => LibraryMonitor, FileSystemManager, () => ProviderManager); -- cgit v1.2.3 From f5b7e1dba42f0cf9951d8f2a2324f10fda425565 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 20 Jan 2015 23:56:00 -0500 Subject: add mark for removal options --- MediaBrowser.Api/Sync/SyncService.cs | 28 +++++++++++++++++ MediaBrowser.Controller/Sync/ISyncManager.cs | 14 +++++++++ MediaBrowser.Model/ApiClient/IApiClient.cs | 31 ++++++++++++++++++- MediaBrowser.Model/Sync/SyncJobItem.cs | 9 +++++- .../Localization/JavaScript/javascript.json | 3 ++ .../Sync/SyncManager.cs | 36 ++++++++++++++++++++++ 6 files changed, 119 insertions(+), 2 deletions(-) (limited to 'MediaBrowser.Controller') diff --git a/MediaBrowser.Api/Sync/SyncService.cs b/MediaBrowser.Api/Sync/SyncService.cs index c763aa8df1..b30df572b6 100644 --- a/MediaBrowser.Api/Sync/SyncService.cs +++ b/MediaBrowser.Api/Sync/SyncService.cs @@ -44,6 +44,20 @@ namespace MediaBrowser.Api.Sync public string Id { get; set; } } + [Route("/Sync/JobItems/{Id}/MarkForRemoval", "POST", Summary = "Marks a job item for removal")] + public class MarkJobItemForRemoval : IReturnVoid + { + [ApiMember(Name = "Id", Description = "Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "POST")] + public string Id { get; set; } + } + + [Route("/Sync/JobItems/{Id}/UnmarkForRemoval", "POST", Summary = "Unmarks a job item for removal")] + public class UnmarkJobItemForRemoval : IReturnVoid + { + [ApiMember(Name = "Id", Description = "Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "POST")] + public string Id { get; set; } + } + [Route("/Sync/JobItems/{Id}", "DELETE", Summary = "Cancels a sync job item")] public class CancelSyncJobItem : IReturnVoid { @@ -299,5 +313,19 @@ namespace MediaBrowser.Api.Sync Task.WaitAll(task); } + + public void Post(MarkJobItemForRemoval request) + { + var task = _syncManager.MarkJobItemForRemoval(request.Id); + + Task.WaitAll(task); + } + + public void Post(UnmarkJobItemForRemoval request) + { + var task = _syncManager.UnmarkJobItemForRemoval(request.Id); + + Task.WaitAll(task); + } } } diff --git a/MediaBrowser.Controller/Sync/ISyncManager.cs b/MediaBrowser.Controller/Sync/ISyncManager.cs index 8e4b6a44a0..62b6a3a379 100644 --- a/MediaBrowser.Controller/Sync/ISyncManager.cs +++ b/MediaBrowser.Controller/Sync/ISyncManager.cs @@ -128,5 +128,19 @@ namespace MediaBrowser.Controller.Sync /// The request. /// Task<SyncDataResponse>. Task SyncData(SyncDataRequest request); + + /// + /// Marks the job item for removal. + /// + /// The identifier. + /// Task. + Task MarkJobItemForRemoval(string id); + + /// + /// Unmarks the job item for removal. + /// + /// The identifier. + /// Task. + Task UnmarkJobItemForRemoval(string id); } } diff --git a/MediaBrowser.Model/ApiClient/IApiClient.cs b/MediaBrowser.Model/ApiClient/IApiClient.cs index e8535278bb..b6938b2174 100644 --- a/MediaBrowser.Model/ApiClient/IApiClient.cs +++ b/MediaBrowser.Model/ApiClient/IApiClient.cs @@ -1449,12 +1449,41 @@ namespace MediaBrowser.Model.ApiClient /// The request. /// Task<SyncDataResponse>. Task SyncData(SyncDataRequest request); - /// /// Gets the synchronize job item file URL. /// /// The identifier. /// System.String. string GetSyncJobItemFileUrl(string id); + /// + /// Marks the synchronize job item for removal. + /// + /// The identifier. + /// Task. + Task MarkSyncJobItemForRemoval(string id); + /// + /// Unmarks the synchronize job item for removal. + /// + /// The identifier. + /// Task. + Task UnmarkSyncJobItemForRemoval(string id); + /// + /// Queues the failed synchronize job item for retry. + /// + /// The identifier. + /// Task. + Task QueueFailedSyncJobItemForRetry(string id); + /// + /// Cancels the synchronize job item. + /// + /// The identifier. + /// Task. + Task CancelSyncJobItem(string id); + /// + /// Enables the cancelled synchronize job item. + /// + /// The identifier. + /// Task. + Task EnableCancelledSyncJobItem(string id); } } \ No newline at end of file diff --git a/MediaBrowser.Model/Sync/SyncJobItem.cs b/MediaBrowser.Model/Sync/SyncJobItem.cs index 133065bf92..195d1e17ef 100644 --- a/MediaBrowser.Model/Sync/SyncJobItem.cs +++ b/MediaBrowser.Model/Sync/SyncJobItem.cs @@ -86,8 +86,15 @@ namespace MediaBrowser.Model.Sync /// /// The temporary path. public string TemporaryPath { get; set; } + /// + /// Gets or sets the additional files. + /// + /// The additional files. public List AdditionalFiles { get; set; } - + /// + /// Gets or sets a value indicating whether this instance is marked for removal. + /// + /// true if this instance is marked for removal; otherwise, false. public bool IsMarkedForRemoval { get; set; } public SyncJobItem() diff --git a/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json b/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json index e4d20d3a15..62619a5672 100644 --- a/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json +++ b/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json @@ -59,6 +59,7 @@ "ButtonCancelItem": "Cancel item", "ButtonQueueForRetry": "Queue for retry", "ButtonReenable": "Re-enable", + "SyncJobItemStatusSyncedMarkForRemoval": "Marked for removal", "LabelAbortedByServerShutdown": "(Aborted by server shutdown)", "LabelScheduledTaskLastRan": "Last ran {0}, taking {1}.", "HeaderDeleteTaskTrigger": "Delete Task Trigger", @@ -70,6 +71,8 @@ "LabelFree": "Free", "HeaderSelectAudio": "Select Audio", "HeaderSelectSubtitles": "Select Subtitles", + "ButtonMarkForRemoval": "Mark for removal from device", + "ButtonUnmarkForRemoval": "Unmark for removal from device", "LabelDefaultStream": "(Default)", "LabelForcedStream": "(Forced)", "LabelDefaultForcedStream": "(Default/Forced)", diff --git a/MediaBrowser.Server.Implementations/Sync/SyncManager.cs b/MediaBrowser.Server.Implementations/Sync/SyncManager.cs index 7e4455ab36..b5e29533bb 100644 --- a/MediaBrowser.Server.Implementations/Sync/SyncManager.cs +++ b/MediaBrowser.Server.Implementations/Sync/SyncManager.cs @@ -684,5 +684,41 @@ namespace MediaBrowser.Server.Implementations.Sync await processor.UpdateJobStatus(jobItem.JobId).ConfigureAwait(false); } + + public async Task MarkJobItemForRemoval(string id) + { + var jobItem = _repo.GetJobItem(id); + + if (jobItem.Status != SyncJobItemStatus.Synced) + { + throw new ArgumentException("Operation is not valid for this job item"); + } + + jobItem.IsMarkedForRemoval = true; + + await _repo.Update(jobItem).ConfigureAwait(false); + + var processor = GetSyncJobProcessor(); + + await processor.UpdateJobStatus(jobItem.JobId).ConfigureAwait(false); + } + + public async Task UnmarkJobItemForRemoval(string id) + { + var jobItem = _repo.GetJobItem(id); + + if (jobItem.Status != SyncJobItemStatus.Synced) + { + throw new ArgumentException("Operation is not valid for this job item"); + } + + jobItem.IsMarkedForRemoval = false; + + await _repo.Update(jobItem).ConfigureAwait(false); + + var processor = GetSyncJobProcessor(); + + await processor.UpdateJobStatus(jobItem.JobId).ConfigureAwait(false); + } } } -- cgit v1.2.3 From b7e5e21c975cc4953764d48c1dacbcd4dc149de9 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 22 Jan 2015 11:41:34 -0500 Subject: update task buttons --- MediaBrowser.Api/BaseApiService.cs | 20 ++- MediaBrowser.Api/ConfigurationService.cs | 3 +- MediaBrowser.Api/Dlna/DlnaServerService.cs | 3 +- MediaBrowser.Api/Images/ImageService.cs | 16 +-- MediaBrowser.Api/Playback/BaseStreamingService.cs | 2 +- MediaBrowser.Api/PluginService.cs | 3 +- .../ScheduledTasks/ScheduledTaskService.cs | 3 +- MediaBrowser.Api/UserService.cs | 3 +- MediaBrowser.Controller/Entities/Folder.cs | 2 +- .../Entities/ISupportsBoxSetGrouping.cs | 9 +- MediaBrowser.Controller/Entities/Movies/BoxSet.cs | 2 +- MediaBrowser.Controller/Entities/Movies/Movie.cs | 7 - MediaBrowser.Dlna/DlnaManager.cs | 31 ++-- .../MediaBrowser.Model.Portable.csproj | 3 - .../MediaBrowser.Model.net35.csproj | 3 - MediaBrowser.Model/ApiClient/IApiClient.cs | 18 --- MediaBrowser.Model/Dto/VideoStreamOptions.cs | 158 --------------------- MediaBrowser.Model/MediaBrowser.Model.csproj | 1 - .../Collections/CollectionManager.cs | 64 ++++----- .../Library/Validators/BoxSetPostScanTask.cs | 50 ------- .../Localization/JavaScript/javascript.json | 8 +- .../MediaBrowser.Server.Implementations.csproj | 1 - 22 files changed, 86 insertions(+), 324 deletions(-) delete mode 100644 MediaBrowser.Model/Dto/VideoStreamOptions.cs delete mode 100644 MediaBrowser.Server.Implementations/Library/Validators/BoxSetPostScanTask.cs (limited to 'MediaBrowser.Controller') diff --git a/MediaBrowser.Api/BaseApiService.cs b/MediaBrowser.Api/BaseApiService.cs index 297a131557..e909696553 100644 --- a/MediaBrowser.Api/BaseApiService.cs +++ b/MediaBrowser.Api/BaseApiService.cs @@ -4,6 +4,7 @@ using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Net; using MediaBrowser.Controller.Session; using MediaBrowser.Model.Logging; +using ServiceStack.Text.Controller; using ServiceStack.Web; using System; using System.Collections.Generic; @@ -21,7 +22,7 @@ namespace MediaBrowser.Api /// /// The logger. public ILogger Logger { get; set; } - + /// /// Gets or sets the HTTP result factory. /// @@ -143,7 +144,7 @@ namespace MediaBrowser.Api { if (!string.IsNullOrEmpty(parentId)) { - var folder = (Folder) libraryManager.GetItemById(new Guid(parentId)); + var folder = (Folder)libraryManager.GetItemById(new Guid(parentId)); if (userId.HasValue) { @@ -287,6 +288,20 @@ namespace MediaBrowser.Api }) ?? name; } + protected string GetPathValue(int index) + { + var pathInfo = PathInfo.Parse(Request.PathInfo); + var first = pathInfo.GetArgumentValue(0); + + // backwards compatibility + if (string.Equals(first, "mediabrowser", StringComparison.OrdinalIgnoreCase)) + { + index++; + } + + return pathInfo.GetArgumentValue(index); + } + /// /// Gets the name of the item by. /// @@ -294,7 +309,6 @@ namespace MediaBrowser.Api /// The type. /// The library manager. /// Task{BaseItem}. - /// protected BaseItem GetItemByName(string name, string type, ILibraryManager libraryManager) { BaseItem item; diff --git a/MediaBrowser.Api/ConfigurationService.cs b/MediaBrowser.Api/ConfigurationService.cs index 3eb0296fcb..d0abd18c28 100644 --- a/MediaBrowser.Api/ConfigurationService.cs +++ b/MediaBrowser.Api/ConfigurationService.cs @@ -143,8 +143,7 @@ namespace MediaBrowser.Api public void Post(UpdateNamedConfiguration request) { - var pathInfo = PathInfo.Parse(Request.PathInfo); - var key = pathInfo.GetArgumentValue(2); + var key = GetPathValue(2); var configurationType = _configurationManager.GetConfigurationType(key); var configuration = _jsonSerializer.DeserializeFromStream(request.RequestStream, configurationType); diff --git a/MediaBrowser.Api/Dlna/DlnaServerService.cs b/MediaBrowser.Api/Dlna/DlnaServerService.cs index 94d6e25b03..2383017c6b 100644 --- a/MediaBrowser.Api/Dlna/DlnaServerService.cs +++ b/MediaBrowser.Api/Dlna/DlnaServerService.cs @@ -120,8 +120,7 @@ namespace MediaBrowser.Api.Dlna private async Task PostAsync(Stream requestStream, IUpnpService service) { - var pathInfo = PathInfo.Parse(Request.PathInfo); - var id = pathInfo.GetArgumentValue(2); + var id = GetPathValue(2); using (var reader = new StreamReader(requestStream)) { diff --git a/MediaBrowser.Api/Images/ImageService.cs b/MediaBrowser.Api/Images/ImageService.cs index f2586b0438..f141d9df92 100644 --- a/MediaBrowser.Api/Images/ImageService.cs +++ b/MediaBrowser.Api/Images/ImageService.cs @@ -396,8 +396,7 @@ namespace MediaBrowser.Api.Images public object Get(GetItemByNameImage request) { - var pathInfo = PathInfo.Parse(Request.PathInfo); - var type = pathInfo.GetArgumentValue(0); + var type = GetPathValue(0); var item = GetItemByName(request.Name, type, _libraryManager); @@ -406,8 +405,7 @@ namespace MediaBrowser.Api.Images public object Head(GetItemByNameImage request) { - var pathInfo = PathInfo.Parse(Request.PathInfo); - var type = pathInfo.GetArgumentValue(0); + var type = GetPathValue(0); var item = GetItemByName(request.Name, type, _libraryManager); @@ -420,10 +418,9 @@ namespace MediaBrowser.Api.Images /// The request. public void Post(PostUserImage request) { - var pathInfo = PathInfo.Parse(Request.PathInfo); - var id = new Guid(pathInfo.GetArgumentValue(1)); + var id = new Guid(GetPathValue(1)); - request.Type = (ImageType)Enum.Parse(typeof(ImageType), pathInfo.GetArgumentValue(3), true); + request.Type = (ImageType)Enum.Parse(typeof(ImageType), GetPathValue(3), true); var item = _userManager.GetUserById(id); @@ -438,10 +435,9 @@ namespace MediaBrowser.Api.Images /// The request. public void Post(PostItemImage request) { - var pathInfo = PathInfo.Parse(Request.PathInfo); - var id = new Guid(pathInfo.GetArgumentValue(1)); + var id = new Guid(GetPathValue(1)); - request.Type = (ImageType)Enum.Parse(typeof(ImageType), pathInfo.GetArgumentValue(3), true); + request.Type = (ImageType)Enum.Parse(typeof(ImageType), GetPathValue(3), true); var item = _libraryManager.GetItemById(id); diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index b3610bc389..77f6dc1035 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -824,7 +824,7 @@ namespace MediaBrowser.Api.Playback { get { - return false; + return true; } } diff --git a/MediaBrowser.Api/PluginService.cs b/MediaBrowser.Api/PluginService.cs index 62aa1e755a..f9098f5bf6 100644 --- a/MediaBrowser.Api/PluginService.cs +++ b/MediaBrowser.Api/PluginService.cs @@ -236,8 +236,7 @@ namespace MediaBrowser.Api { // We need to parse this manually because we told service stack not to with IRequiresRequestStream // https://code.google.com/p/servicestack/source/browse/trunk/Common/ServiceStack.Text/ServiceStack.Text/Controller/PathInfo.cs - var pathInfo = PathInfo.Parse(Request.PathInfo); - var id = new Guid(pathInfo.GetArgumentValue(1)); + var id = new Guid(GetPathValue(1)); var plugin = _appHost.Plugins.First(p => p.Id == id); diff --git a/MediaBrowser.Api/ScheduledTasks/ScheduledTaskService.cs b/MediaBrowser.Api/ScheduledTasks/ScheduledTaskService.cs index 947b99d35f..e3722b4a75 100644 --- a/MediaBrowser.Api/ScheduledTasks/ScheduledTaskService.cs +++ b/MediaBrowser.Api/ScheduledTasks/ScheduledTaskService.cs @@ -224,8 +224,7 @@ namespace MediaBrowser.Api.ScheduledTasks { // We need to parse this manually because we told service stack not to with IRequiresRequestStream // https://code.google.com/p/servicestack/source/browse/trunk/Common/ServiceStack.Text/ServiceStack.Text/Controller/PathInfo.cs - var pathInfo = PathInfo.Parse(Request.PathInfo); - var id = pathInfo.GetArgumentValue(1); + var id = GetPathValue(1); var task = TaskManager.ScheduledTasks.FirstOrDefault(i => string.Equals(i.Id, id)); diff --git a/MediaBrowser.Api/UserService.cs b/MediaBrowser.Api/UserService.cs index 51a7584b8d..37553e4a4b 100644 --- a/MediaBrowser.Api/UserService.cs +++ b/MediaBrowser.Api/UserService.cs @@ -449,8 +449,7 @@ namespace MediaBrowser.Api { // We need to parse this manually because we told service stack not to with IRequiresRequestStream // https://code.google.com/p/servicestack/source/browse/trunk/Common/ServiceStack.Text/ServiceStack.Text/Controller/PathInfo.cs - var pathInfo = PathInfo.Parse(Request.PathInfo); - var id = new Guid(pathInfo.GetArgumentValue(1)); + var id = new Guid(GetPathValue(1)); var dtoUser = request; diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index 005f263f7c..ff6e8e85b1 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -301,7 +301,7 @@ namespace MediaBrowser.Controller.Entities public override bool IsVisible(User user) { - if (this is ICollectionFolder) + if (this is ICollectionFolder && !(this is BasePluginFolder)) { if (user.Policy.BlockedMediaFolders != null) { diff --git a/MediaBrowser.Controller/Entities/ISupportsBoxSetGrouping.cs b/MediaBrowser.Controller/Entities/ISupportsBoxSetGrouping.cs index 0fd463155f..fbe5a06d0e 100644 --- a/MediaBrowser.Controller/Entities/ISupportsBoxSetGrouping.cs +++ b/MediaBrowser.Controller/Entities/ISupportsBoxSetGrouping.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; - + namespace MediaBrowser.Controller.Entities { /// @@ -10,10 +8,5 @@ namespace MediaBrowser.Controller.Entities /// public interface ISupportsBoxSetGrouping { - /// - /// Gets or sets the box set identifier list. - /// - /// The box set identifier list. - List BoxSetIdList { get; set; } } } diff --git a/MediaBrowser.Controller/Entities/Movies/BoxSet.cs b/MediaBrowser.Controller/Entities/Movies/BoxSet.cs index e48b8d8457..63690661a8 100644 --- a/MediaBrowser.Controller/Entities/Movies/BoxSet.cs +++ b/MediaBrowser.Controller/Entities/Movies/BoxSet.cs @@ -4,13 +4,13 @@ using MediaBrowser.Controller.Providers; using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Entities; using MediaBrowser.Model.Querying; +using MediaBrowser.Model.Users; using System; using System.Collections.Generic; using System.Linq; using System.Runtime.Serialization; using System.Threading; using System.Threading.Tasks; -using MediaBrowser.Model.Users; namespace MediaBrowser.Controller.Entities.Movies { diff --git a/MediaBrowser.Controller/Entities/Movies/Movie.cs b/MediaBrowser.Controller/Entities/Movies/Movie.cs index b3774cfe02..2fa5fc6e1e 100644 --- a/MediaBrowser.Controller/Entities/Movies/Movie.cs +++ b/MediaBrowser.Controller/Entities/Movies/Movie.cs @@ -25,12 +25,6 @@ namespace MediaBrowser.Controller.Entities.Movies public List ThemeVideoIds { get; set; } public List ProductionLocations { get; set; } - /// - /// This is just a cache to enable quick access by Id - /// - [IgnoreDataMember] - public List BoxSetIdList { get; set; } - public Movie() { SpecialFeatureIds = new List(); @@ -40,7 +34,6 @@ namespace MediaBrowser.Controller.Entities.Movies RemoteTrailerIds = new List(); ThemeSongIds = new List(); ThemeVideoIds = new List(); - BoxSetIdList = new List(); Taglines = new List(); Keywords = new List(); ProductionLocations = new List(); diff --git a/MediaBrowser.Dlna/DlnaManager.cs b/MediaBrowser.Dlna/DlnaManager.cs index 31f1e0a883..2c22abd4d9 100644 --- a/MediaBrowser.Dlna/DlnaManager.cs +++ b/MediaBrowser.Dlna/DlnaManager.cs @@ -132,61 +132,74 @@ namespace MediaBrowser.Dlna { if (!string.IsNullOrWhiteSpace(profileInfo.DeviceDescription)) { - if (deviceInfo.DeviceDescription == null || !Regex.IsMatch(deviceInfo.DeviceDescription, profileInfo.DeviceDescription)) + if (deviceInfo.DeviceDescription == null || !IsRegexMatch(deviceInfo.DeviceDescription, profileInfo.DeviceDescription)) return false; } if (!string.IsNullOrWhiteSpace(profileInfo.FriendlyName)) { - if (deviceInfo.FriendlyName == null || !Regex.IsMatch(deviceInfo.FriendlyName, profileInfo.FriendlyName)) + if (deviceInfo.FriendlyName == null || !IsRegexMatch(deviceInfo.FriendlyName, profileInfo.FriendlyName)) return false; } if (!string.IsNullOrWhiteSpace(profileInfo.Manufacturer)) { - if (deviceInfo.Manufacturer == null || !Regex.IsMatch(deviceInfo.Manufacturer, profileInfo.Manufacturer)) + if (deviceInfo.Manufacturer == null || !IsRegexMatch(deviceInfo.Manufacturer, profileInfo.Manufacturer)) return false; } if (!string.IsNullOrWhiteSpace(profileInfo.ManufacturerUrl)) { - if (deviceInfo.ManufacturerUrl == null || !Regex.IsMatch(deviceInfo.ManufacturerUrl, profileInfo.ManufacturerUrl)) + if (deviceInfo.ManufacturerUrl == null || !IsRegexMatch(deviceInfo.ManufacturerUrl, profileInfo.ManufacturerUrl)) return false; } if (!string.IsNullOrWhiteSpace(profileInfo.ModelDescription)) { - if (deviceInfo.ModelDescription == null || !Regex.IsMatch(deviceInfo.ModelDescription, profileInfo.ModelDescription)) + if (deviceInfo.ModelDescription == null || !IsRegexMatch(deviceInfo.ModelDescription, profileInfo.ModelDescription)) return false; } if (!string.IsNullOrWhiteSpace(profileInfo.ModelName)) { - if (deviceInfo.ModelName == null || !Regex.IsMatch(deviceInfo.ModelName, profileInfo.ModelName)) + if (deviceInfo.ModelName == null || !IsRegexMatch(deviceInfo.ModelName, profileInfo.ModelName)) return false; } if (!string.IsNullOrWhiteSpace(profileInfo.ModelNumber)) { - if (deviceInfo.ModelNumber == null || !Regex.IsMatch(deviceInfo.ModelNumber, profileInfo.ModelNumber)) + if (deviceInfo.ModelNumber == null || !IsRegexMatch(deviceInfo.ModelNumber, profileInfo.ModelNumber)) return false; } if (!string.IsNullOrWhiteSpace(profileInfo.ModelUrl)) { - if (deviceInfo.ModelUrl == null || !Regex.IsMatch(deviceInfo.ModelUrl, profileInfo.ModelUrl)) + if (deviceInfo.ModelUrl == null || !IsRegexMatch(deviceInfo.ModelUrl, profileInfo.ModelUrl)) return false; } if (!string.IsNullOrWhiteSpace(profileInfo.SerialNumber)) { - if (deviceInfo.SerialNumber == null || !Regex.IsMatch(deviceInfo.SerialNumber, profileInfo.SerialNumber)) + if (deviceInfo.SerialNumber == null || !IsRegexMatch(deviceInfo.SerialNumber, profileInfo.SerialNumber)) return false; } return true; } + private bool IsRegexMatch(string input, string pattern) + { + try + { + return Regex.IsMatch(input, pattern); + } + catch (ArgumentException ex) + { + _logger.ErrorException("Error evaluating regex pattern {0}", ex, pattern); + return false; + } + } + public DeviceProfile GetProfile(IDictionary headers) { if (headers == null) diff --git a/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj b/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj index 91d0e15f88..0a350f5179 100644 --- a/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj +++ b/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj @@ -497,9 +497,6 @@ Dto\UserItemDataDto.cs - - Dto\VideoStreamOptions.cs - Entities\BaseItemInfo.cs diff --git a/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj b/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj index 47e0190518..0c5946d129 100644 --- a/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj +++ b/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj @@ -462,9 +462,6 @@ Dto\UserItemDataDto.cs - - Dto\VideoStreamOptions.cs - Entities\BaseItemInfo.cs diff --git a/MediaBrowser.Model/ApiClient/IApiClient.cs b/MediaBrowser.Model/ApiClient/IApiClient.cs index b6938b2174..0e69bb91f7 100644 --- a/MediaBrowser.Model/ApiClient/IApiClient.cs +++ b/MediaBrowser.Model/ApiClient/IApiClient.cs @@ -1316,24 +1316,6 @@ namespace MediaBrowser.Model.ApiClient /// Task<QueryResult<BaseItemDto>>. Task> GetPlaylistItems(PlaylistItemQuery query); - /// - /// Gets the url needed to stream a video file - /// - /// The options. - /// System.String. - /// options - [Obsolete] - string GetVideoStreamUrl(VideoStreamOptions options); - - /// - /// Formulates a url for streaming video using the HLS protocol - /// - /// The options. - /// System.String. - /// options - [Obsolete] - string GetHlsVideoStreamUrl(VideoStreamOptions options); - /// /// Sends the context message asynchronous. /// diff --git a/MediaBrowser.Model/Dto/VideoStreamOptions.cs b/MediaBrowser.Model/Dto/VideoStreamOptions.cs deleted file mode 100644 index e9a83bd12a..0000000000 --- a/MediaBrowser.Model/Dto/VideoStreamOptions.cs +++ /dev/null @@ -1,158 +0,0 @@ -using System; - -namespace MediaBrowser.Model.Dto -{ - /// - /// Class VideoStreamOptions - /// - [Obsolete] - public class VideoStreamOptions - { - /// - /// Gets or sets the audio bit rate. - /// - /// The audio bit rate. - public int? AudioBitRate { get; set; } - - /// - /// Gets or sets the audio codec. - /// Omit to copy the original stream - /// - /// The audio encoding format. - public string AudioCodec { get; set; } - - /// - /// Gets or sets the item id. - /// - /// The item id. - public string ItemId { get; set; } - - /// - /// Gets or sets the max audio channels. - /// - /// The max audio channels. - public int? MaxAudioChannels { get; set; } - - /// - /// Gets or sets the max audio sample rate. - /// - /// The max audio sample rate. - public int? MaxAudioSampleRate { get; set; } - - /// - /// Gets or sets the start time ticks. - /// - /// The start time ticks. - public long? StartTimeTicks { get; set; } - - /// - /// Gets or sets a value indicating whether the original media should be served statically - /// Only used with progressive streaming - /// - /// true if static; otherwise, false. - public bool? Static { get; set; } - - /// - /// Gets or sets the output file extension. - /// - /// The output file extension. - public string OutputFileExtension { get; set; } - - /// - /// Gets or sets the device id. - /// - /// The device id. - public string DeviceId { get; set; } - - /// - /// Gets or sets the video codec. - /// Omit to copy - /// - /// The video codec. - public string VideoCodec { get; set; } - - /// - /// Gets or sets the video bit rate. - /// - /// The video bit rate. - public int? VideoBitRate { get; set; } - - /// - /// Gets or sets the width. - /// - /// The width. - public int? Width { get; set; } - - /// - /// Gets or sets the height. - /// - /// The height. - public int? Height { get; set; } - - /// - /// Gets or sets the width of the max. - /// - /// The width of the max. - public int? MaxWidth { get; set; } - - /// - /// Gets or sets the height of the max. - /// - /// The height of the max. - public int? MaxHeight { get; set; } - - /// - /// Gets or sets the frame rate. - /// - /// The frame rate. - public double? FrameRate { get; set; } - - /// - /// Gets or sets the index of the audio stream. - /// - /// The index of the audio stream. - public int? AudioStreamIndex { get; set; } - - /// - /// Gets or sets the index of the video stream. - /// - /// The index of the video stream. - public int? VideoStreamIndex { get; set; } - - /// - /// Gets or sets the index of the subtitle stream. - /// - /// The index of the subtitle stream. - public int? SubtitleStreamIndex { get; set; } - - /// - /// Gets or sets the profile. - /// - /// The profile. - public string Profile { get; set; } - - /// - /// Gets or sets the level. - /// - /// The level. - public string Level { get; set; } - - /// - /// Gets or sets the baseline stream audio bit rate. - /// - /// The baseline stream audio bit rate. - public int? BaselineStreamAudioBitRate { get; set; } - - /// - /// Gets or sets a value indicating whether [append baseline stream]. - /// - /// true if [append baseline stream]; otherwise, false. - public bool AppendBaselineStream { get; set; } - - /// - /// Gets or sets the time stamp offset ms. Only used with HLS. - /// - /// The time stamp offset ms. - public int? TimeStampOffsetMs { get; set; } - } -} \ No newline at end of file diff --git a/MediaBrowser.Model/MediaBrowser.Model.csproj b/MediaBrowser.Model/MediaBrowser.Model.csproj index 36d22347fe..bad17abaea 100644 --- a/MediaBrowser.Model/MediaBrowser.Model.csproj +++ b/MediaBrowser.Model/MediaBrowser.Model.csproj @@ -135,7 +135,6 @@ - diff --git a/MediaBrowser.Server.Implementations/Collections/CollectionManager.cs b/MediaBrowser.Server.Implementations/Collections/CollectionManager.cs index d92db34e33..6100e3f5dc 100644 --- a/MediaBrowser.Server.Implementations/Collections/CollectionManager.cs +++ b/MediaBrowser.Server.Implementations/Collections/CollectionManager.cs @@ -167,18 +167,6 @@ namespace MediaBrowser.Server.Implementations.Collections } list.Add(LinkedChild.Create(item)); - - var supportsGrouping = item as ISupportsBoxSetGrouping; - - if (supportsGrouping != null) - { - var boxsetIdList = supportsGrouping.BoxSetIdList.ToList(); - if (!boxsetIdList.Contains(collectionId)) - { - boxsetIdList.Add(collectionId); - } - supportsGrouping.BoxSetIdList = boxsetIdList; - } } collection.LinkedChildren.AddRange(list); @@ -228,15 +216,6 @@ namespace MediaBrowser.Server.Implementations.Collections { itemList.Add(childItem); } - - var supportsGrouping = childItem as ISupportsBoxSetGrouping; - - if (supportsGrouping != null) - { - var boxsetIdList = supportsGrouping.BoxSetIdList.ToList(); - boxsetIdList.Remove(collectionId); - supportsGrouping.BoxSetIdList = boxsetIdList; - } } var shortcutFiles = Directory @@ -289,29 +268,40 @@ namespace MediaBrowser.Server.Implementations.Collections public IEnumerable CollapseItemsWithinBoxSets(IEnumerable items, User user) { - var itemsToCollapse = new List(); - var boxsets = new List(); + var results = new Dictionary(); + var allBoxsets = new List(); - var list = items.ToList(); - - foreach (var item in list.OfType()) + foreach (var item in items) { - var currentBoxSets = item.BoxSetIdList - .Select(i => _libraryManager.GetItemById(i)) - .Where(i => i != null && i.IsVisible(user)) - .ToList(); + var grouping = item as ISupportsBoxSetGrouping; - if (currentBoxSets.Count > 0) + if (grouping == null) + { + results[item.Id] = item; + } + else { - itemsToCollapse.Add(item); - boxsets.AddRange(currentBoxSets); + var itemId = item.Id; + + var currentBoxSets = allBoxsets + .Where(i => i.GetLinkedChildren().Any(j => j.Id == itemId)) + .ToList(); + + if (currentBoxSets.Count > 0) + { + foreach (var boxset in currentBoxSets) + { + results[boxset.Id] = boxset; + } + } + else + { + results[item.Id] = item; + } } } - return list - .Except(itemsToCollapse.Cast()) - .Concat(boxsets) - .DistinctBy(i => i.Id); + return results.Values; } } } diff --git a/MediaBrowser.Server.Implementations/Library/Validators/BoxSetPostScanTask.cs b/MediaBrowser.Server.Implementations/Library/Validators/BoxSetPostScanTask.cs deleted file mode 100644 index 86d88f7e04..0000000000 --- a/MediaBrowser.Server.Implementations/Library/Validators/BoxSetPostScanTask.cs +++ /dev/null @@ -1,50 +0,0 @@ -using MediaBrowser.Controller.Entities; -using MediaBrowser.Controller.Entities.Movies; -using MediaBrowser.Controller.Library; -using System; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; - -namespace MediaBrowser.Server.Implementations.Library.Validators -{ - public class BoxSetPostScanTask : ILibraryPostScanTask - { - private readonly ILibraryManager _libraryManager; - - public BoxSetPostScanTask(ILibraryManager libraryManager) - { - _libraryManager = libraryManager; - } - - public Task Run(IProgress progress, CancellationToken cancellationToken) - { - var items = _libraryManager.RootFolder.RecursiveChildren.ToList(); - - var boxsets = items.OfType().ToList(); - - var numComplete = 0; - - foreach (var boxset in boxsets) - { - foreach (var child in boxset.Children.Concat(boxset.GetLinkedChildren()).OfType()) - { - var boxsetIdList = child.BoxSetIdList.ToList(); - if (!boxsetIdList.Contains(boxset.Id)) - { - boxsetIdList.Add(boxset.Id); - } - child.BoxSetIdList = boxsetIdList; - } - - numComplete++; - double percent = numComplete; - percent /= boxsets.Count; - progress.Report(percent * 100); - } - - progress.Report(100); - return Task.FromResult(true); - } - } -} diff --git a/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json b/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json index 62619a5672..4206ccf591 100644 --- a/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json +++ b/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json @@ -45,6 +45,8 @@ "ButtonHelp": "Help", "ButtonSave": "Save", "HeaderDevices": "Devices", + "ButtonScheduledTasks": "Scheduled tasks", + "ConfirmMessageScheduledTaskButton": "This operation normally runs automatically as a scheduled task. It can also be run manually here. To configure the scheduled task, see:", "HeaderSupporterBenefit": "A supporter membership provides additional benefits such as access to premium plugins, internet channel content, and more. {0}Learn more{1}.", "HeaderWelcomeToMediaBrowserServerDashboard": "Welcome to the Media Browser Dashboard", "HeaderWelcomeToMediaBrowserWebClient": "Welcome to the Media Browser Web Client", @@ -59,7 +61,7 @@ "ButtonCancelItem": "Cancel item", "ButtonQueueForRetry": "Queue for retry", "ButtonReenable": "Re-enable", - "SyncJobItemStatusSyncedMarkForRemoval": "Marked for removal", + "SyncJobItemStatusSyncedMarkForRemoval": "Marked for removal", "LabelAbortedByServerShutdown": "(Aborted by server shutdown)", "LabelScheduledTaskLastRan": "Last ran {0}, taking {1}.", "HeaderDeleteTaskTrigger": "Delete Task Trigger", @@ -71,8 +73,8 @@ "LabelFree": "Free", "HeaderSelectAudio": "Select Audio", "HeaderSelectSubtitles": "Select Subtitles", - "ButtonMarkForRemoval": "Mark for removal from device", - "ButtonUnmarkForRemoval": "Unmark for removal from device", + "ButtonMarkForRemoval": "Mark for removal from device", + "ButtonUnmarkForRemoval": "Unmark for removal from device", "LabelDefaultStream": "(Default)", "LabelForcedStream": "(Forced)", "LabelDefaultForcedStream": "(Default/Forced)", diff --git a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj index 548ac07aaf..fe5642dbc7 100644 --- a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj +++ b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj @@ -209,7 +209,6 @@ - -- cgit v1.2.3 From 1af651bc56025935cebe2762d6f36be41530eba1 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 23 Jan 2015 23:50:45 -0500 Subject: add Add to collection buttons --- MediaBrowser.Controller/Channels/Channel.cs | 7 ++++++- MediaBrowser.Controller/Entities/BaseItem.cs | 17 ++++------------- MediaBrowser.Controller/Entities/UserViewBuilder.cs | 18 +++++++++++++++++- MediaBrowser.Providers/Manager/ProviderManager.cs | 9 ++++++--- .../Channels/ChannelManager.cs | 6 +++--- .../Library/LibraryManager.cs | 2 +- .../Library/Resolvers/Movies/BoxSetResolver.cs | 12 ------------ .../Localization/JavaScript/javascript.json | 7 +++++++ .../Localization/Server/server.json | 9 +++++---- .../Themes/AppThemeManager.cs | 2 +- MediaBrowser.Server.Startup.Common/ApplicationHost.cs | 2 +- MediaBrowser.WebDashboard/Api/PackageCreator.cs | 3 ++- .../MediaBrowser.WebDashboard.csproj | 3 +++ 13 files changed, 56 insertions(+), 41 deletions(-) (limited to 'MediaBrowser.Controller') diff --git a/MediaBrowser.Controller/Channels/Channel.cs b/MediaBrowser.Controller/Channels/Channel.cs index 32ad2ff122..87d257f12e 100644 --- a/MediaBrowser.Controller/Channels/Channel.cs +++ b/MediaBrowser.Controller/Channels/Channel.cs @@ -60,7 +60,12 @@ namespace MediaBrowser.Controller.Channels protected override string GetInternalMetadataPath(string basePath) { - return System.IO.Path.Combine(basePath, "channels", Id.ToString("N"), "metadata"); + return GetInternalMetadataPath(basePath, Id); + } + + public static string GetInternalMetadataPath(string basePath, Guid id) + { + return System.IO.Path.Combine(basePath, "channels", id.ToString("N"), "metadata"); } } } diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index 6a30df7fe8..2be4f99e9c 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -381,11 +381,6 @@ namespace MediaBrowser.Controller.Entities { var basePath = ConfigurationManager.ApplicationPaths.InternalMetadataPath; - if (ConfigurationManager.Configuration.EnableLibraryMetadataSubFolder) - { - basePath = System.IO.Path.Combine(basePath, "library"); - } - return GetInternalMetadataPath(basePath); } @@ -393,14 +388,10 @@ namespace MediaBrowser.Controller.Entities { var idString = Id.ToString("N"); - return System.IO.Path.Combine(basePath, idString.Substring(0, 2), idString); - } - - public static string GetInternalMetadataPathForId(Guid id) - { - var idString = id.ToString("N"); - - var basePath = ConfigurationManager.ApplicationPaths.InternalMetadataPath; + if (ConfigurationManager.Configuration.EnableLibraryMetadataSubFolder) + { + basePath = System.IO.Path.Combine(basePath, "library"); + } return System.IO.Path.Combine(basePath, idString.Substring(0, 2), idString); } diff --git a/MediaBrowser.Controller/Entities/UserViewBuilder.cs b/MediaBrowser.Controller/Entities/UserViewBuilder.cs index 166d56c514..deb85ed6a0 100644 --- a/MediaBrowser.Controller/Entities/UserViewBuilder.cs +++ b/MediaBrowser.Controller/Entities/UserViewBuilder.cs @@ -117,7 +117,7 @@ namespace MediaBrowser.Controller.Entities return await GetGameView(user, queryParent, query).ConfigureAwait(false); case CollectionType.BoxSets: - return GetResult(GetMediaFolders(user).SelectMany(i => i.GetRecursiveChildren(user)).OfType(), queryParent, query); + return await GetBoxsetView(queryParent, user, query).ConfigureAwait(false); case CollectionType.TvShows: return await GetTvView(queryParent, user, query).ConfigureAwait(false); @@ -526,6 +526,22 @@ namespace MediaBrowser.Controller.Entities return GetResult(items, queryParent, query); } + private async Task> GetBoxsetView(Folder parent, User user, InternalItemsQuery query) + { + return GetResult(GetMediaFolders(user).SelectMany(i => + { + var hasCollectionType = i as ICollectionFolder; + + if (hasCollectionType != null && string.Equals(hasCollectionType.CollectionType, CollectionType.BoxSets, StringComparison.OrdinalIgnoreCase)) + { + return i.GetChildren(user, true); + } + + return i.GetRecursiveChildren(user); + + }).OfType(), parent, query); + } + private async Task> GetTvView(Folder parent, User user, InternalItemsQuery query) { if (query.Recursive) diff --git a/MediaBrowser.Providers/Manager/ProviderManager.cs b/MediaBrowser.Providers/Manager/ProviderManager.cs index d9982e7863..823c34a756 100644 --- a/MediaBrowser.Providers/Manager/ProviderManager.cs +++ b/MediaBrowser.Providers/Manager/ProviderManager.cs @@ -1,5 +1,6 @@ using MediaBrowser.Common.IO; using MediaBrowser.Common.Net; +using MediaBrowser.Controller; using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.Audio; @@ -58,6 +59,7 @@ namespace MediaBrowser.Providers.Manager private IMetadataProvider[] _metadataProviders = { }; private IEnumerable _savers; private IImageSaver[] _imageSavers; + private readonly IServerApplicationPaths _appPaths; private IExternalId[] _externalIds; @@ -69,13 +71,14 @@ namespace MediaBrowser.Providers.Manager /// The directory watchers. /// The log manager. /// The file system. - public ProviderManager(IHttpClient httpClient, IServerConfigurationManager configurationManager, ILibraryMonitor libraryMonitor, ILogManager logManager, IFileSystem fileSystem) + public ProviderManager(IHttpClient httpClient, IServerConfigurationManager configurationManager, ILibraryMonitor libraryMonitor, ILogManager logManager, IFileSystem fileSystem, IServerApplicationPaths appPaths) { _logger = logManager.GetLogger("ProviderManager"); _httpClient = httpClient; ConfigurationManager = configurationManager; _libraryMonitor = libraryMonitor; _fileSystem = fileSystem; + _appPaths = appPaths; } /// @@ -467,7 +470,7 @@ namespace MediaBrowser.Providers.Manager // Give it a dummy path just so that it looks like a file system item var dummy = new T() { - Path = BaseItem.GetInternalMetadataPathForId(Guid.NewGuid()), + Path = Path.Combine(_appPaths.InternalMetadataPath, "dummy"), // Dummy this up to fool the local trailer check Parent = new Folder() @@ -709,7 +712,7 @@ namespace MediaBrowser.Providers.Manager // Give it a dummy path just so that it looks like a file system item var dummy = new TItemType { - Path = BaseItem.GetInternalMetadataPathForId(Guid.NewGuid()), + Path = Path.Combine(_appPaths.InternalMetadataPath, "dummy"), // Dummy this up to fool the local trailer check Parent = new Folder() diff --git a/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs b/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs index a7e248ea46..99ca0b5dac 100644 --- a/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs +++ b/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs @@ -393,7 +393,9 @@ namespace MediaBrowser.Server.Implementations.Channels private async Task GetChannel(IChannel channelInfo, CancellationToken cancellationToken) { - var path = Path.Combine(_config.ApplicationPaths.ItemsByNamePath, "channels", _fileSystem.GetValidFilename(channelInfo.Name)); + var id = GetInternalChannelId(channelInfo.Name); + + var path = Channel.GetInternalMetadataPath(_config.ApplicationPaths.InternalMetadataPath, id); var fileInfo = new DirectoryInfo(path); @@ -414,8 +416,6 @@ namespace MediaBrowser.Server.Implementations.Channels isNew = true; } - var id = GetInternalChannelId(channelInfo.Name); - var item = _libraryManager.GetItemById(id) as Channel; if (item == null) diff --git a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs index b28c987286..1306188dad 100644 --- a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs +++ b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs @@ -1646,7 +1646,7 @@ namespace MediaBrowser.Server.Implementations.Library var id = GetNewItemId("7_namedview_" + name + user.Id.ToString("N") + parentId, typeof(UserView)); - var path = BaseItem.GetInternalMetadataPathForId(id); + var path = Path.Combine(ConfigurationManager.ApplicationPaths.InternalMetadataPath, "views", "specialviews", id.ToString("N")); var item = GetItemById(id) as UserView; diff --git a/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/BoxSetResolver.cs b/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/BoxSetResolver.cs index 67b9d546fd..e3447afc99 100644 --- a/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/BoxSetResolver.cs +++ b/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/BoxSetResolver.cs @@ -4,7 +4,6 @@ using MediaBrowser.Controller.Library; using MediaBrowser.Model.Entities; using System; using System.IO; -using System.Linq; namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies { @@ -46,17 +45,6 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies return null; } - private bool IsInvalid(string collectionType) - { - var validCollectionTypes = new[] - { - CollectionType.Movies, - CollectionType.BoxSets - }; - - return !validCollectionTypes.Contains(collectionType ?? string.Empty, StringComparer.OrdinalIgnoreCase); - } - /// /// Sets the initial item values. /// diff --git a/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json b/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json index 5d37007e06..914924f42b 100644 --- a/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json +++ b/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json @@ -45,8 +45,14 @@ "LabelFailed": "(failed)", "ButtonHelp": "Help", "ButtonSave": "Save", + "HeaderAddToCollection": "Add to Collection", + "NewCollectionNameExample": "Example: Star Wars Collection", + "OptionSearchForInternetMetadata": "Search the internet for artwork and metadata", + "LabelSelectCollection": "Select collection:", "HeaderDevices": "Devices", "ButtonScheduledTasks": "Scheduled tasks", + "MessageItemsAdded": "Items added", + "ButtonAddToCollection": "Add to collection", "HeaderSelectCertificatePath": "Select Certificate Path", "ConfirmMessageScheduledTaskButton": "This operation normally runs automatically as a scheduled task. It can also be run manually here. To configure the scheduled task, see:", "HeaderSupporterBenefit": "A supporter membership provides additional benefits such as access to premium plugins, internet channel content, and more. {0}Learn more{1}.", @@ -223,6 +229,7 @@ "ButtonRefresh": "Refresh", "LabelCurrentPath": "Current path:", "HeaderSelectMediaPath": "Select Media Path", + "HeaderSelectPath": "Select Path", "ButtonNetwork": "Network", "MessageDirectoryPickerInstruction": "Network paths can be entered manually in the event the Network button fails to locate your devices. For example, {0} or {1}.", "HeaderMenu": "Menu", diff --git a/MediaBrowser.Server.Implementations/Localization/Server/server.json b/MediaBrowser.Server.Implementations/Localization/Server/server.json index 3a5e7c77e7..576e0493e2 100644 --- a/MediaBrowser.Server.Implementations/Localization/Server/server.json +++ b/MediaBrowser.Server.Implementations/Localization/Server/server.json @@ -55,6 +55,8 @@ "HeaderAudio": "Audio", "HeaderVideo": "Video", "HeaderPaths": "Paths", + "LabelSyncTempPath": "Temporary file path:", + "LabelSyncTempPathHelp": "", "LabelCustomCertificatePath": "Custom certificate path:", "LabelCustomCertificatePathHelp": "Supply your own ssl certificate. If omitted, the server will create a self-signed certificate.", "TitleNotifications": "Notifications", @@ -516,10 +518,7 @@ "LabelPreferredDisplayLanguageHelp": "Translating Media Browser is an ongoing project and is not yet complete.", "LabelReadHowYouCanContribute": "Read about how you can contribute.", "HeaderNewCollection": "New Collection", - "HeaderAddToCollection": "Add to Collection", "ButtonSubmit": "Submit", - "NewCollectionNameExample": "Example: Star Wars Collection", - "OptionSearchForInternetMetadata": "Search the internet for artwork and metadata", "ButtonCreate": "Create", "LabelCustomCss": "Custom css:", "LabelCustomCssHelp": "Apply your own custom css to the web interface.", @@ -891,6 +890,8 @@ "OptionDefaultSort": "Default", "OptionCommunityMostWatchedSort": "Most Watched", "TabNextUp": "Next Up", + "HeaderBecomeMediaBrowserSupporter": "Become a Media Browser Supporter", + "TextAccessPremiumFeatures": "Enjoy Premium Features", "MessageNoMovieSuggestionsAvailable": "No movie suggestions are currently available. Start watching and rating your movies, and then come back to view your recommendations.", "MessageNoCollectionsAvailable": "Collections allow you to enjoy personalized groupings of Movies, Series, Albums, Books and Games. Click the + button to start creating Collections.", "MessageNoPlaylistsAvailable": "Playlists allow you to create lists of content to play consecutively at a time. To add items to playlists, right click or tap and hold, then select Add to Playlist.", @@ -907,7 +908,6 @@ "LabelChannelDownloadAge": "Delete content after: (days)", "LabelChannelDownloadAgeHelp": "Downloaded content older than this will be deleted. It will remain playable via internet streaming.", "ChannelSettingsFormHelp": "Install channels such as Trailers and Vimeo in the plugin catalog.", - "LabelSelectCollection": "Select collection:", "ButtonOptions": "Options", "ViewTypeMovies": "Movies", "ViewTypeTvShows": "TV", @@ -969,6 +969,7 @@ "LabelGroupChannelsIntoViews": "Display the following channels directly within my views:", "LabelGroupChannelsIntoViewsHelp": "If enabled, these channels will be displayed directly alongside other views. If disabled, they'll be displayed within a separate Channels view.", "LabelDisplayCollectionsView": "Display a collections view to show movie collections", + "LabelDisplayCollectionsViewHelp": "This will create a separate view to display collections that you've created or have access to. To create a collection, right-click or tap-hold any movie and select 'Add to Collection'. ", "LabelKodiMetadataEnableExtraThumbs": "Copy extrafanart into extrathumbs", "LabelKodiMetadataEnableExtraThumbsHelp": "When downloading images they can be saved into both extrafanart and extrathumbs for maximum Kodi skin compatibility.", "TabServices": "Services", diff --git a/MediaBrowser.Server.Implementations/Themes/AppThemeManager.cs b/MediaBrowser.Server.Implementations/Themes/AppThemeManager.cs index 9845f38674..2711c08aac 100644 --- a/MediaBrowser.Server.Implementations/Themes/AppThemeManager.cs +++ b/MediaBrowser.Server.Implementations/Themes/AppThemeManager.cs @@ -33,7 +33,7 @@ namespace MediaBrowser.Server.Implementations.Themes { get { - return Path.Combine(_appPaths.ItemsByNamePath, "appthemes"); + return Path.Combine(_appPaths.ProgramDataPath, "appthemes"); } } diff --git a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs index 4fc6ae6fa1..439d74ab90 100644 --- a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs +++ b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs @@ -419,7 +419,7 @@ namespace MediaBrowser.Server.Startup.Common LibraryMonitor = new LibraryMonitor(LogManager, TaskManager, LibraryManager, ServerConfigurationManager, FileSystemManager); RegisterSingleInstance(LibraryMonitor); - ProviderManager = new ProviderManager(HttpClient, ServerConfigurationManager, LibraryMonitor, LogManager, FileSystemManager); + ProviderManager = new ProviderManager(HttpClient, ServerConfigurationManager, LibraryMonitor, LogManager, FileSystemManager, ApplicationPaths); RegisterSingleInstance(ProviderManager); SeriesOrderManager = new SeriesOrderManager(); diff --git a/MediaBrowser.WebDashboard/Api/PackageCreator.cs b/MediaBrowser.WebDashboard/Api/PackageCreator.cs index 90a5b4ab64..340b02be75 100644 --- a/MediaBrowser.WebDashboard/Api/PackageCreator.cs +++ b/MediaBrowser.WebDashboard/Api/PackageCreator.cs @@ -565,7 +565,8 @@ namespace MediaBrowser.WebDashboard.Api "userimage.css", "livetv.css", "nowplaying.css", - "icons.css" + "icons.css", + "materialize.css" }; var builder = new StringBuilder(); diff --git a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj index 1f720eb26c..7613195ea3 100644 --- a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj +++ b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj @@ -96,6 +96,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest -- cgit v1.2.3 From ee00f8bf726ae5498d64cff0086b9b7e638936ea Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 24 Jan 2015 14:03:55 -0500 Subject: added HasSyncJob --- MediaBrowser.Api/BaseApiService.cs | 36 +++++++- MediaBrowser.Api/GamesService.cs | 4 +- MediaBrowser.Api/IHasDtoOptions.cs | 29 +------ MediaBrowser.Api/ItemLookupService.cs | 3 +- MediaBrowser.Api/Library/LibraryService.cs | 16 ++-- MediaBrowser.Api/Movies/CollectionService.cs | 2 +- MediaBrowser.Api/Movies/MoviesService.cs | 14 +-- MediaBrowser.Api/Movies/TrailersService.cs | 8 +- MediaBrowser.Api/Music/AlbumsService.cs | 4 +- MediaBrowser.Api/Music/InstantMixService.cs | 7 +- MediaBrowser.Api/PlaylistService.cs | 7 +- MediaBrowser.Api/SimilarItemsHelper.cs | 5 +- MediaBrowser.Api/Sync/SyncService.cs | 7 +- MediaBrowser.Api/TvShowsService.cs | 22 ++--- MediaBrowser.Api/UserLibrary/ArtistsService.cs | 2 +- .../UserLibrary/BaseItemsByNameService.cs | 2 +- MediaBrowser.Api/UserLibrary/GameGenresService.cs | 2 +- MediaBrowser.Api/UserLibrary/GenresService.cs | 2 +- MediaBrowser.Api/UserLibrary/ItemsService.cs | 6 +- MediaBrowser.Api/UserLibrary/MusicGenresService.cs | 2 +- MediaBrowser.Api/UserLibrary/PersonsService.cs | 2 +- MediaBrowser.Api/UserLibrary/StudiosService.cs | 2 +- MediaBrowser.Api/UserLibrary/UserLibraryService.cs | 16 ++-- MediaBrowser.Api/UserLibrary/YearsService.cs | 2 +- MediaBrowser.Api/VideosService.cs | 2 +- .../Networking/BaseNetworkManager.cs | 53 ++++++++++++ .../ScheduledTasks/ScheduledTaskWorker.cs | 6 ++ MediaBrowser.Common/Net/INetworkManager.cs | 1 - .../Collections/ICollectionManager.cs | 7 ++ MediaBrowser.Controller/Dto/DtoOptions.cs | 1 + MediaBrowser.Controller/Dto/IDtoService.cs | 11 +++ MediaBrowser.Controller/IServerApplicationHost.cs | 12 ++- MediaBrowser.Controller/Sync/ISyncManager.cs | 7 ++ MediaBrowser.Controller/Sync/ISyncRepository.cs | 7 ++ MediaBrowser.Dlna/Ssdp/DeviceDiscovery.cs | 2 +- .../Configuration/ServerConfiguration.cs | 2 + MediaBrowser.Model/Dto/BaseItemDto.cs | 3 +- MediaBrowser.Model/Tasks/TaskResult.cs | 6 ++ .../Channels/ChannelManager.cs | 8 +- .../Collections/CollectionManager.cs | 12 ++- .../Connect/ConnectManager.cs | 4 +- .../Dto/DtoService.cs | 99 ++++++++++++++++++++-- .../Library/LibraryManager.cs | 2 +- .../Library/UserManager.cs | 3 +- .../Library/UserViewManager.cs | 38 ++++++--- .../Localization/Server/server.json | 4 +- .../Sync/SyncManager.cs | 5 ++ .../Sync/SyncRepository.cs | 27 ++++-- .../Udp/UdpServer.cs | 14 ++- .../ApplicationHost.cs | 41 +++++---- MediaBrowser.sln | 5 ++ 51 files changed, 419 insertions(+), 165 deletions(-) (limited to 'MediaBrowser.Controller') diff --git a/MediaBrowser.Api/BaseApiService.cs b/MediaBrowser.Api/BaseApiService.cs index e909696553..2aaec8627a 100644 --- a/MediaBrowser.Api/BaseApiService.cs +++ b/MediaBrowser.Api/BaseApiService.cs @@ -1,8 +1,10 @@ -using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Dto; +using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.Audio; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Net; using MediaBrowser.Controller.Session; +using MediaBrowser.Model.Entities; using MediaBrowser.Model.Logging; using ServiceStack.Text.Controller; using ServiceStack.Web; @@ -36,6 +38,7 @@ namespace MediaBrowser.Api public IRequest Request { get; set; } public ISessionContext SessionContext { get; set; } + public IAuthorizationContext AuthorizationContext { get; set; } public string GetHeader(string name) { @@ -110,6 +113,37 @@ namespace MediaBrowser.Api private readonly char[] _dashReplaceChars = { '?', '/', '&' }; private const char SlugChar = '-'; + protected DtoOptions GetDtoOptions(object request) + { + var options = new DtoOptions(); + + options.DeviceId = AuthorizationContext.GetAuthorizationInfo(Request).DeviceId; + + var hasFields = request as IHasItemFields; + if (hasFields != null) + { + options.Fields = hasFields.GetItemFields().ToList(); + } + + var hasDtoOptions = request as IHasDtoOptions; + if (hasDtoOptions != null) + { + options.EnableImages = hasDtoOptions.EnableImages ?? true; + + if (hasDtoOptions.ImageTypeLimit.HasValue) + { + options.ImageTypeLimit = hasDtoOptions.ImageTypeLimit.Value; + } + + if (!string.IsNullOrWhiteSpace(hasDtoOptions.EnableImageTypes)) + { + options.ImageTypes = (hasDtoOptions.EnableImageTypes ?? string.Empty).Split(',').Where(i => !string.IsNullOrWhiteSpace(i)).Select(v => (ImageType)Enum.Parse(typeof(ImageType), v, true)).ToList(); + } + } + + return options; + } + protected MusicArtist GetArtist(string name, ILibraryManager libraryManager) { return libraryManager.GetArtist(DeSlugArtistName(name, libraryManager)); diff --git a/MediaBrowser.Api/GamesService.cs b/MediaBrowser.Api/GamesService.cs index 9aba2b0652..39e357f498 100644 --- a/MediaBrowser.Api/GamesService.cs +++ b/MediaBrowser.Api/GamesService.cs @@ -172,7 +172,9 @@ namespace MediaBrowser.Api /// System.Object. public object Get(GetSimilarGames request) { - var result = SimilarItemsHelper.GetSimilarItemsResult(_userManager, + var dtoOptions = GetDtoOptions(request); + + var result = SimilarItemsHelper.GetSimilarItemsResult(dtoOptions, _userManager, _itemRepo, _libraryManager, _userDataRepository, diff --git a/MediaBrowser.Api/IHasDtoOptions.cs b/MediaBrowser.Api/IHasDtoOptions.cs index 7fe47c4a1e..dac366113c 100644 --- a/MediaBrowser.Api/IHasDtoOptions.cs +++ b/MediaBrowser.Api/IHasDtoOptions.cs @@ -1,8 +1,4 @@ -using MediaBrowser.Controller.Dto; -using MediaBrowser.Model.Entities; -using System; -using System.Linq; - + namespace MediaBrowser.Api { public interface IHasDtoOptions : IHasItemFields @@ -13,27 +9,4 @@ namespace MediaBrowser.Api string EnableImageTypes { get; set; } } - - public static class HasDtoOptionsExtensions - { - public static DtoOptions GetDtoOptions(this IHasDtoOptions request) - { - var options = new DtoOptions(); - - options.Fields = request.GetItemFields().ToList(); - options.EnableImages = request.EnableImages ?? true; - - if (request.ImageTypeLimit.HasValue) - { - options.ImageTypeLimit = request.ImageTypeLimit.Value; - } - - if (!string.IsNullOrWhiteSpace(request.EnableImageTypes)) - { - options.ImageTypes = (request.EnableImageTypes ?? string.Empty).Split(',').Where(i => !string.IsNullOrWhiteSpace(i)).Select(v => (ImageType)Enum.Parse(typeof(ImageType), v, true)).ToList(); - } - - return options; - } - } } diff --git a/MediaBrowser.Api/ItemLookupService.cs b/MediaBrowser.Api/ItemLookupService.cs index 9a97022b67..d6b4da8bea 100644 --- a/MediaBrowser.Api/ItemLookupService.cs +++ b/MediaBrowser.Api/ItemLookupService.cs @@ -205,7 +205,8 @@ namespace MediaBrowser.Api Logger = Logger, Request = Request, ResultFactory = ResultFactory, - SessionContext = SessionContext + SessionContext = SessionContext, + AuthorizationContext = AuthorizationContext }; service.Post(new RefreshItem diff --git a/MediaBrowser.Api/Library/LibraryService.cs b/MediaBrowser.Api/Library/LibraryService.cs index 5e1619672f..bac6f6a397 100644 --- a/MediaBrowser.Api/Library/LibraryService.cs +++ b/MediaBrowser.Api/Library/LibraryService.cs @@ -272,7 +272,7 @@ namespace MediaBrowser.Api.Library items = items.Where(i => i.IsHidden == val).ToList(); } - var dtoOptions = new DtoOptions(); + var dtoOptions = GetDtoOptions(request); var result = new ItemsResult { @@ -344,7 +344,7 @@ namespace MediaBrowser.Api.Library var user = request.UserId.HasValue ? _userManager.GetUserById(request.UserId.Value) : null; - var dtoOptions = new DtoOptions(); + var dtoOptions = GetDtoOptions(request); BaseItem parent = item.Parent; @@ -544,7 +544,7 @@ namespace MediaBrowser.Api.Library ThemeSongsResult = themeSongs, ThemeVideosResult = themeVideos, - SoundtrackSongsResult = GetSoundtrackSongs(request.Id, request.UserId, request.InheritFromParent) + SoundtrackSongsResult = GetSoundtrackSongs(request, request.Id, request.UserId, request.InheritFromParent) }); } @@ -597,7 +597,7 @@ namespace MediaBrowser.Api.Library } } - var dtoOptions = new DtoOptions(); + var dtoOptions = GetDtoOptions(request); var dtos = themeSongIds.Select(_libraryManager.GetItemById) .OrderBy(i => i.SortName) @@ -667,7 +667,7 @@ namespace MediaBrowser.Api.Library } } - var dtoOptions = new DtoOptions(); + var dtoOptions = GetDtoOptions(request); var dtos = themeVideoIds.Select(_libraryManager.GetItemById) .OrderBy(i => i.SortName) @@ -732,17 +732,17 @@ namespace MediaBrowser.Api.Library return ToOptimizedSerializedResultUsingCache(lookup); } - public ThemeMediaResult GetSoundtrackSongs(string id, Guid? userId, bool inheritFromParent) + public ThemeMediaResult GetSoundtrackSongs(GetThemeMedia request, string id, Guid? userId, bool inheritFromParent) { var user = userId.HasValue ? _userManager.GetUserById(userId.Value) : null; var item = string.IsNullOrEmpty(id) ? (userId.HasValue ? user.RootFolder - : (Folder)_libraryManager.RootFolder) + : _libraryManager.RootFolder) : _libraryManager.GetItemById(id); - var dtoOptions = new DtoOptions(); + var dtoOptions = GetDtoOptions(request); var dtos = GetSoundtrackSongIds(item, inheritFromParent) .Select(_libraryManager.GetItemById) diff --git a/MediaBrowser.Api/Movies/CollectionService.cs b/MediaBrowser.Api/Movies/CollectionService.cs index 97c6cd87da..e6277e39a2 100644 --- a/MediaBrowser.Api/Movies/CollectionService.cs +++ b/MediaBrowser.Api/Movies/CollectionService.cs @@ -71,7 +71,7 @@ namespace MediaBrowser.Api.Movies }).ConfigureAwait(false); - var dtoOptions = new DtoOptions(); + var dtoOptions = GetDtoOptions(request); var dto = _dtoService.GetBaseItemDto(item, dtoOptions); diff --git a/MediaBrowser.Api/Movies/MoviesService.cs b/MediaBrowser.Api/Movies/MoviesService.cs index ba3c15a90b..0b8bb4036d 100644 --- a/MediaBrowser.Api/Movies/MoviesService.cs +++ b/MediaBrowser.Api/Movies/MoviesService.cs @@ -157,7 +157,7 @@ namespace MediaBrowser.Api.Movies .DistinctBy(i => i.GetProviderId(MetadataProviders.Imdb) ?? Guid.NewGuid().ToString(), StringComparer.OrdinalIgnoreCase) .ToList(); - var dtoOptions = new DtoOptions(); + var dtoOptions = GetDtoOptions(request); dtoOptions.Fields = request.GetItemFields().ToList(); @@ -174,8 +174,6 @@ namespace MediaBrowser.Api.Movies (request.UserId.HasValue ? user.RootFolder : _libraryManager.RootFolder) : _libraryManager.GetItemById(request.Id); - var fields = request.GetItemFields().ToList(); - var inputItems = user == null ? _libraryManager.RootFolder.GetRecursiveChildren().Where(i => i.Id != item.Id) : user.RootFolder.GetRecursiveChildren(user).Where(i => i.Id != item.Id); @@ -225,10 +223,12 @@ namespace MediaBrowser.Api.Movies { returnItems = returnItems.Take(request.Limit.Value); } + + var dtoOptions = GetDtoOptions(request); var result = new ItemsResult { - Items = returnItems.Select(i => _dtoService.GetBaseItemDto(i, fields, user)).ToArray(), + Items = _dtoService.GetBaseItemDtos(returnItems, dtoOptions, user).ToArray(), TotalRecordCount = items.Count }; @@ -351,7 +351,7 @@ namespace MediaBrowser.Api.Movies BaselineItemName = director, CategoryId = director.GetMD5().ToString("N"), RecommendationType = type, - Items = items.Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, user)).ToArray() + Items = _dtoService.GetBaseItemDtos(items, dtoOptions, user).ToArray() }; } } @@ -375,7 +375,7 @@ namespace MediaBrowser.Api.Movies BaselineItemName = name, CategoryId = name.GetMD5().ToString("N"), RecommendationType = type, - Items = items.Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, user)).ToArray() + Items = _dtoService.GetBaseItemDtos(items, dtoOptions, user).ToArray() }; } } @@ -399,7 +399,7 @@ namespace MediaBrowser.Api.Movies BaselineItemName = item.Name, CategoryId = item.Id.ToString("N"), RecommendationType = type, - Items = similar.Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, user)).ToArray() + Items = _dtoService.GetBaseItemDtos(similar, dtoOptions, user).ToArray() }; } } diff --git a/MediaBrowser.Api/Movies/TrailersService.cs b/MediaBrowser.Api/Movies/TrailersService.cs index 8e1704af73..3bee59a869 100644 --- a/MediaBrowser.Api/Movies/TrailersService.cs +++ b/MediaBrowser.Api/Movies/TrailersService.cs @@ -84,7 +84,9 @@ namespace MediaBrowser.Api.Movies /// System.Object. public object Get(GetSimilarTrailers request) { - var result = SimilarItemsHelper.GetSimilarItemsResult(_userManager, + var dtoOptions = GetDtoOptions(request); + + var result = SimilarItemsHelper.GetSimilarItemsResult(dtoOptions, _userManager, _itemRepo, _libraryManager, _userDataRepository, @@ -119,9 +121,9 @@ namespace MediaBrowser.Api.Movies var pagedItems = ApplyPaging(request, itemsArray); - var fields = request.GetItemFields().ToList(); + var dtoOptions = GetDtoOptions(request); - var returnItems = pagedItems.Select(i => _dtoService.GetBaseItemDto(i, fields, user)).ToArray(); + var returnItems = _dtoService.GetBaseItemDtos(pagedItems, dtoOptions, user).ToArray(); return new ItemsResult { diff --git a/MediaBrowser.Api/Music/AlbumsService.cs b/MediaBrowser.Api/Music/AlbumsService.cs index 34a933dee3..4cfb3c7d44 100644 --- a/MediaBrowser.Api/Music/AlbumsService.cs +++ b/MediaBrowser.Api/Music/AlbumsService.cs @@ -50,7 +50,9 @@ namespace MediaBrowser.Api.Music /// System.Object. public object Get(GetSimilarAlbums request) { - var result = SimilarItemsHelper.GetSimilarItemsResult(_userManager, + var dtoOptions = GetDtoOptions(request); + + var result = SimilarItemsHelper.GetSimilarItemsResult(dtoOptions, _userManager, _itemRepo, _libraryManager, _userDataRepository, diff --git a/MediaBrowser.Api/Music/InstantMixService.cs b/MediaBrowser.Api/Music/InstantMixService.cs index 43fd0894b9..cfb826a134 100644 --- a/MediaBrowser.Api/Music/InstantMixService.cs +++ b/MediaBrowser.Api/Music/InstantMixService.cs @@ -146,8 +146,6 @@ namespace MediaBrowser.Api.Music private object GetResult(IEnumerable /// System.String. - public override string GetUserDataKey() + protected override string CreateUserDataKey() { return GetUserDataKey(this); } diff --git a/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs b/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs index 928eb64630..ad2d39c794 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs @@ -14,7 +14,7 @@ namespace MediaBrowser.Controller.Entities.Audio /// Gets the user data key. /// /// System.String. - public override string GetUserDataKey() + protected override string CreateUserDataKey() { return "MusicGenre-" + Name; } diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index 2be4f99e9c..234a33d78f 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -359,7 +359,7 @@ namespace MediaBrowser.Controller.Entities { get { - if (!string.IsNullOrEmpty(ForcedSortName)) + if (!string.IsNullOrWhiteSpace(ForcedSortName)) { return ForcedSortName; } @@ -887,11 +887,22 @@ namespace MediaBrowser.Controller.Entities get { return null; } } + private string _userDataKey; /// /// Gets the user data key. /// /// System.String. - public virtual string GetUserDataKey() + public string GetUserDataKey() + { + if (!string.IsNullOrWhiteSpace(_userDataKey)) + { + return _userDataKey; + } + + return _userDataKey ?? (_userDataKey = CreateUserDataKey()); + } + + protected virtual string CreateUserDataKey() { return Id.ToString(); } @@ -1701,6 +1712,9 @@ namespace MediaBrowser.Controller.Entities /// public virtual bool BeforeMetadataRefresh() { + _userDataKey = null; + _sortName = null; + var hasChanges = false; if (string.IsNullOrEmpty(Name) && !string.IsNullOrEmpty(Path)) diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index ff6e8e85b1..dd3d145a03 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -807,7 +807,7 @@ namespace MediaBrowser.Controller.Entities protected QueryResult SortAndFilter(IEnumerable items, InternalItemsQuery query) { - return UserViewBuilder.SortAndFilter(items, this, null, query, LibraryManager, UserDataManager); + return UserViewBuilder.FilterAndSort(items, this, null, query, LibraryManager, UserDataManager); } /// diff --git a/MediaBrowser.Controller/Entities/Game.cs b/MediaBrowser.Controller/Entities/Game.cs index bf32d3e634..71642ea902 100644 --- a/MediaBrowser.Controller/Entities/Game.cs +++ b/MediaBrowser.Controller/Entities/Game.cs @@ -88,7 +88,7 @@ namespace MediaBrowser.Controller.Entities /// public List MultiPartGameFiles { get; set; } - public override string GetUserDataKey() + protected override string CreateUserDataKey() { var id = this.GetProviderId(MetadataProviders.Gamesdb); @@ -96,7 +96,7 @@ namespace MediaBrowser.Controller.Entities { return "Game-Gamesdb-" + id; } - return base.GetUserDataKey(); + return base.CreateUserDataKey(); } public override IEnumerable GetDeletePaths() diff --git a/MediaBrowser.Controller/Entities/GameGenre.cs b/MediaBrowser.Controller/Entities/GameGenre.cs index 8254689540..16ca6e70a0 100644 --- a/MediaBrowser.Controller/Entities/GameGenre.cs +++ b/MediaBrowser.Controller/Entities/GameGenre.cs @@ -10,7 +10,7 @@ namespace MediaBrowser.Controller.Entities /// Gets the user data key. /// /// System.String. - public override string GetUserDataKey() + protected override string CreateUserDataKey() { return "GameGenre-" + Name; } diff --git a/MediaBrowser.Controller/Entities/GameSystem.cs b/MediaBrowser.Controller/Entities/GameSystem.cs index 7584989779..cf69167638 100644 --- a/MediaBrowser.Controller/Entities/GameSystem.cs +++ b/MediaBrowser.Controller/Entities/GameSystem.cs @@ -35,13 +35,13 @@ namespace MediaBrowser.Controller.Entities /// Gets the user data key. /// /// System.String. - public override string GetUserDataKey() + protected override string CreateUserDataKey() { if (!string.IsNullOrEmpty(GameSystemName)) { return "GameSystem-" + GameSystemName; } - return base.GetUserDataKey(); + return base.CreateUserDataKey(); } protected override bool GetBlockUnratedValue(UserPolicy config) diff --git a/MediaBrowser.Controller/Entities/Genre.cs b/MediaBrowser.Controller/Entities/Genre.cs index 05442f2b7f..da5569afc9 100644 --- a/MediaBrowser.Controller/Entities/Genre.cs +++ b/MediaBrowser.Controller/Entities/Genre.cs @@ -14,7 +14,7 @@ namespace MediaBrowser.Controller.Entities /// Gets the user data key. /// /// System.String. - public override string GetUserDataKey() + protected override string CreateUserDataKey() { return "Genre-" + Name; } diff --git a/MediaBrowser.Controller/Entities/Movies/Movie.cs b/MediaBrowser.Controller/Entities/Movies/Movie.cs index 2fa5fc6e1e..cfe008bd7c 100644 --- a/MediaBrowser.Controller/Entities/Movies/Movie.cs +++ b/MediaBrowser.Controller/Entities/Movies/Movie.cs @@ -100,9 +100,9 @@ namespace MediaBrowser.Controller.Entities.Movies /// Gets the user data key. /// /// System.String. - public override string GetUserDataKey() + protected override string CreateUserDataKey() { - return this.GetProviderId(MetadataProviders.Tmdb) ?? this.GetProviderId(MetadataProviders.Imdb) ?? base.GetUserDataKey(); + return this.GetProviderId(MetadataProviders.Tmdb) ?? this.GetProviderId(MetadataProviders.Imdb) ?? base.CreateUserDataKey(); } protected override async Task RefreshedOwnedItems(MetadataRefreshOptions options, List fileSystemChildren, CancellationToken cancellationToken) diff --git a/MediaBrowser.Controller/Entities/MusicVideo.cs b/MediaBrowser.Controller/Entities/MusicVideo.cs index 4ca8cf1c5a..771c62fd6d 100644 --- a/MediaBrowser.Controller/Entities/MusicVideo.cs +++ b/MediaBrowser.Controller/Entities/MusicVideo.cs @@ -47,21 +47,6 @@ namespace MediaBrowser.Controller.Entities } } - /// - /// TODO: Remove - /// - public string Artist - { - get { return Artists.FirstOrDefault(); } - set - { - if (!string.IsNullOrEmpty(value) && !Artists.Contains(value, StringComparer.OrdinalIgnoreCase)) - { - Artists.Add(value); - } - } - } - /// /// Determines whether the specified name has artist. /// @@ -76,9 +61,9 @@ namespace MediaBrowser.Controller.Entities /// Gets the user data key. /// /// System.String. - public override string GetUserDataKey() + protected override string CreateUserDataKey() { - return this.GetProviderId(MetadataProviders.Tmdb) ?? this.GetProviderId(MetadataProviders.Imdb) ?? base.GetUserDataKey(); + return this.GetProviderId(MetadataProviders.Tmdb) ?? this.GetProviderId(MetadataProviders.Imdb) ?? base.CreateUserDataKey(); } protected override bool GetBlockUnratedValue(UserPolicy config) diff --git a/MediaBrowser.Controller/Entities/Person.cs b/MediaBrowser.Controller/Entities/Person.cs index fe8d618362..6d256e81c7 100644 --- a/MediaBrowser.Controller/Entities/Person.cs +++ b/MediaBrowser.Controller/Entities/Person.cs @@ -20,7 +20,7 @@ namespace MediaBrowser.Controller.Entities /// Gets the user data key. /// /// System.String. - public override string GetUserDataKey() + protected override string CreateUserDataKey() { return "Person-" + Name; } diff --git a/MediaBrowser.Controller/Entities/Studio.cs b/MediaBrowser.Controller/Entities/Studio.cs index 0d934ad0a5..58d46facc9 100644 --- a/MediaBrowser.Controller/Entities/Studio.cs +++ b/MediaBrowser.Controller/Entities/Studio.cs @@ -20,7 +20,7 @@ namespace MediaBrowser.Controller.Entities /// Gets the user data key. /// /// System.String. - public override string GetUserDataKey() + protected override string CreateUserDataKey() { return "Studio-" + Name; } diff --git a/MediaBrowser.Controller/Entities/TV/Episode.cs b/MediaBrowser.Controller/Entities/TV/Episode.cs index 6b67cebc88..a2731f6dfb 100644 --- a/MediaBrowser.Controller/Entities/TV/Episode.cs +++ b/MediaBrowser.Controller/Entities/TV/Episode.cs @@ -117,7 +117,7 @@ namespace MediaBrowser.Controller.Entities.TV /// Gets the user data key. /// /// System.String. - public override string GetUserDataKey() + protected override string CreateUserDataKey() { var series = Series; @@ -126,7 +126,7 @@ namespace MediaBrowser.Controller.Entities.TV return series.GetUserDataKey() + ParentIndexNumber.Value.ToString("000") + IndexNumber.Value.ToString("000"); } - return base.GetUserDataKey(); + return base.CreateUserDataKey(); } /// diff --git a/MediaBrowser.Controller/Entities/TV/Season.cs b/MediaBrowser.Controller/Entities/TV/Season.cs index 54db12b6f8..61d0aec607 100644 --- a/MediaBrowser.Controller/Entities/TV/Season.cs +++ b/MediaBrowser.Controller/Entities/TV/Season.cs @@ -92,7 +92,7 @@ namespace MediaBrowser.Controller.Entities.TV /// Gets the user data key. /// /// System.String. - public override string GetUserDataKey() + protected override string CreateUserDataKey() { if (Series != null) { @@ -100,7 +100,7 @@ namespace MediaBrowser.Controller.Entities.TV return Series.GetUserDataKey() + seasonNo.ToString("000"); } - return base.GetUserDataKey(); + return base.CreateUserDataKey(); } /// diff --git a/MediaBrowser.Controller/Entities/TV/Series.cs b/MediaBrowser.Controller/Entities/TV/Series.cs index 55cfffeb26..0ec9121f37 100644 --- a/MediaBrowser.Controller/Entities/TV/Series.cs +++ b/MediaBrowser.Controller/Entities/TV/Series.cs @@ -117,9 +117,9 @@ namespace MediaBrowser.Controller.Entities.TV /// Gets the user data key. /// /// System.String. - public override string GetUserDataKey() + protected override string CreateUserDataKey() { - return this.GetProviderId(MetadataProviders.Tvdb) ?? this.GetProviderId(MetadataProviders.Tvcom) ?? base.GetUserDataKey(); + return this.GetProviderId(MetadataProviders.Tvdb) ?? this.GetProviderId(MetadataProviders.Tvcom) ?? base.CreateUserDataKey(); } /// diff --git a/MediaBrowser.Controller/Entities/Trailer.cs b/MediaBrowser.Controller/Entities/Trailer.cs index 7a1eef8dbb..72e3640f27 100644 --- a/MediaBrowser.Controller/Entities/Trailer.cs +++ b/MediaBrowser.Controller/Entities/Trailer.cs @@ -79,7 +79,7 @@ namespace MediaBrowser.Controller.Entities } } - public override string GetUserDataKey() + protected override string CreateUserDataKey() { var key = this.GetProviderId(MetadataProviders.Imdb) ?? this.GetProviderId(MetadataProviders.Tmdb); @@ -96,7 +96,7 @@ namespace MediaBrowser.Controller.Entities return key; } - return base.GetUserDataKey(); + return base.CreateUserDataKey(); } protected override bool GetBlockUnratedValue(UserPolicy config) diff --git a/MediaBrowser.Controller/Entities/UserViewBuilder.cs b/MediaBrowser.Controller/Entities/UserViewBuilder.cs index deb85ed6a0..ac8be37d44 100644 --- a/MediaBrowser.Controller/Entities/UserViewBuilder.cs +++ b/MediaBrowser.Controller/Entities/UserViewBuilder.cs @@ -18,6 +18,7 @@ using System.IO; using System.Linq; using System.Threading; using System.Threading.Tasks; +using MoreLinq; namespace MediaBrowser.Controller.Entities { @@ -412,7 +413,19 @@ namespace MediaBrowser.Controller.Entities { if (query.Recursive) { - return GetResult(GetRecursiveChildren(parent, user, new[] { CollectionType.Movies, CollectionType.BoxSets, string.Empty }).Where(i => i is Movie || i is BoxSet), parent, query); + var recursiveItems = GetRecursiveChildren(parent, user, + new[] {CollectionType.Movies, CollectionType.BoxSets, string.Empty}) + .Where(i => i is Movie || i is BoxSet); + + //var collections = _collectionManager.CollapseItemsWithinBoxSets(recursiveItems, user).ToList(); + + //if (collections.Count > 0) + //{ + // recursiveItems.AddRange(_collectionManager.CollapseItemsWithinBoxSets(recursiveItems, user)); + // recursiveItems = recursiveItems.DistinctBy(i => i.Id).ToList(); + //} + + return GetResult(recursiveItems, parent, query); } var list = new List(); @@ -744,10 +757,10 @@ namespace MediaBrowser.Controller.Entities InternalItemsQuery query) where T : BaseItem { - return SortAndFilter(items, queryParent, totalRecordLimit, query, _libraryManager, _userDataManager); + return FilterAndSort(items, queryParent, totalRecordLimit, query, _libraryManager, _userDataManager); } - public static QueryResult SortAndFilter(IEnumerable items, + public static QueryResult FilterAndSort(IEnumerable items, BaseItem queryParent, int? totalRecordLimit, InternalItemsQuery query, diff --git a/MediaBrowser.Controller/Entities/Year.cs b/MediaBrowser.Controller/Entities/Year.cs index 8deb930e8b..11b0ce3d28 100644 --- a/MediaBrowser.Controller/Entities/Year.cs +++ b/MediaBrowser.Controller/Entities/Year.cs @@ -13,7 +13,7 @@ namespace MediaBrowser.Controller.Entities /// Gets the user data key. /// /// System.String. - public override string GetUserDataKey() + protected override string CreateUserDataKey() { return "Year-" + Name; } diff --git a/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs b/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs index f29204689f..5cfdb5dbf5 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs +++ b/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs @@ -12,7 +12,7 @@ namespace MediaBrowser.Controller.LiveTv /// Gets the user data key. /// /// System.String. - public override string GetUserDataKey() + protected override string CreateUserDataKey() { var name = GetClientTypeName(); diff --git a/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs b/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs index b4b9fa77b8..72b4970262 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs +++ b/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs @@ -16,7 +16,7 @@ namespace MediaBrowser.Controller.LiveTv /// Gets the user data key. /// /// System.String. - public override string GetUserDataKey() + protected override string CreateUserDataKey() { return GetClientTypeName() + "-" + Name; } diff --git a/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs b/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs index 74cf950d42..6308a71dc3 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs +++ b/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs @@ -16,7 +16,7 @@ namespace MediaBrowser.Controller.LiveTv /// Gets the user data key. /// /// System.String. - public override string GetUserDataKey() + protected override string CreateUserDataKey() { return GetClientTypeName() + "-" + Name; } diff --git a/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs b/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs index 91edc06c11..098400b502 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs +++ b/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs @@ -12,7 +12,7 @@ namespace MediaBrowser.Controller.LiveTv /// Gets the user data key. /// /// System.String. - public override string GetUserDataKey() + protected override string CreateUserDataKey() { var name = GetClientTypeName(); diff --git a/MediaBrowser.Providers/Manager/MetadataService.cs b/MediaBrowser.Providers/Manager/MetadataService.cs index f55eddfcf1..fc329d64c5 100644 --- a/MediaBrowser.Providers/Manager/MetadataService.cs +++ b/MediaBrowser.Providers/Manager/MetadataService.cs @@ -437,8 +437,7 @@ namespace MediaBrowser.Providers.Manager localProviders.Count == 0 && refreshResult.UpdateType > ItemUpdateType.None) { - // TODO: If the new metadata from above has some blank data, this - // can cause old data to get filled into those empty fields + // TODO: If the new metadata from above has some blank data, this can cause old data to get filled into those empty fields MergeData(item, temp, new List(), false, true); } diff --git a/MediaBrowser.Server.Implementations/Collections/ManualCollectionsFolder.cs b/MediaBrowser.Server.Implementations/Collections/ManualCollectionsFolder.cs index fa4de728b9..bbe37cb506 100644 --- a/MediaBrowser.Server.Implementations/Collections/ManualCollectionsFolder.cs +++ b/MediaBrowser.Server.Implementations/Collections/ManualCollectionsFolder.cs @@ -1,4 +1,5 @@ using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Entities.Movies; using System.Linq; namespace MediaBrowser.Server.Implementations.Collections @@ -14,7 +15,8 @@ namespace MediaBrowser.Server.Implementations.Collections public override bool IsVisible(User user) { return base.IsVisible(user) && GetChildren(user, false) - .Any(); + .OfType() + .Any(i => i.IsVisible(user)); } public override bool IsHidden diff --git a/MediaBrowser.Server.Implementations/FileOrganization/NameUtils.cs b/MediaBrowser.Server.Implementations/FileOrganization/NameUtils.cs index 795be1e2f3..624133d4fb 100644 --- a/MediaBrowser.Server.Implementations/FileOrganization/NameUtils.cs +++ b/MediaBrowser.Server.Implementations/FileOrganization/NameUtils.cs @@ -54,9 +54,6 @@ namespace MediaBrowser.Server.Implementations.FileOrganization private static string GetComparableName(string name) { - // TODO: Improve this - should ignore spaces, periods, underscores, most likely all symbols and - // possibly remove sorting words like "the", "and", etc. - name = RemoveDiacritics(name); name = " " + name + " "; diff --git a/MediaBrowser.Server.Implementations/Library/UserViewManager.cs b/MediaBrowser.Server.Implementations/Library/UserViewManager.cs index bd0f44adc2..d8c5f85c02 100644 --- a/MediaBrowser.Server.Implementations/Library/UserViewManager.cs +++ b/MediaBrowser.Server.Implementations/Library/UserViewManager.cs @@ -88,24 +88,10 @@ namespace MediaBrowser.Server.Implementations.Library list.Add(await GetUserView(CollectionType.Games, string.Empty, cancellationToken).ConfigureAwait(false)); } - if (user.Configuration.DisplayCollectionsView) + if (foldersWithViewTypes.Any(i => string.Equals(i.CollectionType, CollectionType.BoxSets, StringComparison.OrdinalIgnoreCase))) { - bool showCollectionView; - if (_config.Configuration.EnableLegacyCollections) - { - showCollectionView = folders - .Except(standaloneFolders) - .SelectMany(i => i.GetRecursiveChildren(user, false)).OfType().Any(); - } - else - { - showCollectionView = _collectionManager.GetCollections(user).Any(); - } - - if (showCollectionView) - { - list.Add(await GetUserView(CollectionType.BoxSets, string.Empty, cancellationToken).ConfigureAwait(false)); - } + //list.Add(_collectionManager.GetCollectionsFolder(user.Id.ToString("N"))); + list.Add(await GetUserView(CollectionType.BoxSets, string.Empty, cancellationToken).ConfigureAwait(false)); } if (foldersWithViewTypes.Any(i => string.Equals(i.CollectionType, CollectionType.Playlists, StringComparison.OrdinalIgnoreCase))) diff --git a/MediaBrowser.Server.Implementations/Localization/Server/server.json b/MediaBrowser.Server.Implementations/Localization/Server/server.json index 34a0b327d3..15bc624123 100644 --- a/MediaBrowser.Server.Implementations/Localization/Server/server.json +++ b/MediaBrowser.Server.Implementations/Localization/Server/server.json @@ -55,6 +55,8 @@ "HeaderAudio": "Audio", "HeaderVideo": "Video", "HeaderPaths": "Paths", + "HeaderSyncRequiresSupporterMembership": "Sync Requires a Supporter Membership", + "HeaderEnjoyDayTrial": "Enjoy a 14 Day Free Trial", "LabelSyncTempPath": "Temporary file path:", "LabelSyncTempPathHelp": "Specify a custom sync working folder. Converted media created during the sync process will be stored here.", "LabelCustomCertificatePath": "Custom certificate path:", diff --git a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj index e95bd6503b..30384d1ffc 100644 --- a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj +++ b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj @@ -306,6 +306,7 @@ + diff --git a/MediaBrowser.Server.Implementations/Sync/SyncJobProcessor.cs b/MediaBrowser.Server.Implementations/Sync/SyncJobProcessor.cs index 716584084c..b926ee3388 100644 --- a/MediaBrowser.Server.Implementations/Sync/SyncJobProcessor.cs +++ b/MediaBrowser.Server.Implementations/Sync/SyncJobProcessor.cs @@ -90,7 +90,7 @@ namespace MediaBrowser.Server.Implementations.Sync continue; } - var index = jobItems.Count == 0 ? + var index = jobItems.Count == 0 ? 0 : (jobItems.Select(i => i.JobItemIndex).Max() + 1); @@ -348,10 +348,20 @@ namespace MediaBrowser.Server.Implementations.Sync private void CleanDeadSyncFiles() { // TODO + // Clean files in sync temp folder that are not linked to any sync jobs } public async Task SyncJobItems(SyncJobItem[] items, bool enableConversion, IProgress progress, CancellationToken cancellationToken) { + if (items.Length > 0) + { + if (!SyncRegistrationInfo.Instance.IsRegistered) + { + _logger.Debug("Cancelling sync job processing. Please obtain a supporter membership."); + return; + } + } + var numComplete = 0; foreach (var item in items) diff --git a/MediaBrowser.Server.Implementations/Sync/SyncRegistrationInfo.cs b/MediaBrowser.Server.Implementations/Sync/SyncRegistrationInfo.cs new file mode 100644 index 0000000000..40b84b1c21 --- /dev/null +++ b/MediaBrowser.Server.Implementations/Sync/SyncRegistrationInfo.cs @@ -0,0 +1,31 @@ +using MediaBrowser.Common.Security; +using System.Threading.Tasks; + +namespace MediaBrowser.Server.Implementations.Sync +{ + public class SyncRegistrationInfo : IRequiresRegistration + { + private readonly ISecurityManager _securityManager; + + public static SyncRegistrationInfo Instance; + + public SyncRegistrationInfo(ISecurityManager securityManager) + { + _securityManager = securityManager; + Instance = this; + } + + private bool _registered; + public bool IsRegistered + { + get { return _registered; } + } + + public async Task LoadRegistrationInfoAsync() + { + var info = await _securityManager.GetRegistrationStatus("sync").ConfigureAwait(false); + + _registered = info.IsValid; + } + } +} diff --git a/Nuget/MediaBrowser.Common.Internal.nuspec b/Nuget/MediaBrowser.Common.Internal.nuspec index 6de8801790..1a7dc626a3 100644 --- a/Nuget/MediaBrowser.Common.Internal.nuspec +++ b/Nuget/MediaBrowser.Common.Internal.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common.Internal - 3.0.545 + 3.0.546 MediaBrowser.Common.Internal Luke ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains common components shared by Media Browser Theater and Media Browser Server. Not intended for plugin developer consumption. Copyright © Media Browser 2013 - + diff --git a/Nuget/MediaBrowser.Common.nuspec b/Nuget/MediaBrowser.Common.nuspec index 94445107e6..3eb6621b31 100644 --- a/Nuget/MediaBrowser.Common.nuspec +++ b/Nuget/MediaBrowser.Common.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common - 3.0.545 + 3.0.546 MediaBrowser.Common Media Browser Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Model.Signed.nuspec b/Nuget/MediaBrowser.Model.Signed.nuspec index c441d3b636..f73b375a2f 100644 --- a/Nuget/MediaBrowser.Model.Signed.nuspec +++ b/Nuget/MediaBrowser.Model.Signed.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Model.Signed - 3.0.545 + 3.0.546 MediaBrowser.Model - Signed Edition Media Browser Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Server.Core.nuspec b/Nuget/MediaBrowser.Server.Core.nuspec index 5409d970d5..451a376540 100644 --- a/Nuget/MediaBrowser.Server.Core.nuspec +++ b/Nuget/MediaBrowser.Server.Core.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Server.Core - 3.0.545 + 3.0.546 Media Browser.Server.Core Media Browser Team ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains core components required to build plugins for Media Browser Server. Copyright © Media Browser 2013 - + -- cgit v1.2.3 From a1a56557ece84d8b726a6c06b2620fa43ff22461 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 25 Jan 2015 01:34:50 -0500 Subject: sync updates --- MediaBrowser.Api/BaseApiService.cs | 34 +++++--- MediaBrowser.Api/GamesService.cs | 15 ++-- MediaBrowser.Api/ItemRefreshService.cs | 2 +- MediaBrowser.Api/ItemUpdateService.cs | 2 +- MediaBrowser.Api/Library/LibraryService.cs | 81 +++++++++---------- MediaBrowser.Api/Movies/MoviesService.cs | 11 ++- MediaBrowser.Api/Music/AlbumsService.cs | 8 +- MediaBrowser.Api/SearchService.cs | 8 +- MediaBrowser.Api/SimilarItemsHelper.cs | 10 +-- MediaBrowser.Api/TvShowsService.cs | 19 ++--- .../UserLibrary/BaseItemsByNameService.cs | 66 +++++++++------- MediaBrowser.Api/UserLibrary/ItemsService.cs | 4 +- MediaBrowser.Api/UserLibrary/UserLibraryService.cs | 63 ++++++++------- .../Entities/Audio/MusicAlbum.cs | 5 +- .../Entities/Audio/MusicArtist.cs | 25 ++++-- .../Entities/Audio/MusicGenre.cs | 8 +- MediaBrowser.Controller/Entities/BaseItem.cs | 5 +- MediaBrowser.Controller/Entities/Folder.cs | 91 +++++++++++++--------- MediaBrowser.Controller/Entities/GameGenre.cs | 8 +- MediaBrowser.Controller/Entities/Genre.cs | 7 +- MediaBrowser.Controller/Entities/IItemByName.cs | 5 +- .../Entities/InternalItemsQuery.cs | 2 +- MediaBrowser.Controller/Entities/Movies/BoxSet.cs | 14 +--- MediaBrowser.Controller/Entities/Person.cs | 8 +- MediaBrowser.Controller/Entities/Studio.cs | 8 +- MediaBrowser.Controller/Entities/TV/Season.cs | 6 +- MediaBrowser.Controller/Entities/TV/Series.cs | 16 +--- MediaBrowser.Controller/Entities/UserRootFolder.cs | 9 ++- MediaBrowser.Controller/Entities/UserView.cs | 5 +- .../Entities/UserViewBuilder.cs | 72 +++++++++++------ MediaBrowser.Controller/Entities/Year.cs | 9 ++- MediaBrowser.Controller/Playlists/Playlist.cs | 60 +++++++------- .../ContentDirectory/ControlHandler.cs | 6 +- .../MediaInfo/SubtitleScheduledTask.cs | 10 ++- .../Movies/MovieUpdatesPrescanTask.cs | 5 +- .../Music/AlbumImageFromSongProvider.cs | 3 +- .../Music/AlbumMetadataService.cs | 4 +- .../Music/ArtistMetadataService.cs | 4 +- .../People/TvdbPersonImageProvider.cs | 8 +- MediaBrowser.Providers/TV/DummySeasonProvider.cs | 4 +- .../TV/MissingEpisodeProvider.cs | 31 ++++---- MediaBrowser.Providers/TV/SeriesPostScanTask.cs | 8 +- MediaBrowser.Providers/TV/TvdbPrescanTask.cs | 12 +-- .../Dto/DtoService.cs | 38 +++++---- .../EntryPoints/LibraryChangedNotifier.cs | 3 +- .../FileOrganization/EpisodeFileOrganizer.cs | 11 ++- .../Intros/DefaultIntroProvider.cs | 40 +++++----- .../Library/LibraryManager.cs | 13 ++-- .../Library/LocalTrailerPostScanTask.cs | 7 +- .../Library/MusicManager.cs | 17 ++-- .../Library/SearchEngine.cs | 9 +-- .../Library/Validators/ArtistsValidator.cs | 7 +- .../Library/Validators/GameGenresValidator.cs | 2 +- .../Library/Validators/GenresValidator.cs | 2 +- .../Library/Validators/MusicGenresValidator.cs | 2 +- .../Library/Validators/StudiosValidator.cs | 2 +- .../Library/Validators/YearsPostScanTask.cs | 2 +- .../Photos/PhotoAlbumImageProvider.cs | 2 +- .../Playlists/ManualPlaylistsFolder.cs | 3 +- .../Playlists/PlaylistManager.cs | 3 +- .../ScheduledTasks/ChapterImagesTask.cs | 4 +- .../Session/SessionManager.cs | 7 +- .../Sync/SyncJobProcessor.cs | 10 +-- .../TV/TVSeriesManager.cs | 16 ++-- .../FFMpeg/FFMpegDownloadInfo.cs | 12 +-- MediaBrowser.XbmcMetadata/EntryPoint.cs | 3 +- MediaBrowser.XbmcMetadata/Savers/ArtistNfoSaver.cs | 4 +- 67 files changed, 568 insertions(+), 432 deletions(-) (limited to 'MediaBrowser.Controller') diff --git a/MediaBrowser.Api/BaseApiService.cs b/MediaBrowser.Api/BaseApiService.cs index 2aaec8627a..dff433c9dc 100644 --- a/MediaBrowser.Api/BaseApiService.cs +++ b/MediaBrowser.Api/BaseApiService.cs @@ -174,7 +174,7 @@ namespace MediaBrowser.Api return libraryManager.GetPerson(DeSlugPersonName(name, libraryManager)); } - protected IEnumerable GetAllLibraryItems(Guid? userId, IUserManager userManager, ILibraryManager libraryManager, string parentId = null) + protected IList GetAllLibraryItems(Guid? userId, IUserManager userManager, ILibraryManager libraryManager, string parentId, Func filter) { if (!string.IsNullOrEmpty(parentId)) { @@ -189,10 +189,13 @@ namespace MediaBrowser.Api throw new ArgumentException("User not found"); } - return folder.GetRecursiveChildren(user); + return folder + .GetRecursiveChildren(user, filter) + .ToList(); } - return folder.GetRecursiveChildren(); + return folder + .GetRecursiveChildren(filter); } if (userId.HasValue) { @@ -203,10 +206,16 @@ namespace MediaBrowser.Api throw new ArgumentException("User not found"); } - return userManager.GetUserById(userId.Value).RootFolder.GetRecursiveChildren(user); + return userManager + .GetUserById(userId.Value) + .RootFolder + .GetRecursiveChildren(user, filter) + .ToList(); } - return libraryManager.RootFolder.GetRecursiveChildren(); + return libraryManager + .RootFolder + .GetRecursiveChildren(filter); } /// @@ -222,8 +231,9 @@ namespace MediaBrowser.Api return name; } - return libraryManager.RootFolder.RecursiveChildren - .OfType