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.Server.Implementations/Collections/CollectionManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'MediaBrowser.Server.Implementations/Collections') diff --git a/MediaBrowser.Server.Implementations/Collections/CollectionManager.cs b/MediaBrowser.Server.Implementations/Collections/CollectionManager.cs index 9fee27db9b..05efcaa1c9 100644 --- a/MediaBrowser.Server.Implementations/Collections/CollectionManager.cs +++ b/MediaBrowser.Server.Implementations/Collections/CollectionManager.cs @@ -258,7 +258,7 @@ namespace MediaBrowser.Server.Implementations.Collections { foreach (var file in shortcutFilesToDelete) { - File.Delete(file); + _fileSystem.DeleteFile(file); } foreach (var child in list) -- 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.Server.Implementations/Collections') 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 449485d3d2044185f16af3e7dc185ff86a0ed72b Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 20 Jan 2015 15:19:54 -0500 Subject: add organize now/sync prepare buttons --- MediaBrowser.Providers/TV/DummySeasonProvider.cs | 1 - MediaBrowser.Providers/TV/MissingEpisodeProvider.cs | 1 - .../Channels/ChannelManager.cs | 2 -- .../Collections/CollectionManager.cs | 1 - .../Devices/CameraUploadsFolder.cs | 1 - .../FileOrganization/OrganizerScheduledTask.cs | 7 ++++++- .../Library/ResolverHelper.cs | 12 ------------ MediaBrowser.Server.Implementations/Library/UserManager.cs | 7 +++++++ .../Localization/Server/server.json | 2 ++ .../Sync/SyncScheduledTask.cs | 11 ++++++++--- 10 files changed, 23 insertions(+), 22 deletions(-) (limited to 'MediaBrowser.Server.Implementations/Collections') diff --git a/MediaBrowser.Providers/TV/DummySeasonProvider.cs b/MediaBrowser.Providers/TV/DummySeasonProvider.cs index 5bf40de0f1..f82439de98 100644 --- a/MediaBrowser.Providers/TV/DummySeasonProvider.cs +++ b/MediaBrowser.Providers/TV/DummySeasonProvider.cs @@ -112,7 +112,6 @@ namespace MediaBrowser.Providers.TV Name = seasonName, IndexNumber = seasonNumber, Parent = series, - DisplayMediaType = typeof(Season).Name, Id = (series.Id + (seasonNumber ?? -1).ToString(_usCulture) + seasonName).GetMBId(typeof(Season)) }; diff --git a/MediaBrowser.Providers/TV/MissingEpisodeProvider.cs b/MediaBrowser.Providers/TV/MissingEpisodeProvider.cs index 53b60c1b8b..8b46b082b9 100644 --- a/MediaBrowser.Providers/TV/MissingEpisodeProvider.cs +++ b/MediaBrowser.Providers/TV/MissingEpisodeProvider.cs @@ -406,7 +406,6 @@ namespace MediaBrowser.Providers.TV IndexNumber = episodeNumber, ParentIndexNumber = seasonNumber, Parent = season, - DisplayMediaType = typeof(Episode).Name, Id = (series.Id + seasonNumber.ToString(_usCulture) + name).GetMBId(typeof(Episode)) }; diff --git a/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs b/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs index 3e50375536..a7e248ea46 100644 --- a/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs +++ b/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs @@ -1263,8 +1263,6 @@ namespace MediaBrowser.Server.Implementations.Channels var mediaSource = info.MediaSources.FirstOrDefault(); item.Path = mediaSource == null ? null : mediaSource.Path; - - item.DisplayMediaType = channelMediaItem.ContentType.ToString(); } if (isNew) diff --git a/MediaBrowser.Server.Implementations/Collections/CollectionManager.cs b/MediaBrowser.Server.Implementations/Collections/CollectionManager.cs index 28f3ed89cf..d92db34e33 100644 --- a/MediaBrowser.Server.Implementations/Collections/CollectionManager.cs +++ b/MediaBrowser.Server.Implementations/Collections/CollectionManager.cs @@ -69,7 +69,6 @@ namespace MediaBrowser.Server.Implementations.Collections { Name = name, Parent = parentFolder, - DisplayMediaType = "Collection", Path = path, IsLocked = options.IsLocked, ProviderIds = options.ProviderIds, diff --git a/MediaBrowser.Server.Implementations/Devices/CameraUploadsFolder.cs b/MediaBrowser.Server.Implementations/Devices/CameraUploadsFolder.cs index 10fc2ad911..2fe5d8f742 100644 --- a/MediaBrowser.Server.Implementations/Devices/CameraUploadsFolder.cs +++ b/MediaBrowser.Server.Implementations/Devices/CameraUploadsFolder.cs @@ -10,7 +10,6 @@ namespace MediaBrowser.Server.Implementations.Devices public CameraUploadsFolder() { Name = "Camera Uploads"; - DisplayMediaType = "CollectionFolder"; } public override bool IsVisible(User user) diff --git a/MediaBrowser.Server.Implementations/FileOrganization/OrganizerScheduledTask.cs b/MediaBrowser.Server.Implementations/FileOrganization/OrganizerScheduledTask.cs index 8dfdfdaece..74b994c28f 100644 --- a/MediaBrowser.Server.Implementations/FileOrganization/OrganizerScheduledTask.cs +++ b/MediaBrowser.Server.Implementations/FileOrganization/OrganizerScheduledTask.cs @@ -13,7 +13,7 @@ using System.Threading.Tasks; namespace MediaBrowser.Server.Implementations.FileOrganization { - public class OrganizerScheduledTask : IScheduledTask, IConfigurableScheduledTask, IScheduledTaskActivityLog + public class OrganizerScheduledTask : IScheduledTask, IConfigurableScheduledTask, IScheduledTaskActivityLog, IHasKey { private readonly ILibraryMonitor _libraryMonitor; private readonly ILibraryManager _libraryManager; @@ -82,5 +82,10 @@ namespace MediaBrowser.Server.Implementations.FileOrganization { get { return false; } } + + public string Key + { + get { return "AutoOrganize"; } + } } } diff --git a/MediaBrowser.Server.Implementations/Library/ResolverHelper.cs b/MediaBrowser.Server.Implementations/Library/ResolverHelper.cs index 03e28d7ba1..b6a93408ad 100644 --- a/MediaBrowser.Server.Implementations/Library/ResolverHelper.cs +++ b/MediaBrowser.Server.Implementations/Library/ResolverHelper.cs @@ -39,12 +39,6 @@ namespace MediaBrowser.Server.Implementations.Library item.Id = libraryManager.GetNewItemId(item.Path, item.GetType()); - // If the resolver didn't specify this - if (string.IsNullOrEmpty(item.DisplayMediaType)) - { - item.DisplayMediaType = item.GetType().Name; - } - item.IsLocked = item.Path.IndexOf("[dontfetchmeta]", StringComparison.OrdinalIgnoreCase) != -1 || item.Parents.Any(i => i.IsLocked); @@ -79,12 +73,6 @@ namespace MediaBrowser.Server.Implementations.Library item.Id = libraryManager.GetNewItemId(item.Path, item.GetType()); - // If the resolver didn't specify this - if (string.IsNullOrEmpty(item.DisplayMediaType)) - { - item.DisplayMediaType = item.GetType().Name; - } - // Make sure the item has a name EnsureName(item, args.FileInfo); diff --git a/MediaBrowser.Server.Implementations/Library/UserManager.cs b/MediaBrowser.Server.Implementations/Library/UserManager.cs index 3d64326363..3020a224de 100644 --- a/MediaBrowser.Server.Implementations/Library/UserManager.cs +++ b/MediaBrowser.Server.Implementations/Library/UserManager.cs @@ -411,6 +411,7 @@ namespace MediaBrowser.Server.Implementations.Library catch { user.Policy.EnabledFolders = new string[] { }; + user.Policy.EnableAllFolders = true; } } else @@ -419,6 +420,12 @@ namespace MediaBrowser.Server.Implementations.Library 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); diff --git a/MediaBrowser.Server.Implementations/Localization/Server/server.json b/MediaBrowser.Server.Implementations/Localization/Server/server.json index ccba2e6979..3c44adc60b 100644 --- a/MediaBrowser.Server.Implementations/Localization/Server/server.json +++ b/MediaBrowser.Server.Implementations/Localization/Server/server.json @@ -46,6 +46,8 @@ "OptionEnableWebClientResourceMinification": "Enable web client resource minification", "LabelDashboardSourcePath": "Web client source path:", "LabelDashboardSourcePathHelp": "If running the server from source, specify the path to the dashboard-ui folder. All web client files will be served from this location.", + "ButtonConvertMedia": "Convert media", + "ButtonOrganizeNow": "Organize now", "ButtonOk": "Ok", "ButtonCancel": "Cancel", "ButtonNew": "New", diff --git a/MediaBrowser.Server.Implementations/Sync/SyncScheduledTask.cs b/MediaBrowser.Server.Implementations/Sync/SyncScheduledTask.cs index 360cf54213..b68a97817b 100644 --- a/MediaBrowser.Server.Implementations/Sync/SyncScheduledTask.cs +++ b/MediaBrowser.Server.Implementations/Sync/SyncScheduledTask.cs @@ -13,7 +13,7 @@ using System.Threading.Tasks; namespace MediaBrowser.Server.Implementations.Sync { - public class SyncScheduledTask : IScheduledTask, IConfigurableScheduledTask + public class SyncScheduledTask : IScheduledTask, IConfigurableScheduledTask, IHasKey { private readonly ILibraryManager _libraryManager; private readonly ISyncRepository _syncRepo; @@ -42,7 +42,7 @@ namespace MediaBrowser.Server.Implementations.Sync public string Name { - get { return "Sync preparation"; } + get { return "Convert media"; } } public string Description @@ -54,7 +54,7 @@ namespace MediaBrowser.Server.Implementations.Sync { get { - return "Library"; + return "Sync"; } } @@ -82,5 +82,10 @@ namespace MediaBrowser.Server.Implementations.Sync { get { return true; } } + + public string Key + { + get { return "SyncPrepare"; } + } } } -- 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.Server.Implementations/Collections') 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 db038464814ea56fd90526dd35ce790cfc2a72e2 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 23 Jan 2015 01:15:15 -0500 Subject: sync updates --- MediaBrowser.Model/Sync/SyncJobItem.cs | 5 ++ .../BoxSets/BoxSetMetadataService.cs | 2 - MediaBrowser.Providers/Photos/PhotoProvider.cs | 2 +- .../Collections/CollectionImageProvider.cs | 67 ++++++++++++++++++++++ .../Collections/ManualCollectionsFolder.cs | 4 +- .../Localization/JavaScript/javascript.json | 2 + .../Localization/Server/server.json | 2 + .../MediaBrowser.Server.Implementations.csproj | 1 + .../Persistence/SqliteItemRepository.cs | 1 - .../Photos/BaseDynamicImageProvider.cs | 2 +- .../Playlists/ManualPlaylistsFolder.cs | 2 +- .../Sync/SyncJobProcessor.cs | 7 ++- .../Sync/SyncRepository.cs | 19 +++--- .../TV/TVSeriesManager.cs | 5 +- .../ApplicationHost.cs | 42 +++++++------- 15 files changed, 124 insertions(+), 39 deletions(-) create mode 100644 MediaBrowser.Server.Implementations/Collections/CollectionImageProvider.cs (limited to 'MediaBrowser.Server.Implementations/Collections') diff --git a/MediaBrowser.Model/Sync/SyncJobItem.cs b/MediaBrowser.Model/Sync/SyncJobItem.cs index 195d1e17ef..77464be58d 100644 --- a/MediaBrowser.Model/Sync/SyncJobItem.cs +++ b/MediaBrowser.Model/Sync/SyncJobItem.cs @@ -96,6 +96,11 @@ namespace MediaBrowser.Model.Sync /// /// true if this instance is marked for removal; otherwise, false. public bool IsMarkedForRemoval { get; set; } + /// + /// Gets or sets the index of the job item. + /// + /// The index of the job item. + public int JobItemIndex { get; set; } public SyncJobItem() { diff --git a/MediaBrowser.Providers/BoxSets/BoxSetMetadataService.cs b/MediaBrowser.Providers/BoxSets/BoxSetMetadataService.cs index e195df7dd7..3ac3cccb3d 100644 --- a/MediaBrowser.Providers/BoxSets/BoxSetMetadataService.cs +++ b/MediaBrowser.Providers/BoxSets/BoxSetMetadataService.cs @@ -2,14 +2,12 @@ using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.Movies; -using MediaBrowser.Controller.Entities.TV; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Localization; using MediaBrowser.Controller.Providers; using MediaBrowser.Model.Entities; using MediaBrowser.Model.Logging; using MediaBrowser.Providers.Manager; -using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; diff --git a/MediaBrowser.Providers/Photos/PhotoProvider.cs b/MediaBrowser.Providers/Photos/PhotoProvider.cs index 29b75d8302..3eaef59fbe 100644 --- a/MediaBrowser.Providers/Photos/PhotoProvider.cs +++ b/MediaBrowser.Providers/Photos/PhotoProvider.cs @@ -15,7 +15,7 @@ using TagLib.IFD.Tags; namespace MediaBrowser.Providers.Photos { - public class PhotoProvider : ICustomMetadataProvider, IHasItemChangeMonitor + public class PhotoProvider : ICustomMetadataProvider, IHasItemChangeMonitor, IForcedProvider { private readonly ILogger _logger; private readonly IImageProcessor _imageProcessor; diff --git a/MediaBrowser.Server.Implementations/Collections/CollectionImageProvider.cs b/MediaBrowser.Server.Implementations/Collections/CollectionImageProvider.cs new file mode 100644 index 0000000000..27ec6cc3b1 --- /dev/null +++ b/MediaBrowser.Server.Implementations/Collections/CollectionImageProvider.cs @@ -0,0 +1,67 @@ +using MediaBrowser.Common.IO; +using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Entities.Audio; +using MediaBrowser.Controller.Entities.Movies; +using MediaBrowser.Controller.Entities.TV; +using MediaBrowser.Controller.Providers; +using MediaBrowser.Model.Entities; +using MediaBrowser.Server.Implementations.Photos; +using MoreLinq; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace MediaBrowser.Server.Implementations.Collections +{ + public class CollectionImageProvider : BaseDynamicImageProvider, ICustomMetadataProvider + { + public CollectionImageProvider(IFileSystem fileSystem, IProviderManager providerManager) + : base(fileSystem, providerManager) + { + } + + protected override Task> GetItemsWithImages(IHasImages item) + { + var playlist = (BoxSet)item; + + var items = playlist.Children.Concat(playlist.GetLinkedChildren()) + .Select(i => + { + var subItem = i; + + var episode = subItem as Episode; + + if (episode != null) + { + var series = episode.Series; + if (series != null && series.HasImage(ImageType.Primary)) + { + return series; + } + } + + if (subItem.HasImage(ImageType.Primary)) + { + return subItem; + } + + var parent = subItem.Parent; + + if (parent != null && parent.HasImage(ImageType.Primary)) + { + if (parent is MusicAlbum) + { + return parent; + } + } + + return null; + }) + .Where(i => i != null) + .DistinctBy(i => i.Id) + .ToList(); + + return Task.FromResult(GetFinalItems(items)); + } + } +} diff --git a/MediaBrowser.Server.Implementations/Collections/ManualCollectionsFolder.cs b/MediaBrowser.Server.Implementations/Collections/ManualCollectionsFolder.cs index b02c52874c..fa4de728b9 100644 --- a/MediaBrowser.Server.Implementations/Collections/ManualCollectionsFolder.cs +++ b/MediaBrowser.Server.Implementations/Collections/ManualCollectionsFolder.cs @@ -13,8 +13,8 @@ namespace MediaBrowser.Server.Implementations.Collections public override bool IsVisible(User user) { - return GetChildren(user, true).Any() && - base.IsVisible(user); + return base.IsVisible(user) && GetChildren(user, false) + .Any(); } public override bool IsHidden diff --git a/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json b/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json index 4206ccf591..5d37007e06 100644 --- a/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json +++ b/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json @@ -34,6 +34,7 @@ "MessageKeyRemoved": "Thank you. Your supporter key has been removed.", "ErrorLaunchingChromecast": "There was an error launching chromecast. Please ensure your device is connected to your wireless network.", "HeaderSearch": "Search", + "ValueDateCreated": "Date created: {0}", "LabelArtist": "Artist", "LabelMovie": "Movie", "LabelMusicVideo": "Music Video", @@ -46,6 +47,7 @@ "ButtonSave": "Save", "HeaderDevices": "Devices", "ButtonScheduledTasks": "Scheduled tasks", + "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}.", "HeaderWelcomeToMediaBrowserServerDashboard": "Welcome to the Media Browser Dashboard", diff --git a/MediaBrowser.Server.Implementations/Localization/Server/server.json b/MediaBrowser.Server.Implementations/Localization/Server/server.json index e4677e4d10..3a5e7c77e7 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", + "LabelCustomCertificatePath": "Custom certificate path:", + "LabelCustomCertificatePathHelp": "Supply your own ssl certificate. If omitted, the server will create a self-signed certificate.", "TitleNotifications": "Notifications", "ButtonDonateWithPayPal": "Donate with PayPal", "OptionDetectArchiveFilesAsMedia": "Detect archive files as media", diff --git a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj index 1737e6fd39..c0cc0395cd 100644 --- a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj +++ b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj @@ -117,6 +117,7 @@ + diff --git a/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs b/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs index cd79282909..99c59abc5d 100644 --- a/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs +++ b/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs @@ -1,7 +1,6 @@ using MediaBrowser.Common.Configuration; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Persistence; -using MediaBrowser.Controller.Providers; using MediaBrowser.Model.Entities; using MediaBrowser.Model.Logging; using MediaBrowser.Model.Serialization; diff --git a/MediaBrowser.Server.Implementations/Photos/BaseDynamicImageProvider.cs b/MediaBrowser.Server.Implementations/Photos/BaseDynamicImageProvider.cs index dbaf23656d..369e8512fa 100644 --- a/MediaBrowser.Server.Implementations/Photos/BaseDynamicImageProvider.cs +++ b/MediaBrowser.Server.Implementations/Photos/BaseDynamicImageProvider.cs @@ -14,7 +14,7 @@ using System.Threading.Tasks; namespace MediaBrowser.Server.Implementations.Photos { - public abstract class BaseDynamicImageProvider : IHasChangeMonitor + public abstract class BaseDynamicImageProvider : IHasChangeMonitor, IForcedProvider where T : IHasImages { protected IFileSystem FileSystem { get; private set; } diff --git a/MediaBrowser.Server.Implementations/Playlists/ManualPlaylistsFolder.cs b/MediaBrowser.Server.Implementations/Playlists/ManualPlaylistsFolder.cs index 89395a00b5..2b2c524061 100644 --- a/MediaBrowser.Server.Implementations/Playlists/ManualPlaylistsFolder.cs +++ b/MediaBrowser.Server.Implementations/Playlists/ManualPlaylistsFolder.cs @@ -16,7 +16,7 @@ namespace MediaBrowser.Server.Implementations.Playlists public override bool IsVisible(User user) { - return base.IsVisible(user) && GetRecursiveChildren(user, false) + return base.IsVisible(user) && GetChildren(user, false) .OfType() .Any(i => i.IsVisible(user)); } diff --git a/MediaBrowser.Server.Implementations/Sync/SyncJobProcessor.cs b/MediaBrowser.Server.Implementations/Sync/SyncJobProcessor.cs index 67f9d363e2..716584084c 100644 --- a/MediaBrowser.Server.Implementations/Sync/SyncJobProcessor.cs +++ b/MediaBrowser.Server.Implementations/Sync/SyncJobProcessor.cs @@ -90,6 +90,10 @@ namespace MediaBrowser.Server.Implementations.Sync continue; } + var index = jobItems.Count == 0 ? + 0 : + (jobItems.Select(i => i.JobItemIndex).Max() + 1); + jobItem = new SyncJobItem { Id = Guid.NewGuid().ToString("N"), @@ -97,7 +101,8 @@ namespace MediaBrowser.Server.Implementations.Sync ItemName = GetSyncJobItemName(item), JobId = job.Id, TargetId = job.TargetId, - DateCreated = DateTime.UtcNow + DateCreated = DateTime.UtcNow, + JobItemIndex = index }; await _syncRepo.Create(jobItem).ConfigureAwait(false); diff --git a/MediaBrowser.Server.Implementations/Sync/SyncRepository.cs b/MediaBrowser.Server.Implementations/Sync/SyncRepository.cs index 1cd8e8a9d4..0e527ea540 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, "sync13.db"); + var dbFile = Path.Combine(_appPaths.DataPath, "sync14.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, IsMarkedForRemoval BIT)", + "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, JobItemIndex INT)", "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, IsMarkedForRemoval) values (@Id, @ItemId, @ItemName, @MediaSourceId, @JobId, @TemporaryPath, @OutputPath, @Status, @TargetId, @DateCreated, @Progress, @AdditionalFiles, @MediaSource, @IsMarkedForRemoval)"; + _saveJobItemCommand.CommandText = "replace into SyncJobItems (Id, ItemId, ItemName, MediaSourceId, JobId, TemporaryPath, OutputPath, Status, TargetId, DateCreated, Progress, AdditionalFiles, MediaSource, IsMarkedForRemoval, JobItemIndex) values (@Id, @ItemId, @ItemName, @MediaSourceId, @JobId, @TemporaryPath, @OutputPath, @Status, @TargetId, @DateCreated, @Progress, @AdditionalFiles, @MediaSource, @IsMarkedForRemoval, @JobItemIndex)"; _saveJobItemCommand.Parameters.Add(_saveJobItemCommand, "@Id"); _saveJobItemCommand.Parameters.Add(_saveJobItemCommand, "@ItemId"); @@ -111,10 +111,11 @@ namespace MediaBrowser.Server.Implementations.Sync _saveJobItemCommand.Parameters.Add(_saveJobItemCommand, "@AdditionalFiles"); _saveJobItemCommand.Parameters.Add(_saveJobItemCommand, "@MediaSource"); _saveJobItemCommand.Parameters.Add(_saveJobItemCommand, "@IsMarkedForRemoval"); + _saveJobItemCommand.Parameters.Add(_saveJobItemCommand, "@JobItemIndex"); } 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, IsMarkedForRemoval from SyncJobItems"; + private const string BaseJobItemSelectText = "select Id, ItemId, ItemName, MediaSourceId, JobId, TemporaryPath, OutputPath, Status, TargetId, DateCreated, Progress, AdditionalFiles, MediaSource, IsMarkedForRemoval, JobItemIndex from SyncJobItems"; public SyncJob GetJob(string id) { @@ -496,7 +497,7 @@ namespace MediaBrowser.Server.Implementations.Sync var startIndex = query.StartIndex ?? 0; if (startIndex > 0) { - whereClauses.Add(string.Format("Id NOT IN (SELECT Id FROM SyncJobItems ORDER BY DateCreated LIMIT {0})", + whereClauses.Add(string.Format("Id NOT IN (SELECT Id FROM SyncJobItems ORDER BY JobItemIndex, DateCreated LIMIT {0})", startIndex.ToString(_usCulture))); } @@ -505,7 +506,7 @@ namespace MediaBrowser.Server.Implementations.Sync cmd.CommandText += " where " + string.Join(" AND ", whereClauses.ToArray()); } - cmd.CommandText += " ORDER BY DateCreated"; + cmd.CommandText += " ORDER BY JobItemIndex, DateCreated"; if (query.Limit.HasValue) { @@ -574,6 +575,7 @@ namespace MediaBrowser.Server.Implementations.Sync _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.GetParameter(index++).Value = jobItem.JobItemIndex; _saveJobItemCommand.Transaction = transaction; @@ -648,7 +650,7 @@ namespace MediaBrowser.Server.Implementations.Sync info.TargetId = reader.GetString(8); - info.DateCreated = reader.GetDateTime(9); + info.DateCreated = reader.GetDateTime(9).ToUniversalTime(); if (!reader.IsDBNull(10)) { @@ -676,7 +678,8 @@ namespace MediaBrowser.Server.Implementations.Sync } info.IsMarkedForRemoval = reader.GetBoolean(13); - + info.JobItemIndex = reader.GetInt32(14); + return info; } diff --git a/MediaBrowser.Server.Implementations/TV/TVSeriesManager.cs b/MediaBrowser.Server.Implementations/TV/TVSeriesManager.cs index 66e771aa37..8c21727a4b 100644 --- a/MediaBrowser.Server.Implementations/TV/TVSeriesManager.cs +++ b/MediaBrowser.Server.Implementations/TV/TVSeriesManager.cs @@ -163,7 +163,10 @@ namespace MediaBrowser.Server.Implementations.TV return new Tuple(nextUp, lastWatchedDate); } - return new Tuple(null, lastWatchedDate); + var firstEpisode = allEpisodes.LastOrDefault(i => i.LocationType != LocationType.Virtual && !i.IsPlayed(user)); + + // Return the first episode + return new Tuple(firstEpisode, DateTime.MinValue); } private IEnumerable FilterSeries(NextUpQuery request, IEnumerable items) diff --git a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs index 7eb68187a3..4fc6ae6fa1 100644 --- a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs +++ b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs @@ -796,35 +796,35 @@ namespace MediaBrowser.Server.Startup.Common private string GetCertificatePath(bool generateCertificate) { - if (string.IsNullOrWhiteSpace(ServerConfigurationManager.Configuration.CertificatePath)) + if (!string.IsNullOrWhiteSpace(ServerConfigurationManager.Configuration.CertificatePath)) { - // Generate self-signed cert - var certHost = GetHostnameFromExternalDns(ServerConfigurationManager.Configuration.WanDdns); - var certPath = Path.Combine(ServerConfigurationManager.ApplicationPaths.ProgramDataPath, "ssl", "cert_" + certHost.GetMD5().ToString("N") + ".pfx"); + // Custom cert + return ServerConfigurationManager.Configuration.CertificatePath; + } + + // Generate self-signed cert + var certHost = GetHostnameFromExternalDns(ServerConfigurationManager.Configuration.WanDdns); + var certPath = Path.Combine(ServerConfigurationManager.ApplicationPaths.ProgramDataPath, "ssl", "cert_" + certHost.GetMD5().ToString("N") + ".pfx"); - if (generateCertificate) + if (generateCertificate) + { + if (!File.Exists(certPath)) { - if (!File.Exists(certPath)) + Directory.CreateDirectory(Path.GetDirectoryName(certPath)); + + try { - Directory.CreateDirectory(Path.GetDirectoryName(certPath)); - - try - { - NetworkManager.GenerateSelfSignedSslCertificate(certPath, certHost); - } - catch (Exception ex) - { - Logger.ErrorException("Error creating ssl cert", ex); - return null; - } + NetworkManager.GenerateSelfSignedSslCertificate(certPath, certHost); + } + catch (Exception ex) + { + Logger.ErrorException("Error creating ssl cert", ex); + return null; } } - - return certPath; } - // Custom cert - return ServerConfigurationManager.Configuration.CertificatePath; + return certPath; } /// -- cgit v1.2.3 From ee00f8bf726ae5498d64cff0086b9b7e638936ea Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 24 Jan 2015 14:03:55 -0500 Subject: added HasSyncJob --- MediaBrowser.Api/BaseApiService.cs | 36 +++++++- MediaBrowser.Api/GamesService.cs | 4 +- MediaBrowser.Api/IHasDtoOptions.cs | 29 +------ MediaBrowser.Api/ItemLookupService.cs | 3 +- MediaBrowser.Api/Library/LibraryService.cs | 16 ++-- MediaBrowser.Api/Movies/CollectionService.cs | 2 +- MediaBrowser.Api/Movies/MoviesService.cs | 14 +-- MediaBrowser.Api/Movies/TrailersService.cs | 8 +- MediaBrowser.Api/Music/AlbumsService.cs | 4 +- MediaBrowser.Api/Music/InstantMixService.cs | 7 +- MediaBrowser.Api/PlaylistService.cs | 7 +- MediaBrowser.Api/SimilarItemsHelper.cs | 5 +- MediaBrowser.Api/Sync/SyncService.cs | 7 +- MediaBrowser.Api/TvShowsService.cs | 22 ++--- MediaBrowser.Api/UserLibrary/ArtistsService.cs | 2 +- .../UserLibrary/BaseItemsByNameService.cs | 2 +- MediaBrowser.Api/UserLibrary/GameGenresService.cs | 2 +- MediaBrowser.Api/UserLibrary/GenresService.cs | 2 +- MediaBrowser.Api/UserLibrary/ItemsService.cs | 6 +- MediaBrowser.Api/UserLibrary/MusicGenresService.cs | 2 +- MediaBrowser.Api/UserLibrary/PersonsService.cs | 2 +- MediaBrowser.Api/UserLibrary/StudiosService.cs | 2 +- MediaBrowser.Api/UserLibrary/UserLibraryService.cs | 16 ++-- MediaBrowser.Api/UserLibrary/YearsService.cs | 2 +- MediaBrowser.Api/VideosService.cs | 2 +- .../Networking/BaseNetworkManager.cs | 53 ++++++++++++ .../ScheduledTasks/ScheduledTaskWorker.cs | 6 ++ MediaBrowser.Common/Net/INetworkManager.cs | 1 - .../Collections/ICollectionManager.cs | 7 ++ MediaBrowser.Controller/Dto/DtoOptions.cs | 1 + MediaBrowser.Controller/Dto/IDtoService.cs | 11 +++ MediaBrowser.Controller/IServerApplicationHost.cs | 12 ++- MediaBrowser.Controller/Sync/ISyncManager.cs | 7 ++ MediaBrowser.Controller/Sync/ISyncRepository.cs | 7 ++ MediaBrowser.Dlna/Ssdp/DeviceDiscovery.cs | 2 +- .../Configuration/ServerConfiguration.cs | 2 + MediaBrowser.Model/Dto/BaseItemDto.cs | 3 +- MediaBrowser.Model/Tasks/TaskResult.cs | 6 ++ .../Channels/ChannelManager.cs | 8 +- .../Collections/CollectionManager.cs | 12 ++- .../Connect/ConnectManager.cs | 4 +- .../Dto/DtoService.cs | 99 ++++++++++++++++++++-- .../Library/LibraryManager.cs | 2 +- .../Library/UserManager.cs | 3 +- .../Library/UserViewManager.cs | 38 ++++++--- .../Localization/Server/server.json | 4 +- .../Sync/SyncManager.cs | 5 ++ .../Sync/SyncRepository.cs | 27 ++++-- .../Udp/UdpServer.cs | 14 ++- .../ApplicationHost.cs | 41 +++++---- MediaBrowser.sln | 5 ++ 51 files changed, 419 insertions(+), 165 deletions(-) (limited to 'MediaBrowser.Server.Implementations/Collections') diff --git a/MediaBrowser.Api/BaseApiService.cs b/MediaBrowser.Api/BaseApiService.cs index e909696553..2aaec8627a 100644 --- a/MediaBrowser.Api/BaseApiService.cs +++ b/MediaBrowser.Api/BaseApiService.cs @@ -1,8 +1,10 @@ -using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Dto; +using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.Audio; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Net; using MediaBrowser.Controller.Session; +using MediaBrowser.Model.Entities; using MediaBrowser.Model.Logging; using ServiceStack.Text.Controller; using ServiceStack.Web; @@ -36,6 +38,7 @@ namespace MediaBrowser.Api public IRequest Request { get; set; } public ISessionContext SessionContext { get; set; } + public IAuthorizationContext AuthorizationContext { get; set; } public string GetHeader(string name) { @@ -110,6 +113,37 @@ namespace MediaBrowser.Api private readonly char[] _dashReplaceChars = { '?', '/', '&' }; private const char SlugChar = '-'; + protected DtoOptions GetDtoOptions(object request) + { + var options = new DtoOptions(); + + options.DeviceId = AuthorizationContext.GetAuthorizationInfo(Request).DeviceId; + + var hasFields = request as IHasItemFields; + if (hasFields != null) + { + options.Fields = hasFields.GetItemFields().ToList(); + } + + var hasDtoOptions = request as IHasDtoOptions; + if (hasDtoOptions != null) + { + options.EnableImages = hasDtoOptions.EnableImages ?? true; + + if (hasDtoOptions.ImageTypeLimit.HasValue) + { + options.ImageTypeLimit = hasDtoOptions.ImageTypeLimit.Value; + } + + if (!string.IsNullOrWhiteSpace(hasDtoOptions.EnableImageTypes)) + { + options.ImageTypes = (hasDtoOptions.EnableImageTypes ?? string.Empty).Split(',').Where(i => !string.IsNullOrWhiteSpace(i)).Select(v => (ImageType)Enum.Parse(typeof(ImageType), v, true)).ToList(); + } + } + + return options; + } + protected MusicArtist GetArtist(string name, ILibraryManager libraryManager) { return libraryManager.GetArtist(DeSlugArtistName(name, libraryManager)); diff --git a/MediaBrowser.Api/GamesService.cs b/MediaBrowser.Api/GamesService.cs index 9aba2b0652..39e357f498 100644 --- a/MediaBrowser.Api/GamesService.cs +++ b/MediaBrowser.Api/GamesService.cs @@ -172,7 +172,9 @@ namespace MediaBrowser.Api /// System.Object. public object Get(GetSimilarGames request) { - var result = SimilarItemsHelper.GetSimilarItemsResult(_userManager, + var dtoOptions = GetDtoOptions(request); + + var result = SimilarItemsHelper.GetSimilarItemsResult(dtoOptions, _userManager, _itemRepo, _libraryManager, _userDataRepository, diff --git a/MediaBrowser.Api/IHasDtoOptions.cs b/MediaBrowser.Api/IHasDtoOptions.cs index 7fe47c4a1e..dac366113c 100644 --- a/MediaBrowser.Api/IHasDtoOptions.cs +++ b/MediaBrowser.Api/IHasDtoOptions.cs @@ -1,8 +1,4 @@ -using MediaBrowser.Controller.Dto; -using MediaBrowser.Model.Entities; -using System; -using System.Linq; - + namespace MediaBrowser.Api { public interface IHasDtoOptions : IHasItemFields @@ -13,27 +9,4 @@ namespace MediaBrowser.Api string EnableImageTypes { get; set; } } - - public static class HasDtoOptionsExtensions - { - public static DtoOptions GetDtoOptions(this IHasDtoOptions request) - { - var options = new DtoOptions(); - - options.Fields = request.GetItemFields().ToList(); - options.EnableImages = request.EnableImages ?? true; - - if (request.ImageTypeLimit.HasValue) - { - options.ImageTypeLimit = request.ImageTypeLimit.Value; - } - - if (!string.IsNullOrWhiteSpace(request.EnableImageTypes)) - { - options.ImageTypes = (request.EnableImageTypes ?? string.Empty).Split(',').Where(i => !string.IsNullOrWhiteSpace(i)).Select(v => (ImageType)Enum.Parse(typeof(ImageType), v, true)).ToList(); - } - - return options; - } - } } diff --git a/MediaBrowser.Api/ItemLookupService.cs b/MediaBrowser.Api/ItemLookupService.cs index 9a97022b67..d6b4da8bea 100644 --- a/MediaBrowser.Api/ItemLookupService.cs +++ b/MediaBrowser.Api/ItemLookupService.cs @@ -205,7 +205,8 @@ namespace MediaBrowser.Api Logger = Logger, Request = Request, ResultFactory = ResultFactory, - SessionContext = SessionContext + SessionContext = SessionContext, + AuthorizationContext = AuthorizationContext }; service.Post(new RefreshItem diff --git a/MediaBrowser.Api/Library/LibraryService.cs b/MediaBrowser.Api/Library/LibraryService.cs index 5e1619672f..bac6f6a397 100644 --- a/MediaBrowser.Api/Library/LibraryService.cs +++ b/MediaBrowser.Api/Library/LibraryService.cs @@ -272,7 +272,7 @@ namespace MediaBrowser.Api.Library items = items.Where(i => i.IsHidden == val).ToList(); } - var dtoOptions = new DtoOptions(); + var dtoOptions = GetDtoOptions(request); var result = new ItemsResult { @@ -344,7 +344,7 @@ namespace MediaBrowser.Api.Library var user = request.UserId.HasValue ? _userManager.GetUserById(request.UserId.Value) : null; - var dtoOptions = new DtoOptions(); + var dtoOptions = GetDtoOptions(request); BaseItem parent = item.Parent; @@ -544,7 +544,7 @@ namespace MediaBrowser.Api.Library ThemeSongsResult = themeSongs, ThemeVideosResult = themeVideos, - SoundtrackSongsResult = GetSoundtrackSongs(request.Id, request.UserId, request.InheritFromParent) + SoundtrackSongsResult = GetSoundtrackSongs(request, request.Id, request.UserId, request.InheritFromParent) }); } @@ -597,7 +597,7 @@ namespace MediaBrowser.Api.Library } } - var dtoOptions = new DtoOptions(); + var dtoOptions = GetDtoOptions(request); var dtos = themeSongIds.Select(_libraryManager.GetItemById) .OrderBy(i => i.SortName) @@ -667,7 +667,7 @@ namespace MediaBrowser.Api.Library } } - var dtoOptions = new DtoOptions(); + var dtoOptions = GetDtoOptions(request); var dtos = themeVideoIds.Select(_libraryManager.GetItemById) .OrderBy(i => i.SortName) @@ -732,17 +732,17 @@ namespace MediaBrowser.Api.Library return ToOptimizedSerializedResultUsingCache(lookup); } - public ThemeMediaResult GetSoundtrackSongs(string id, Guid? userId, bool inheritFromParent) + public ThemeMediaResult GetSoundtrackSongs(GetThemeMedia request, string id, Guid? userId, bool inheritFromParent) { var user = userId.HasValue ? _userManager.GetUserById(userId.Value) : null; var item = string.IsNullOrEmpty(id) ? (userId.HasValue ? user.RootFolder - : (Folder)_libraryManager.RootFolder) + : _libraryManager.RootFolder) : _libraryManager.GetItemById(id); - var dtoOptions = new DtoOptions(); + var dtoOptions = GetDtoOptions(request); var dtos = GetSoundtrackSongIds(item, inheritFromParent) .Select(_libraryManager.GetItemById) diff --git a/MediaBrowser.Api/Movies/CollectionService.cs b/MediaBrowser.Api/Movies/CollectionService.cs index 97c6cd87da..e6277e39a2 100644 --- a/MediaBrowser.Api/Movies/CollectionService.cs +++ b/MediaBrowser.Api/Movies/CollectionService.cs @@ -71,7 +71,7 @@ namespace MediaBrowser.Api.Movies }).ConfigureAwait(false); - var dtoOptions = new DtoOptions(); + var dtoOptions = GetDtoOptions(request); var dto = _dtoService.GetBaseItemDto(item, dtoOptions); diff --git a/MediaBrowser.Api/Movies/MoviesService.cs b/MediaBrowser.Api/Movies/MoviesService.cs index ba3c15a90b..0b8bb4036d 100644 --- a/MediaBrowser.Api/Movies/MoviesService.cs +++ b/MediaBrowser.Api/Movies/MoviesService.cs @@ -157,7 +157,7 @@ namespace MediaBrowser.Api.Movies .DistinctBy(i => i.GetProviderId(MetadataProviders.Imdb) ?? Guid.NewGuid().ToString(), StringComparer.OrdinalIgnoreCase) .ToList(); - var dtoOptions = new DtoOptions(); + var dtoOptions = GetDtoOptions(request); dtoOptions.Fields = request.GetItemFields().ToList(); @@ -174,8 +174,6 @@ namespace MediaBrowser.Api.Movies (request.UserId.HasValue ? user.RootFolder : _libraryManager.RootFolder) : _libraryManager.GetItemById(request.Id); - var fields = request.GetItemFields().ToList(); - var inputItems = user == null ? _libraryManager.RootFolder.GetRecursiveChildren().Where(i => i.Id != item.Id) : user.RootFolder.GetRecursiveChildren(user).Where(i => i.Id != item.Id); @@ -225,10 +223,12 @@ namespace MediaBrowser.Api.Movies { returnItems = returnItems.Take(request.Limit.Value); } + + var dtoOptions = GetDtoOptions(request); var result = new ItemsResult { - Items = returnItems.Select(i => _dtoService.GetBaseItemDto(i, fields, user)).ToArray(), + Items = _dtoService.GetBaseItemDtos(returnItems, dtoOptions, user).ToArray(), TotalRecordCount = items.Count }; @@ -351,7 +351,7 @@ namespace MediaBrowser.Api.Movies BaselineItemName = director, CategoryId = director.GetMD5().ToString("N"), RecommendationType = type, - Items = items.Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, user)).ToArray() + Items = _dtoService.GetBaseItemDtos(items, dtoOptions, user).ToArray() }; } } @@ -375,7 +375,7 @@ namespace MediaBrowser.Api.Movies BaselineItemName = name, CategoryId = name.GetMD5().ToString("N"), RecommendationType = type, - Items = items.Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, user)).ToArray() + Items = _dtoService.GetBaseItemDtos(items, dtoOptions, user).ToArray() }; } } @@ -399,7 +399,7 @@ namespace MediaBrowser.Api.Movies BaselineItemName = item.Name, CategoryId = item.Id.ToString("N"), RecommendationType = type, - Items = similar.Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, user)).ToArray() + Items = _dtoService.GetBaseItemDtos(similar, dtoOptions, user).ToArray() }; } } diff --git a/MediaBrowser.Api/Movies/TrailersService.cs b/MediaBrowser.Api/Movies/TrailersService.cs index 8e1704af73..3bee59a869 100644 --- a/MediaBrowser.Api/Movies/TrailersService.cs +++ b/MediaBrowser.Api/Movies/TrailersService.cs @@ -84,7 +84,9 @@ namespace MediaBrowser.Api.Movies /// System.Object. public object Get(GetSimilarTrailers request) { - var result = SimilarItemsHelper.GetSimilarItemsResult(_userManager, + var dtoOptions = GetDtoOptions(request); + + var result = SimilarItemsHelper.GetSimilarItemsResult(dtoOptions, _userManager, _itemRepo, _libraryManager, _userDataRepository, @@ -119,9 +121,9 @@ namespace MediaBrowser.Api.Movies var pagedItems = ApplyPaging(request, itemsArray); - var fields = request.GetItemFields().ToList(); + var dtoOptions = GetDtoOptions(request); - var returnItems = pagedItems.Select(i => _dtoService.GetBaseItemDto(i, fields, user)).ToArray(); + var returnItems = _dtoService.GetBaseItemDtos(pagedItems, dtoOptions, user).ToArray(); return new ItemsResult { diff --git a/MediaBrowser.Api/Music/AlbumsService.cs b/MediaBrowser.Api/Music/AlbumsService.cs index 34a933dee3..4cfb3c7d44 100644 --- a/MediaBrowser.Api/Music/AlbumsService.cs +++ b/MediaBrowser.Api/Music/AlbumsService.cs @@ -50,7 +50,9 @@ namespace MediaBrowser.Api.Music /// System.Object. public object Get(GetSimilarAlbums request) { - var result = SimilarItemsHelper.GetSimilarItemsResult(_userManager, + var dtoOptions = GetDtoOptions(request); + + var result = SimilarItemsHelper.GetSimilarItemsResult(dtoOptions, _userManager, _itemRepo, _libraryManager, _userDataRepository, diff --git a/MediaBrowser.Api/Music/InstantMixService.cs b/MediaBrowser.Api/Music/InstantMixService.cs index 43fd0894b9..cfb826a134 100644 --- a/MediaBrowser.Api/Music/InstantMixService.cs +++ b/MediaBrowser.Api/Music/InstantMixService.cs @@ -146,8 +146,6 @@ namespace MediaBrowser.Api.Music private object GetResult(IEnumerable /// System.String. - public override string GetUserDataKey() + protected override string CreateUserDataKey() { return GetUserDataKey(this); } diff --git a/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs b/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs index 928eb64630..ad2d39c794 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs @@ -14,7 +14,7 @@ namespace MediaBrowser.Controller.Entities.Audio /// Gets the user data key. /// /// System.String. - public override string GetUserDataKey() + protected override string CreateUserDataKey() { return "MusicGenre-" + Name; } diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index 2be4f99e9c..234a33d78f 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -359,7 +359,7 @@ namespace MediaBrowser.Controller.Entities { get { - if (!string.IsNullOrEmpty(ForcedSortName)) + if (!string.IsNullOrWhiteSpace(ForcedSortName)) { return ForcedSortName; } @@ -887,11 +887,22 @@ namespace MediaBrowser.Controller.Entities get { return null; } } + private string _userDataKey; /// /// Gets the user data key. /// /// System.String. - public virtual string GetUserDataKey() + public string GetUserDataKey() + { + if (!string.IsNullOrWhiteSpace(_userDataKey)) + { + return _userDataKey; + } + + return _userDataKey ?? (_userDataKey = CreateUserDataKey()); + } + + protected virtual string CreateUserDataKey() { return Id.ToString(); } @@ -1701,6 +1712,9 @@ namespace MediaBrowser.Controller.Entities /// public virtual bool BeforeMetadataRefresh() { + _userDataKey = null; + _sortName = null; + var hasChanges = false; if (string.IsNullOrEmpty(Name) && !string.IsNullOrEmpty(Path)) diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index ff6e8e85b1..dd3d145a03 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -807,7 +807,7 @@ namespace MediaBrowser.Controller.Entities protected QueryResult SortAndFilter(IEnumerable items, InternalItemsQuery query) { - return UserViewBuilder.SortAndFilter(items, this, null, query, LibraryManager, UserDataManager); + return UserViewBuilder.FilterAndSort(items, this, null, query, LibraryManager, UserDataManager); } /// diff --git a/MediaBrowser.Controller/Entities/Game.cs b/MediaBrowser.Controller/Entities/Game.cs index bf32d3e634..71642ea902 100644 --- a/MediaBrowser.Controller/Entities/Game.cs +++ b/MediaBrowser.Controller/Entities/Game.cs @@ -88,7 +88,7 @@ namespace MediaBrowser.Controller.Entities /// public List MultiPartGameFiles { get; set; } - public override string GetUserDataKey() + protected override string CreateUserDataKey() { var id = this.GetProviderId(MetadataProviders.Gamesdb); @@ -96,7 +96,7 @@ namespace MediaBrowser.Controller.Entities { return "Game-Gamesdb-" + id; } - return base.GetUserDataKey(); + return base.CreateUserDataKey(); } public override IEnumerable GetDeletePaths() diff --git a/MediaBrowser.Controller/Entities/GameGenre.cs b/MediaBrowser.Controller/Entities/GameGenre.cs index 8254689540..16ca6e70a0 100644 --- a/MediaBrowser.Controller/Entities/GameGenre.cs +++ b/MediaBrowser.Controller/Entities/GameGenre.cs @@ -10,7 +10,7 @@ namespace MediaBrowser.Controller.Entities /// Gets the user data key. /// /// System.String. - public override string GetUserDataKey() + protected override string CreateUserDataKey() { return "GameGenre-" + Name; } diff --git a/MediaBrowser.Controller/Entities/GameSystem.cs b/MediaBrowser.Controller/Entities/GameSystem.cs index 7584989779..cf69167638 100644 --- a/MediaBrowser.Controller/Entities/GameSystem.cs +++ b/MediaBrowser.Controller/Entities/GameSystem.cs @@ -35,13 +35,13 @@ namespace MediaBrowser.Controller.Entities /// Gets the user data key. /// /// System.String. - public override string GetUserDataKey() + protected override string CreateUserDataKey() { if (!string.IsNullOrEmpty(GameSystemName)) { return "GameSystem-" + GameSystemName; } - return base.GetUserDataKey(); + return base.CreateUserDataKey(); } protected override bool GetBlockUnratedValue(UserPolicy config) diff --git a/MediaBrowser.Controller/Entities/Genre.cs b/MediaBrowser.Controller/Entities/Genre.cs index 05442f2b7f..da5569afc9 100644 --- a/MediaBrowser.Controller/Entities/Genre.cs +++ b/MediaBrowser.Controller/Entities/Genre.cs @@ -14,7 +14,7 @@ namespace MediaBrowser.Controller.Entities /// Gets the user data key. /// /// System.String. - public override string GetUserDataKey() + protected override string CreateUserDataKey() { return "Genre-" + Name; } diff --git a/MediaBrowser.Controller/Entities/Movies/Movie.cs b/MediaBrowser.Controller/Entities/Movies/Movie.cs index 2fa5fc6e1e..cfe008bd7c 100644 --- a/MediaBrowser.Controller/Entities/Movies/Movie.cs +++ b/MediaBrowser.Controller/Entities/Movies/Movie.cs @@ -100,9 +100,9 @@ namespace MediaBrowser.Controller.Entities.Movies /// Gets the user data key. /// /// System.String. - public override string GetUserDataKey() + protected override string CreateUserDataKey() { - return this.GetProviderId(MetadataProviders.Tmdb) ?? this.GetProviderId(MetadataProviders.Imdb) ?? base.GetUserDataKey(); + return this.GetProviderId(MetadataProviders.Tmdb) ?? this.GetProviderId(MetadataProviders.Imdb) ?? base.CreateUserDataKey(); } protected override async Task RefreshedOwnedItems(MetadataRefreshOptions options, List fileSystemChildren, CancellationToken cancellationToken) diff --git a/MediaBrowser.Controller/Entities/MusicVideo.cs b/MediaBrowser.Controller/Entities/MusicVideo.cs index 4ca8cf1c5a..771c62fd6d 100644 --- a/MediaBrowser.Controller/Entities/MusicVideo.cs +++ b/MediaBrowser.Controller/Entities/MusicVideo.cs @@ -47,21 +47,6 @@ namespace MediaBrowser.Controller.Entities } } - /// - /// TODO: Remove - /// - public string Artist - { - get { return Artists.FirstOrDefault(); } - set - { - if (!string.IsNullOrEmpty(value) && !Artists.Contains(value, StringComparer.OrdinalIgnoreCase)) - { - Artists.Add(value); - } - } - } - /// /// Determines whether the specified name has artist. /// @@ -76,9 +61,9 @@ namespace MediaBrowser.Controller.Entities /// Gets the user data key. /// /// System.String. - public override string GetUserDataKey() + protected override string CreateUserDataKey() { - return this.GetProviderId(MetadataProviders.Tmdb) ?? this.GetProviderId(MetadataProviders.Imdb) ?? base.GetUserDataKey(); + return this.GetProviderId(MetadataProviders.Tmdb) ?? this.GetProviderId(MetadataProviders.Imdb) ?? base.CreateUserDataKey(); } protected override bool GetBlockUnratedValue(UserPolicy config) diff --git a/MediaBrowser.Controller/Entities/Person.cs b/MediaBrowser.Controller/Entities/Person.cs index fe8d618362..6d256e81c7 100644 --- a/MediaBrowser.Controller/Entities/Person.cs +++ b/MediaBrowser.Controller/Entities/Person.cs @@ -20,7 +20,7 @@ namespace MediaBrowser.Controller.Entities /// Gets the user data key. /// /// System.String. - public override string GetUserDataKey() + protected override string CreateUserDataKey() { return "Person-" + Name; } diff --git a/MediaBrowser.Controller/Entities/Studio.cs b/MediaBrowser.Controller/Entities/Studio.cs index 0d934ad0a5..58d46facc9 100644 --- a/MediaBrowser.Controller/Entities/Studio.cs +++ b/MediaBrowser.Controller/Entities/Studio.cs @@ -20,7 +20,7 @@ namespace MediaBrowser.Controller.Entities /// Gets the user data key. /// /// System.String. - public override string GetUserDataKey() + protected override string CreateUserDataKey() { return "Studio-" + Name; } diff --git a/MediaBrowser.Controller/Entities/TV/Episode.cs b/MediaBrowser.Controller/Entities/TV/Episode.cs index 6b67cebc88..a2731f6dfb 100644 --- a/MediaBrowser.Controller/Entities/TV/Episode.cs +++ b/MediaBrowser.Controller/Entities/TV/Episode.cs @@ -117,7 +117,7 @@ namespace MediaBrowser.Controller.Entities.TV /// Gets the user data key. /// /// System.String. - public override string GetUserDataKey() + protected override string CreateUserDataKey() { var series = Series; @@ -126,7 +126,7 @@ namespace MediaBrowser.Controller.Entities.TV return series.GetUserDataKey() + ParentIndexNumber.Value.ToString("000") + IndexNumber.Value.ToString("000"); } - return base.GetUserDataKey(); + return base.CreateUserDataKey(); } /// diff --git a/MediaBrowser.Controller/Entities/TV/Season.cs b/MediaBrowser.Controller/Entities/TV/Season.cs index 54db12b6f8..61d0aec607 100644 --- a/MediaBrowser.Controller/Entities/TV/Season.cs +++ b/MediaBrowser.Controller/Entities/TV/Season.cs @@ -92,7 +92,7 @@ namespace MediaBrowser.Controller.Entities.TV /// Gets the user data key. /// /// System.String. - public override string GetUserDataKey() + protected override string CreateUserDataKey() { if (Series != null) { @@ -100,7 +100,7 @@ namespace MediaBrowser.Controller.Entities.TV return Series.GetUserDataKey() + seasonNo.ToString("000"); } - return base.GetUserDataKey(); + return base.CreateUserDataKey(); } /// diff --git a/MediaBrowser.Controller/Entities/TV/Series.cs b/MediaBrowser.Controller/Entities/TV/Series.cs index 55cfffeb26..0ec9121f37 100644 --- a/MediaBrowser.Controller/Entities/TV/Series.cs +++ b/MediaBrowser.Controller/Entities/TV/Series.cs @@ -117,9 +117,9 @@ namespace MediaBrowser.Controller.Entities.TV /// Gets the user data key. /// /// System.String. - public override string GetUserDataKey() + protected override string CreateUserDataKey() { - return this.GetProviderId(MetadataProviders.Tvdb) ?? this.GetProviderId(MetadataProviders.Tvcom) ?? base.GetUserDataKey(); + return this.GetProviderId(MetadataProviders.Tvdb) ?? this.GetProviderId(MetadataProviders.Tvcom) ?? base.CreateUserDataKey(); } /// diff --git a/MediaBrowser.Controller/Entities/Trailer.cs b/MediaBrowser.Controller/Entities/Trailer.cs index 7a1eef8dbb..72e3640f27 100644 --- a/MediaBrowser.Controller/Entities/Trailer.cs +++ b/MediaBrowser.Controller/Entities/Trailer.cs @@ -79,7 +79,7 @@ namespace MediaBrowser.Controller.Entities } } - public override string GetUserDataKey() + protected override string CreateUserDataKey() { var key = this.GetProviderId(MetadataProviders.Imdb) ?? this.GetProviderId(MetadataProviders.Tmdb); @@ -96,7 +96,7 @@ namespace MediaBrowser.Controller.Entities return key; } - return base.GetUserDataKey(); + return base.CreateUserDataKey(); } protected override bool GetBlockUnratedValue(UserPolicy config) diff --git a/MediaBrowser.Controller/Entities/UserViewBuilder.cs b/MediaBrowser.Controller/Entities/UserViewBuilder.cs index deb85ed6a0..ac8be37d44 100644 --- a/MediaBrowser.Controller/Entities/UserViewBuilder.cs +++ b/MediaBrowser.Controller/Entities/UserViewBuilder.cs @@ -18,6 +18,7 @@ using System.IO; using System.Linq; using System.Threading; using System.Threading.Tasks; +using MoreLinq; namespace MediaBrowser.Controller.Entities { @@ -412,7 +413,19 @@ namespace MediaBrowser.Controller.Entities { if (query.Recursive) { - return GetResult(GetRecursiveChildren(parent, user, new[] { CollectionType.Movies, CollectionType.BoxSets, string.Empty }).Where(i => i is Movie || i is BoxSet), parent, query); + var recursiveItems = GetRecursiveChildren(parent, user, + new[] {CollectionType.Movies, CollectionType.BoxSets, string.Empty}) + .Where(i => i is Movie || i is BoxSet); + + //var collections = _collectionManager.CollapseItemsWithinBoxSets(recursiveItems, user).ToList(); + + //if (collections.Count > 0) + //{ + // recursiveItems.AddRange(_collectionManager.CollapseItemsWithinBoxSets(recursiveItems, user)); + // recursiveItems = recursiveItems.DistinctBy(i => i.Id).ToList(); + //} + + return GetResult(recursiveItems, parent, query); } var list = new List(); @@ -744,10 +757,10 @@ namespace MediaBrowser.Controller.Entities InternalItemsQuery query) where T : BaseItem { - return SortAndFilter(items, queryParent, totalRecordLimit, query, _libraryManager, _userDataManager); + return FilterAndSort(items, queryParent, totalRecordLimit, query, _libraryManager, _userDataManager); } - public static QueryResult SortAndFilter(IEnumerable items, + public static QueryResult FilterAndSort(IEnumerable items, BaseItem queryParent, int? totalRecordLimit, InternalItemsQuery query, diff --git a/MediaBrowser.Controller/Entities/Year.cs b/MediaBrowser.Controller/Entities/Year.cs index 8deb930e8b..11b0ce3d28 100644 --- a/MediaBrowser.Controller/Entities/Year.cs +++ b/MediaBrowser.Controller/Entities/Year.cs @@ -13,7 +13,7 @@ namespace MediaBrowser.Controller.Entities /// Gets the user data key. /// /// System.String. - public override string GetUserDataKey() + protected override string CreateUserDataKey() { return "Year-" + Name; } diff --git a/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs b/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs index f29204689f..5cfdb5dbf5 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs +++ b/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs @@ -12,7 +12,7 @@ namespace MediaBrowser.Controller.LiveTv /// Gets the user data key. /// /// System.String. - public override string GetUserDataKey() + protected override string CreateUserDataKey() { var name = GetClientTypeName(); diff --git a/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs b/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs index b4b9fa77b8..72b4970262 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs +++ b/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs @@ -16,7 +16,7 @@ namespace MediaBrowser.Controller.LiveTv /// Gets the user data key. /// /// System.String. - public override string GetUserDataKey() + protected override string CreateUserDataKey() { return GetClientTypeName() + "-" + Name; } diff --git a/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs b/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs index 74cf950d42..6308a71dc3 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs +++ b/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs @@ -16,7 +16,7 @@ namespace MediaBrowser.Controller.LiveTv /// Gets the user data key. /// /// System.String. - public override string GetUserDataKey() + protected override string CreateUserDataKey() { return GetClientTypeName() + "-" + Name; } diff --git a/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs b/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs index 91edc06c11..098400b502 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs +++ b/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs @@ -12,7 +12,7 @@ namespace MediaBrowser.Controller.LiveTv /// Gets the user data key. /// /// System.String. - public override string GetUserDataKey() + protected override string CreateUserDataKey() { var name = GetClientTypeName(); diff --git a/MediaBrowser.Providers/Manager/MetadataService.cs b/MediaBrowser.Providers/Manager/MetadataService.cs index f55eddfcf1..fc329d64c5 100644 --- a/MediaBrowser.Providers/Manager/MetadataService.cs +++ b/MediaBrowser.Providers/Manager/MetadataService.cs @@ -437,8 +437,7 @@ namespace MediaBrowser.Providers.Manager localProviders.Count == 0 && refreshResult.UpdateType > ItemUpdateType.None) { - // TODO: If the new metadata from above has some blank data, this - // can cause old data to get filled into those empty fields + // TODO: If the new metadata from above has some blank data, this can cause old data to get filled into those empty fields MergeData(item, temp, new List(), false, true); } diff --git a/MediaBrowser.Server.Implementations/Collections/ManualCollectionsFolder.cs b/MediaBrowser.Server.Implementations/Collections/ManualCollectionsFolder.cs index fa4de728b9..bbe37cb506 100644 --- a/MediaBrowser.Server.Implementations/Collections/ManualCollectionsFolder.cs +++ b/MediaBrowser.Server.Implementations/Collections/ManualCollectionsFolder.cs @@ -1,4 +1,5 @@ using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Entities.Movies; using System.Linq; namespace MediaBrowser.Server.Implementations.Collections @@ -14,7 +15,8 @@ namespace MediaBrowser.Server.Implementations.Collections public override bool IsVisible(User user) { return base.IsVisible(user) && GetChildren(user, false) - .Any(); + .OfType() + .Any(i => i.IsVisible(user)); } public override bool IsHidden diff --git a/MediaBrowser.Server.Implementations/FileOrganization/NameUtils.cs b/MediaBrowser.Server.Implementations/FileOrganization/NameUtils.cs index 795be1e2f3..624133d4fb 100644 --- a/MediaBrowser.Server.Implementations/FileOrganization/NameUtils.cs +++ b/MediaBrowser.Server.Implementations/FileOrganization/NameUtils.cs @@ -54,9 +54,6 @@ namespace MediaBrowser.Server.Implementations.FileOrganization private static string GetComparableName(string name) { - // TODO: Improve this - should ignore spaces, periods, underscores, most likely all symbols and - // possibly remove sorting words like "the", "and", etc. - name = RemoveDiacritics(name); name = " " + name + " "; diff --git a/MediaBrowser.Server.Implementations/Library/UserViewManager.cs b/MediaBrowser.Server.Implementations/Library/UserViewManager.cs index bd0f44adc2..d8c5f85c02 100644 --- a/MediaBrowser.Server.Implementations/Library/UserViewManager.cs +++ b/MediaBrowser.Server.Implementations/Library/UserViewManager.cs @@ -88,24 +88,10 @@ namespace MediaBrowser.Server.Implementations.Library list.Add(await GetUserView(CollectionType.Games, string.Empty, cancellationToken).ConfigureAwait(false)); } - if (user.Configuration.DisplayCollectionsView) + if (foldersWithViewTypes.Any(i => string.Equals(i.CollectionType, CollectionType.BoxSets, StringComparison.OrdinalIgnoreCase))) { - bool showCollectionView; - if (_config.Configuration.EnableLegacyCollections) - { - showCollectionView = folders - .Except(standaloneFolders) - .SelectMany(i => i.GetRecursiveChildren(user, false)).OfType().Any(); - } - else - { - showCollectionView = _collectionManager.GetCollections(user).Any(); - } - - if (showCollectionView) - { - list.Add(await GetUserView(CollectionType.BoxSets, string.Empty, cancellationToken).ConfigureAwait(false)); - } + //list.Add(_collectionManager.GetCollectionsFolder(user.Id.ToString("N"))); + list.Add(await GetUserView(CollectionType.BoxSets, string.Empty, cancellationToken).ConfigureAwait(false)); } if (foldersWithViewTypes.Any(i => string.Equals(i.CollectionType, CollectionType.Playlists, StringComparison.OrdinalIgnoreCase))) diff --git a/MediaBrowser.Server.Implementations/Localization/Server/server.json b/MediaBrowser.Server.Implementations/Localization/Server/server.json index 34a0b327d3..15bc624123 100644 --- a/MediaBrowser.Server.Implementations/Localization/Server/server.json +++ b/MediaBrowser.Server.Implementations/Localization/Server/server.json @@ -55,6 +55,8 @@ "HeaderAudio": "Audio", "HeaderVideo": "Video", "HeaderPaths": "Paths", + "HeaderSyncRequiresSupporterMembership": "Sync Requires a Supporter Membership", + "HeaderEnjoyDayTrial": "Enjoy a 14 Day Free Trial", "LabelSyncTempPath": "Temporary file path:", "LabelSyncTempPathHelp": "Specify a custom sync working folder. Converted media created during the sync process will be stored here.", "LabelCustomCertificatePath": "Custom certificate path:", diff --git a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj index e95bd6503b..30384d1ffc 100644 --- a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj +++ b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj @@ -306,6 +306,7 @@ + diff --git a/MediaBrowser.Server.Implementations/Sync/SyncJobProcessor.cs b/MediaBrowser.Server.Implementations/Sync/SyncJobProcessor.cs index 716584084c..b926ee3388 100644 --- a/MediaBrowser.Server.Implementations/Sync/SyncJobProcessor.cs +++ b/MediaBrowser.Server.Implementations/Sync/SyncJobProcessor.cs @@ -90,7 +90,7 @@ namespace MediaBrowser.Server.Implementations.Sync continue; } - var index = jobItems.Count == 0 ? + var index = jobItems.Count == 0 ? 0 : (jobItems.Select(i => i.JobItemIndex).Max() + 1); @@ -348,10 +348,20 @@ namespace MediaBrowser.Server.Implementations.Sync private void CleanDeadSyncFiles() { // TODO + // Clean files in sync temp folder that are not linked to any sync jobs } public async Task SyncJobItems(SyncJobItem[] items, bool enableConversion, IProgress progress, CancellationToken cancellationToken) { + if (items.Length > 0) + { + if (!SyncRegistrationInfo.Instance.IsRegistered) + { + _logger.Debug("Cancelling sync job processing. Please obtain a supporter membership."); + return; + } + } + var numComplete = 0; foreach (var item in items) diff --git a/MediaBrowser.Server.Implementations/Sync/SyncRegistrationInfo.cs b/MediaBrowser.Server.Implementations/Sync/SyncRegistrationInfo.cs new file mode 100644 index 0000000000..40b84b1c21 --- /dev/null +++ b/MediaBrowser.Server.Implementations/Sync/SyncRegistrationInfo.cs @@ -0,0 +1,31 @@ +using MediaBrowser.Common.Security; +using System.Threading.Tasks; + +namespace MediaBrowser.Server.Implementations.Sync +{ + public class SyncRegistrationInfo : IRequiresRegistration + { + private readonly ISecurityManager _securityManager; + + public static SyncRegistrationInfo Instance; + + public SyncRegistrationInfo(ISecurityManager securityManager) + { + _securityManager = securityManager; + Instance = this; + } + + private bool _registered; + public bool IsRegistered + { + get { return _registered; } + } + + public async Task LoadRegistrationInfoAsync() + { + var info = await _securityManager.GetRegistrationStatus("sync").ConfigureAwait(false); + + _registered = info.IsValid; + } + } +} diff --git a/Nuget/MediaBrowser.Common.Internal.nuspec b/Nuget/MediaBrowser.Common.Internal.nuspec index 6de8801790..1a7dc626a3 100644 --- a/Nuget/MediaBrowser.Common.Internal.nuspec +++ b/Nuget/MediaBrowser.Common.Internal.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common.Internal - 3.0.545 + 3.0.546 MediaBrowser.Common.Internal Luke ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains common components shared by Media Browser Theater and Media Browser Server. Not intended for plugin developer consumption. Copyright © Media Browser 2013 - + diff --git a/Nuget/MediaBrowser.Common.nuspec b/Nuget/MediaBrowser.Common.nuspec index 94445107e6..3eb6621b31 100644 --- a/Nuget/MediaBrowser.Common.nuspec +++ b/Nuget/MediaBrowser.Common.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common - 3.0.545 + 3.0.546 MediaBrowser.Common Media Browser Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Model.Signed.nuspec b/Nuget/MediaBrowser.Model.Signed.nuspec index c441d3b636..f73b375a2f 100644 --- a/Nuget/MediaBrowser.Model.Signed.nuspec +++ b/Nuget/MediaBrowser.Model.Signed.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Model.Signed - 3.0.545 + 3.0.546 MediaBrowser.Model - Signed Edition Media Browser Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Server.Core.nuspec b/Nuget/MediaBrowser.Server.Core.nuspec index 5409d970d5..451a376540 100644 --- a/Nuget/MediaBrowser.Server.Core.nuspec +++ b/Nuget/MediaBrowser.Server.Core.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Server.Core - 3.0.545 + 3.0.546 Media Browser.Server.Core Media Browser Team ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains core components required to build plugins for Media Browser Server. Copyright © Media Browser 2013 - + -- cgit v1.2.3