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/Entities/BaseItem.cs | 11 +++++++++-- MediaBrowser.Controller/Entities/User.cs | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) (limited to 'MediaBrowser.Controller/Entities') 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)) -- 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/Entities') 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/Entities') 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/Entities') 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 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/Entities') 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/Entities') 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 67559378009062a26173888ad457d0c9116bfc9a Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 24 Jan 2015 17:33:26 -0500 Subject: sync updates --- .../Channels/ChannelAudioItem.cs | 2 +- .../Channels/ChannelFolderItem.cs | 2 +- .../Channels/ChannelVideoItem.cs | 4 +-- MediaBrowser.Controller/Entities/Audio/Audio.cs | 4 +-- .../Entities/Audio/MusicAlbum.cs | 4 +-- .../Entities/Audio/MusicArtist.cs | 2 +- .../Entities/Audio/MusicGenre.cs | 2 +- MediaBrowser.Controller/Entities/BaseItem.cs | 18 +++++++++++-- MediaBrowser.Controller/Entities/Folder.cs | 2 +- MediaBrowser.Controller/Entities/Game.cs | 4 +-- MediaBrowser.Controller/Entities/GameGenre.cs | 2 +- MediaBrowser.Controller/Entities/GameSystem.cs | 4 +-- MediaBrowser.Controller/Entities/Genre.cs | 2 +- MediaBrowser.Controller/Entities/Movies/Movie.cs | 4 +-- MediaBrowser.Controller/Entities/MusicVideo.cs | 19 ++----------- MediaBrowser.Controller/Entities/Person.cs | 2 +- MediaBrowser.Controller/Entities/Studio.cs | 2 +- MediaBrowser.Controller/Entities/TV/Episode.cs | 4 +-- MediaBrowser.Controller/Entities/TV/Season.cs | 4 +-- MediaBrowser.Controller/Entities/TV/Series.cs | 4 +-- MediaBrowser.Controller/Entities/Trailer.cs | 4 +-- .../Entities/UserViewBuilder.cs | 19 ++++++++++--- MediaBrowser.Controller/Entities/Year.cs | 2 +- .../LiveTv/LiveTvAudioRecording.cs | 2 +- MediaBrowser.Controller/LiveTv/LiveTvChannel.cs | 2 +- MediaBrowser.Controller/LiveTv/LiveTvProgram.cs | 2 +- .../LiveTv/LiveTvVideoRecording.cs | 2 +- MediaBrowser.Providers/Manager/MetadataService.cs | 3 +-- .../Collections/ManualCollectionsFolder.cs | 4 ++- .../FileOrganization/NameUtils.cs | 3 --- .../Library/UserViewManager.cs | 20 +++----------- .../Localization/Server/server.json | 2 ++ .../MediaBrowser.Server.Implementations.csproj | 1 + .../Sync/SyncJobProcessor.cs | 12 ++++++++- .../Sync/SyncRegistrationInfo.cs | 31 ++++++++++++++++++++++ Nuget/MediaBrowser.Common.Internal.nuspec | 4 +-- Nuget/MediaBrowser.Common.nuspec | 2 +- Nuget/MediaBrowser.Model.Signed.nuspec | 2 +- Nuget/MediaBrowser.Server.Core.nuspec | 4 +-- 39 files changed, 126 insertions(+), 86 deletions(-) create mode 100644 MediaBrowser.Server.Implementations/Sync/SyncRegistrationInfo.cs (limited to 'MediaBrowser.Controller/Entities') diff --git a/MediaBrowser.Controller/Channels/ChannelAudioItem.cs b/MediaBrowser.Controller/Channels/ChannelAudioItem.cs index 896d598bb0..d9330f8a30 100644 --- a/MediaBrowser.Controller/Channels/ChannelAudioItem.cs +++ b/MediaBrowser.Controller/Channels/ChannelAudioItem.cs @@ -32,7 +32,7 @@ namespace MediaBrowser.Controller.Channels return config.BlockUnratedItems.Contains(UnratedItem.ChannelContent); } - public override string GetUserDataKey() + protected override string CreateUserDataKey() { return ExternalId; } diff --git a/MediaBrowser.Controller/Channels/ChannelFolderItem.cs b/MediaBrowser.Controller/Channels/ChannelFolderItem.cs index 8482e38dff..dce9840eda 100644 --- a/MediaBrowser.Controller/Channels/ChannelFolderItem.cs +++ b/MediaBrowser.Controller/Channels/ChannelFolderItem.cs @@ -40,7 +40,7 @@ namespace MediaBrowser.Controller.Channels return false; } - public override string GetUserDataKey() + protected override string CreateUserDataKey() { return ExternalId; } diff --git a/MediaBrowser.Controller/Channels/ChannelVideoItem.cs b/MediaBrowser.Controller/Channels/ChannelVideoItem.cs index f0eafcbdff..e3fad56e90 100644 --- a/MediaBrowser.Controller/Channels/ChannelVideoItem.cs +++ b/MediaBrowser.Controller/Channels/ChannelVideoItem.cs @@ -28,8 +28,8 @@ namespace MediaBrowser.Controller.Channels public string OriginalImageUrl { get; set; } public List ChannelMediaSources { get; set; } - - public override string GetUserDataKey() + + protected override string CreateUserDataKey() { if (ContentType == ChannelMediaContentType.MovieExtra) { diff --git a/MediaBrowser.Controller/Entities/Audio/Audio.cs b/MediaBrowser.Controller/Entities/Audio/Audio.cs index c5ed09016c..f110f85d2e 100644 --- a/MediaBrowser.Controller/Entities/Audio/Audio.cs +++ b/MediaBrowser.Controller/Entities/Audio/Audio.cs @@ -169,7 +169,7 @@ namespace MediaBrowser.Controller.Entities.Audio /// Gets the user data key. /// /// System.String. - public override string GetUserDataKey() + protected override string CreateUserDataKey() { var parent = FindParent(); @@ -186,7 +186,7 @@ namespace MediaBrowser.Controller.Entities.Audio } } - return base.GetUserDataKey(); + return base.CreateUserDataKey(); } protected override bool GetBlockUnratedValue(UserPolicy config) diff --git a/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs b/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs index 90edfcce70..7974657d9d 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs @@ -136,7 +136,7 @@ namespace MediaBrowser.Controller.Entities.Audio /// Gets the user data key. /// /// System.String. - public override string GetUserDataKey() + protected override string CreateUserDataKey() { var id = this.GetProviderId(MetadataProviders.MusicBrainzReleaseGroup); @@ -152,7 +152,7 @@ namespace MediaBrowser.Controller.Entities.Audio return "MusicAlbum-Musicbrainz-" + id; } - return base.GetUserDataKey(); + return base.CreateUserDataKey(); } protected override bool GetBlockUnratedValue(UserPolicy config) diff --git a/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs b/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs index a60258d1a7..45476d6a6d 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs @@ -68,7 +68,7 @@ namespace MediaBrowser.Controller.Entities.Audio /// Gets the user data key. /// /// 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/Entities') 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