diff options
Diffstat (limited to 'MediaBrowser.Server.Implementations/EntryPoints')
5 files changed, 54 insertions, 83 deletions
diff --git a/MediaBrowser.Server.Implementations/EntryPoints/ActivityLogEntryPoint.cs b/MediaBrowser.Server.Implementations/EntryPoints/ActivityLogEntryPoint.cs index 0bd772a56..fb1010f1b 100644 --- a/MediaBrowser.Server.Implementations/EntryPoints/ActivityLogEntryPoint.cs +++ b/MediaBrowser.Server.Implementations/EntryPoints/ActivityLogEntryPoint.cs @@ -117,6 +117,13 @@ namespace MediaBrowser.Server.Implementations.EntryPoints return; } + var themeMedia = item as IThemeMedia; + if (themeMedia != null && themeMedia.IsThemeMedia) + { + // Don't report theme song or local trailer playback + return; + } + if (e.Users.Count == 0) { return; @@ -142,6 +149,13 @@ namespace MediaBrowser.Server.Implementations.EntryPoints return; } + var themeMedia = item as IThemeMedia; + if (themeMedia != null && themeMedia.IsThemeMedia) + { + // Don't report theme song or local trailer playback + return; + } + if (e.Users.Count == 0) { return; diff --git a/MediaBrowser.Server.Implementations/EntryPoints/ExternalPortForwarding.cs b/MediaBrowser.Server.Implementations/EntryPoints/ExternalPortForwarding.cs index 42191a270..2d050d4a7 100644 --- a/MediaBrowser.Server.Implementations/EntryPoints/ExternalPortForwarding.cs +++ b/MediaBrowser.Server.Implementations/EntryPoints/ExternalPortForwarding.cs @@ -61,7 +61,7 @@ namespace MediaBrowser.Server.Implementations.EntryPoints // 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; + NatUtility.DeviceLost += NatUtility_DeviceLost; // it is hard to say what one should do when an unhandled exception is raised @@ -71,7 +71,7 @@ namespace MediaBrowser.Server.Implementations.EntryPoints _isStarted = true; - _timer = new Timer(s => _createdRules = new List<string>(), null, TimeSpan.FromHours(6), TimeSpan.FromHours(6)); + _timer = new Timer(s => _createdRules = new List<string>(), null, TimeSpan.FromMinutes(10), TimeSpan.FromMinutes(10)); } } @@ -123,7 +123,7 @@ namespace MediaBrowser.Server.Implementations.EntryPoints if (!_createdRules.Contains(address)) { _createdRules.Add(address); - + var info = _appHost.GetSystemInfo(); CreatePortMap(device, info.HttpServerPortNumber); @@ -141,11 +141,11 @@ namespace MediaBrowser.Server.Implementations.EntryPoints } // As I said before, this method will be never invoked. You can remove it. - //void NatUtility_DeviceLost(object sender, DeviceEventArgs e) - //{ - // var device = e.Device; - // _logger.Debug("NAT device lost: {0}", device.LocalAddress.ToString()); - //} + void NatUtility_DeviceLost(object sender, DeviceEventArgs e) + { + var device = e.Device; + _logger.Debug("NAT device lost: {0}", device.LocalAddress.ToString()); + } public void Dispose() { @@ -167,7 +167,7 @@ namespace MediaBrowser.Server.Implementations.EntryPoints // This is not a significant improvement NatUtility.StopDiscovery(); NatUtility.DeviceFound -= NatUtility_DeviceFound; - //NatUtility.DeviceLost -= NatUtility_DeviceLost; + NatUtility.DeviceLost -= NatUtility_DeviceLost; NatUtility.UnhandledException -= NatUtility_UnhandledException; } // Statements in try-block will no fail because StopDiscovery is a one-line diff --git a/MediaBrowser.Server.Implementations/EntryPoints/Notifications/Notifications.cs b/MediaBrowser.Server.Implementations/EntryPoints/Notifications/Notifications.cs index 6a0bb780c..2d824f36c 100644 --- a/MediaBrowser.Server.Implementations/EntryPoints/Notifications/Notifications.cs +++ b/MediaBrowser.Server.Implementations/EntryPoints/Notifications/Notifications.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Common.Plugins; +using MediaBrowser.Common.Configuration; +using MediaBrowser.Common.Plugins; using MediaBrowser.Common.ScheduledTasks; using MediaBrowser.Common.Updates; using MediaBrowser.Controller; @@ -42,7 +43,9 @@ namespace MediaBrowser.Server.Implementations.EntryPoints.Notifications private Timer LibraryUpdateTimer { get; set; } private readonly object _libraryChangedSyncLock = new object(); - public Notifications(IInstallationManager installationManager, IUserManager userManager, ILogger logger, ITaskManager taskManager, INotificationManager notificationManager, ILibraryManager libraryManager, ISessionManager sessionManager, IServerApplicationHost appHost) + private readonly IConfigurationManager _config; + + public Notifications(IInstallationManager installationManager, IUserManager userManager, ILogger logger, ITaskManager taskManager, INotificationManager notificationManager, ILibraryManager libraryManager, ISessionManager sessionManager, IServerApplicationHost appHost, IConfigurationManager config) { _installationManager = installationManager; _userManager = userManager; @@ -52,6 +55,7 @@ namespace MediaBrowser.Server.Implementations.EntryPoints.Notifications _libraryManager = libraryManager; _sessionManager = sessionManager; _appHost = appHost; + _config = config; } public void Run() @@ -160,20 +164,25 @@ namespace MediaBrowser.Server.Implementations.EntryPoints.Notifications await SendNotification(notification).ConfigureAwait(false); } - void _sessionManager_PlaybackStart(object sender, PlaybackProgressEventArgs e) - { - var item = e.MediaInfo; + private NotificationOptions GetOptions() + { + return _config.GetConfiguration<NotificationOptions>("notifications"); + } - if (item == null) - { - _logger.Warn("PlaybackStart reported with null media info."); - return; - } + void _sessionManager_PlaybackStart(object sender, PlaybackProgressEventArgs e) + { + var item = e.MediaInfo; - var type = GetPlaybackNotificationType(item.MediaType); + if (item == null) + { + _logger.Warn("PlaybackStart reported with null media info."); + return; + } - SendPlaybackNotification(type, e); - } + var type = GetPlaybackNotificationType(item.MediaType); + + SendPlaybackNotification(type, e); + } void _sessionManager_PlaybackStopped(object sender, PlaybackStopEventArgs e) { @@ -194,20 +203,24 @@ namespace MediaBrowser.Server.Implementations.EntryPoints.Notifications { var user = e.Users.FirstOrDefault(); + if (user != null && !GetOptions().IsEnabledToMonitorUser(type, user.Id.ToString("N"))) + { + return; + } + var item = e.MediaInfo; + var themeMedia = item as IThemeMedia; - if (e.Item != null && e.Item.Parent == null) + if (themeMedia != null && themeMedia.IsThemeMedia) { // Don't report theme song or local trailer playback - // TODO: This will also cause movie specials to not be reported return; } + var notification = new NotificationRequest { - NotificationType = type, - - ExcludeUserIds = e.Users.Select(i => i.Id.ToString("N")).ToList() + NotificationType = type }; notification.Variables["ItemName"] = item.Name; diff --git a/MediaBrowser.Server.Implementations/EntryPoints/UsageEntryPoint.cs b/MediaBrowser.Server.Implementations/EntryPoints/UsageEntryPoint.cs index af3fde34b..de53201c9 100644 --- a/MediaBrowser.Server.Implementations/EntryPoints/UsageEntryPoint.cs +++ b/MediaBrowser.Server.Implementations/EntryPoints/UsageEntryPoint.cs @@ -26,7 +26,6 @@ namespace MediaBrowser.Server.Implementations.EntryPoints private Timer _timer; private readonly TimeSpan _frequency = TimeSpan.FromHours(24); - private const string DefaultDeviceVersion = "Unknown version"; private readonly ConcurrentDictionary<Guid, ClientInfo> _apps = new ConcurrentDictionary<Guid, ClientInfo>(); public UsageEntryPoint(ILogger logger, IApplicationHost applicationHost, INetworkManager networkManager, IHttpClient httpClient, ISessionManager sessionManager) diff --git a/MediaBrowser.Server.Implementations/EntryPoints/WanAddressEntryPoint.cs b/MediaBrowser.Server.Implementations/EntryPoints/WanAddressEntryPoint.cs deleted file mode 100644 index 2f6643588..000000000 --- a/MediaBrowser.Server.Implementations/EntryPoints/WanAddressEntryPoint.cs +++ /dev/null @@ -1,55 +0,0 @@ -using MediaBrowser.Common.Net; -using MediaBrowser.Controller.Plugins; -using System; -using System.IO; -using System.Threading; - -namespace MediaBrowser.Server.Implementations.EntryPoints -{ - public class WanAddressEntryPoint : IServerEntryPoint - { - public static string WanAddress; - private Timer _timer; - private readonly IHttpClient _httpClient; - - public WanAddressEntryPoint(IHttpClient httpClient) - { - _httpClient = httpClient; - } - - public void Run() - { - _timer = new Timer(TimerCallback, null, TimeSpan.FromMinutes(1), TimeSpan.FromHours(24)); - } - - private async void TimerCallback(object state) - { - try - { - using (var stream = await _httpClient.Get(new HttpRequestOptions - { - Url = "http://bot.whatismyipaddress.com/" - - }).ConfigureAwait(false)) - { - using (var reader = new StreamReader(stream)) - { - WanAddress = await reader.ReadToEndAsync().ConfigureAwait(false); - } - } - } - catch - { - } - } - - public void Dispose() - { - if (_timer != null) - { - _timer.Dispose(); - _timer = null; - } - } - } -} |
