From 2353dc1aeedd13e1b604d4308b7ff551726bc455 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 29 Jan 2014 15:30:26 -0500 Subject: [PATCH 1/6] added realtime monitor setting --- .../Configuration/ServerConfiguration.cs | 4 ++++ .../FileOrganization/TvFolderOrganizer.cs | 10 ++++++++-- .../IO/LibraryMonitor.cs | 17 +++++++++++++++-- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/MediaBrowser.Model/Configuration/ServerConfiguration.cs b/MediaBrowser.Model/Configuration/ServerConfiguration.cs index 923c5ab748..4e981fa3e5 100644 --- a/MediaBrowser.Model/Configuration/ServerConfiguration.cs +++ b/MediaBrowser.Model/Configuration/ServerConfiguration.cs @@ -227,6 +227,8 @@ namespace MediaBrowser.Model.Configuration public TvFileOrganizationOptions TvFileOrganizationOptions { get; set; } public LiveTvOptions LiveTvOptions { get; set; } + public bool EnableRealtimeMonitor { get; set; } + /// /// Initializes a new instance of the class. /// @@ -294,6 +296,8 @@ namespace MediaBrowser.Model.Configuration LiveTvOptions = new LiveTvOptions(); TvFileOrganizationOptions = new TvFileOrganizationOptions(); + + EnableRealtimeMonitor = true; } } diff --git a/MediaBrowser.Server.Implementations/FileOrganization/TvFolderOrganizer.cs b/MediaBrowser.Server.Implementations/FileOrganization/TvFolderOrganizer.cs index 24f21e3398..85b45cf2c7 100644 --- a/MediaBrowser.Server.Implementations/FileOrganization/TvFolderOrganizer.cs +++ b/MediaBrowser.Server.Implementations/FileOrganization/TvFolderOrganizer.cs @@ -79,9 +79,15 @@ namespace MediaBrowser.Server.Implementations.FileOrganization foreach (var path in watchLocations) { - if (options.LeftOverFileExtensionsToDelete.Length > 0) + var deleteExtensions = options.LeftOverFileExtensionsToDelete + .Select(i => i.Trim().TrimStart('.')) + .Where(i => !string.IsNullOrEmpty(i)) + .Select(i => "." + i) + .ToList(); + + if (deleteExtensions.Count > 0) { - DeleteLeftOverFiles(path, options.LeftOverFileExtensionsToDelete); + DeleteLeftOverFiles(path, deleteExtensions); } if (options.DeleteEmptyFolders) diff --git a/MediaBrowser.Server.Implementations/IO/LibraryMonitor.cs b/MediaBrowser.Server.Implementations/IO/LibraryMonitor.cs index 0716a3d83f..58141902ed 100644 --- a/MediaBrowser.Server.Implementations/IO/LibraryMonitor.cs +++ b/MediaBrowser.Server.Implementations/IO/LibraryMonitor.cs @@ -129,15 +129,28 @@ namespace MediaBrowser.Server.Implementations.IO /// The source of the event. /// The instance containing the event data. void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e) + { + Restart(); + } + + private void Restart() { Stop(); Start(); } + public void Start() + { + if (ConfigurationManager.Configuration.EnableRealtimeMonitor) + { + StartInternal(); + } + } + /// /// Starts this instance. /// - public void Start() + private void StartInternal() { LibraryManager.ItemAdded += LibraryManager_ItemAdded; LibraryManager.ItemRemoved += LibraryManager_ItemRemoved; @@ -359,7 +372,7 @@ namespace MediaBrowser.Server.Implementations.IO { throw new ArgumentNullException("path"); } - + var filename = Path.GetFileName(path); // Ignore certain files From d71e14ec9f97bce6102e7e7da55f31d343528e80 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 29 Jan 2014 15:57:17 -0500 Subject: [PATCH 2/6] added path mapping page stub --- MediaBrowser.WebDashboard/Api/DashboardService.cs | 1 + MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/MediaBrowser.WebDashboard/Api/DashboardService.cs b/MediaBrowser.WebDashboard/Api/DashboardService.cs index ef1504ed5c..c308e76560 100644 --- a/MediaBrowser.WebDashboard/Api/DashboardService.cs +++ b/MediaBrowser.WebDashboard/Api/DashboardService.cs @@ -495,6 +495,7 @@ namespace MediaBrowser.WebDashboard.Api "itemdetailpage.js", "itemgallery.js", "itemlistpage.js", + "librarypathmapping.js", "librarysettings.js", "livetvchannel.js", "livetvchannels.js", diff --git a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj index f1cc75864c..3a72d469a7 100644 --- a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj +++ b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj @@ -175,6 +175,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest @@ -436,6 +439,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest From ca0e13dd239e3966a083c304ce931e006c5ec4a2 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 29 Jan 2014 16:54:40 -0500 Subject: [PATCH 3/6] support turning off subtitles --- MediaBrowser.Server.Implementations/HttpServer/LoggerUtils.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/MediaBrowser.Server.Implementations/HttpServer/LoggerUtils.cs b/MediaBrowser.Server.Implementations/HttpServer/LoggerUtils.cs index cbb2c5642d..7ae740508b 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/LoggerUtils.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/LoggerUtils.cs @@ -18,7 +18,9 @@ namespace MediaBrowser.Server.Implementations.HttpServer { var log = new StringBuilder(); - log.AppendLine("Ip: " + request.RemoteEndPoint + ". Headers: " + string.Join(",", request.Headers.AllKeys.Select(k => k + "=" + request.Headers[k]))); + var headers = string.Join(",", request.Headers.AllKeys.Where(i => !string.Equals(i, "cookie", StringComparison.OrdinalIgnoreCase) && !string.Equals(i, "Referer", StringComparison.OrdinalIgnoreCase)).Select(k => k + "=" + request.Headers[k])); + + log.AppendLine("Ip: " + request.RemoteEndPoint + ". Headers: " + headers); var type = request.IsWebSocketRequest ? "Web Socket" : "HTTP " + request.HttpMethod; From fb69d5b76d9f43979037ee2bb7469917c6e82633 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 29 Jan 2014 17:26:14 -0500 Subject: [PATCH 4/6] fixes #698 - Support xbmc extras folder for movie specials --- MediaBrowser.Controller/Entities/Movies/Movie.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MediaBrowser.Controller/Entities/Movies/Movie.cs b/MediaBrowser.Controller/Entities/Movies/Movie.cs index dbbe5ce018..a4e8853376 100644 --- a/MediaBrowser.Controller/Entities/Movies/Movie.cs +++ b/MediaBrowser.Controller/Entities/Movies/Movie.cs @@ -159,7 +159,8 @@ namespace MediaBrowser.Controller.Entities.Movies try { - folder = ResolveArgs.GetFileSystemEntryByName("specials"); + folder = ResolveArgs.GetFileSystemEntryByName("extras") ?? + ResolveArgs.GetFileSystemEntryByName("specials"); } catch (IOException ex) { From d39f8a11614de8850de9a9b433c1a4f190ccadc9 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 29 Jan 2014 19:18:05 -0500 Subject: [PATCH 5/6] Added is running as service to IServerApplicationHost --- MediaBrowser.Controller/IServerApplicationHost.cs | 6 ++++++ MediaBrowser.Model/System/SystemInfo.cs | 8 +++++++- MediaBrowser.ServerApplication/ApplicationHost.cs | 13 ++++++++++--- MediaBrowser.ServerApplication/MainStartup.cs | 2 +- 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/MediaBrowser.Controller/IServerApplicationHost.cs b/MediaBrowser.Controller/IServerApplicationHost.cs index 5554ced376..38a3cc9236 100644 --- a/MediaBrowser.Controller/IServerApplicationHost.cs +++ b/MediaBrowser.Controller/IServerApplicationHost.cs @@ -20,6 +20,12 @@ namespace MediaBrowser.Controller /// The name of the web application. string WebApplicationName { get; } + /// + /// Gets a value indicating whether this instance is running as service. + /// + /// true if this instance is running as service; otherwise, false. + bool IsRunningAsService { get; } + /// /// Gets a value indicating whether [supports automatic run at startup]. /// diff --git a/MediaBrowser.Model/System/SystemInfo.cs b/MediaBrowser.Model/System/SystemInfo.cs index 3082e80b63..24707b29b3 100644 --- a/MediaBrowser.Model/System/SystemInfo.cs +++ b/MediaBrowser.Model/System/SystemInfo.cs @@ -19,7 +19,13 @@ namespace MediaBrowser.Model.System /// /// The operating sytem. public string OperatingSystem { get; set; } - + + /// + /// Gets or sets a value indicating whether this instance is running as service. + /// + /// true if this instance is running as service; otherwise, false. + public bool IsRunningAsService { get; set; } + /// /// Gets or sets the mac address. /// diff --git a/MediaBrowser.ServerApplication/ApplicationHost.cs b/MediaBrowser.ServerApplication/ApplicationHost.cs index 4b15ca8d03..91019c0a89 100644 --- a/MediaBrowser.ServerApplication/ApplicationHost.cs +++ b/MediaBrowser.ServerApplication/ApplicationHost.cs @@ -179,10 +179,16 @@ namespace MediaBrowser.ServerApplication /// /// The application paths. /// The log manager. - public ApplicationHost(ServerApplicationPaths applicationPaths, ILogManager logManager) + public ApplicationHost(ServerApplicationPaths applicationPaths, ILogManager logManager, bool isRunningAsService) : base(applicationPaths, logManager) { + _isRunningAsService = isRunningAsService; + } + private readonly bool _isRunningAsService; + public bool IsRunningAsService + { + get { return _isRunningAsService; } } /// @@ -431,7 +437,7 @@ namespace MediaBrowser.ServerApplication await ItemRepository.Initialize().ConfigureAwait(false); await ProviderRepository.Initialize().ConfigureAwait(false); - + ((LibraryManager)LibraryManager).ItemRepository = ItemRepository; } @@ -687,7 +693,8 @@ namespace MediaBrowser.ServerApplication WanAddress = GetWanAddress(), HasUpdateAvailable = _hasUpdateAvailable, SupportsAutoRunAtStartup = SupportsAutoRunAtStartup, - TranscodingTempPath = ApplicationPaths.TranscodingTempPath + TranscodingTempPath = ApplicationPaths.TranscodingTempPath, + IsRunningAsService = IsRunningAsService }; } diff --git a/MediaBrowser.ServerApplication/MainStartup.cs b/MediaBrowser.ServerApplication/MainStartup.cs index 3021363213..f34c3921d9 100644 --- a/MediaBrowser.ServerApplication/MainStartup.cs +++ b/MediaBrowser.ServerApplication/MainStartup.cs @@ -212,7 +212,7 @@ namespace MediaBrowser.ServerApplication SystemEvents.SessionEnding += SystemEvents_SessionEnding; SystemEvents.SessionSwitch += SystemEvents_SessionSwitch; - _appHost = new ApplicationHost(appPaths, logManager); + _appHost = new ApplicationHost(appPaths, logManager, runService); _app = new App(_appHost, _appHost.LogManager.GetLogger("App"), runService); From 1f6918117c2a7542e066ffb5ac09051a698bb136 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 29 Jan 2014 19:22:59 -0500 Subject: [PATCH 6/6] Added isservice to reported statistics --- .../BaseApplicationHost.cs | 6 ++++++ .../ScheduledTasks/Tasks/StatisticsTask.cs | 17 ++++++++++++----- MediaBrowser.Common/IApplicationHost.cs | 6 ++++++ .../IServerApplicationHost.cs | 6 ------ .../ApplicationHost.cs | 2 +- 5 files changed, 25 insertions(+), 12 deletions(-) diff --git a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs index 506774b4a5..e2ef4864d0 100644 --- a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs +++ b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs @@ -171,6 +171,12 @@ namespace MediaBrowser.Common.Implementations /// The name. public abstract string Name { get; } + /// + /// Gets a value indicating whether this instance is running as service. + /// + /// true if this instance is running as service; otherwise, false. + public abstract bool IsRunningAsService { get; } + /// /// Initializes a new instance of the class. /// diff --git a/MediaBrowser.Common.Implementations/ScheduledTasks/Tasks/StatisticsTask.cs b/MediaBrowser.Common.Implementations/ScheduledTasks/Tasks/StatisticsTask.cs index 46f3fd4a9f..9c0fe165d4 100644 --- a/MediaBrowser.Common.Implementations/ScheduledTasks/Tasks/StatisticsTask.cs +++ b/MediaBrowser.Common.Implementations/ScheduledTasks/Tasks/StatisticsTask.cs @@ -1,6 +1,4 @@ -using System.Reflection; -using MediaBrowser.Common.Configuration; -using MediaBrowser.Common.Net; +using MediaBrowser.Common.Net; using MediaBrowser.Common.ScheduledTasks; using MediaBrowser.Model.Logging; using System; @@ -74,7 +72,16 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks.Tasks progress.Report(0); var mac = NetworkManager.GetMacAddress(); - var data = new Dictionary { { "feature", ApplicationHost.Name }, { "mac", mac }, { "ver", ApplicationHost.ApplicationVersion.ToString() }, { "platform", Environment.OSVersion.VersionString } }; + + var data = new Dictionary + { + { "feature", ApplicationHost.Name }, + { "mac", mac }, + { "ver", ApplicationHost.ApplicationVersion.ToString() }, + { "platform", Environment.OSVersion.VersionString }, + { "isservice", ApplicationHost.IsRunningAsService.ToString().ToLower()} + }; + await HttpClient.Post(Constants.Constants.MbAdminUrl + "service/registration/ping", data, CancellationToken.None).ConfigureAwait(false); progress.Report(100); @@ -86,7 +93,7 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks.Tasks /// The name. public string Name { - get { return "Collect stats"; } + get { return "Collect anonymous usage stats"; } } /// diff --git a/MediaBrowser.Common/IApplicationHost.cs b/MediaBrowser.Common/IApplicationHost.cs index 8cd1252c74..3d5f3c96f9 100644 --- a/MediaBrowser.Common/IApplicationHost.cs +++ b/MediaBrowser.Common/IApplicationHost.cs @@ -24,6 +24,12 @@ namespace MediaBrowser.Common /// event EventHandler> ApplicationUpdated; + /// + /// Gets a value indicating whether this instance is running as service. + /// + /// true if this instance is running as service; otherwise, false. + bool IsRunningAsService { get; } + /// /// Gets or sets a value indicating whether this instance has pending kernel reload. /// diff --git a/MediaBrowser.Controller/IServerApplicationHost.cs b/MediaBrowser.Controller/IServerApplicationHost.cs index 38a3cc9236..5554ced376 100644 --- a/MediaBrowser.Controller/IServerApplicationHost.cs +++ b/MediaBrowser.Controller/IServerApplicationHost.cs @@ -20,12 +20,6 @@ namespace MediaBrowser.Controller /// The name of the web application. string WebApplicationName { get; } - /// - /// Gets a value indicating whether this instance is running as service. - /// - /// true if this instance is running as service; otherwise, false. - bool IsRunningAsService { get; } - /// /// Gets a value indicating whether [supports automatic run at startup]. /// diff --git a/MediaBrowser.ServerApplication/ApplicationHost.cs b/MediaBrowser.ServerApplication/ApplicationHost.cs index 91019c0a89..0609e80ef9 100644 --- a/MediaBrowser.ServerApplication/ApplicationHost.cs +++ b/MediaBrowser.ServerApplication/ApplicationHost.cs @@ -186,7 +186,7 @@ namespace MediaBrowser.ServerApplication } private readonly bool _isRunningAsService; - public bool IsRunningAsService + public override bool IsRunningAsService { get { return _isRunningAsService; } }