aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.ServerApplication
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.ServerApplication')
-rw-r--r--MediaBrowser.ServerApplication/ApplicationHost.cs5
-rw-r--r--MediaBrowser.ServerApplication/EntryPoints/WanAddressEntryPoint.cs56
-rw-r--r--MediaBrowser.ServerApplication/LibraryExplorer.xaml.cs8
-rw-r--r--MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj1
4 files changed, 64 insertions, 6 deletions
diff --git a/MediaBrowser.ServerApplication/ApplicationHost.cs b/MediaBrowser.ServerApplication/ApplicationHost.cs
index 6058c59581..46a7430b02 100644
--- a/MediaBrowser.ServerApplication/ApplicationHost.cs
+++ b/MediaBrowser.ServerApplication/ApplicationHost.cs
@@ -28,7 +28,6 @@ using MediaBrowser.Controller.Session;
using MediaBrowser.Controller.Sorting;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.MediaInfo;
-using MediaBrowser.Model.Serialization;
using MediaBrowser.Model.System;
using MediaBrowser.Model.Updates;
using MediaBrowser.Providers;
@@ -49,6 +48,7 @@ using MediaBrowser.Server.Implementations.Providers;
using MediaBrowser.Server.Implementations.ServerManager;
using MediaBrowser.Server.Implementations.Session;
using MediaBrowser.Server.Implementations.WebSocket;
+using MediaBrowser.ServerApplication.EntryPoints;
using MediaBrowser.ServerApplication.FFMpeg;
using MediaBrowser.ServerApplication.IO;
using MediaBrowser.ServerApplication.Native;
@@ -616,7 +616,8 @@ namespace MediaBrowser.ServerApplication
HttpServerPortNumber = ServerConfigurationManager.Configuration.HttpServerPortNumber,
OperatingSystem = Environment.OSVersion.ToString(),
CanSelfRestart = CanSelfRestart,
- CanSelfUpdate = CanSelfUpdate
+ CanSelfUpdate = CanSelfUpdate,
+ WanAddress = WanAddressEntryPoint.WanAddress
};
}
diff --git a/MediaBrowser.ServerApplication/EntryPoints/WanAddressEntryPoint.cs b/MediaBrowser.ServerApplication/EntryPoints/WanAddressEntryPoint.cs
new file mode 100644
index 0000000000..44819b3903
--- /dev/null
+++ b/MediaBrowser.ServerApplication/EntryPoints/WanAddressEntryPoint.cs
@@ -0,0 +1,56 @@
+using MediaBrowser.Common.Net;
+using MediaBrowser.Controller.Plugins;
+using System;
+using System.IO;
+using System.Threading;
+
+namespace MediaBrowser.ServerApplication.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 (Exception ex)
+ {
+ var b = true;
+ }
+ }
+
+ public void Dispose()
+ {
+ if (_timer != null)
+ {
+ _timer.Dispose();
+ _timer = null;
+ }
+ }
+ }
+}
diff --git a/MediaBrowser.ServerApplication/LibraryExplorer.xaml.cs b/MediaBrowser.ServerApplication/LibraryExplorer.xaml.cs
index a3d4706893..c133e09571 100644
--- a/MediaBrowser.ServerApplication/LibraryExplorer.xaml.cs
+++ b/MediaBrowser.ServerApplication/LibraryExplorer.xaml.cs
@@ -88,7 +88,7 @@ namespace MediaBrowser.ServerApplication
Cursor = Cursors.Wait;
await Task.Run(() =>
{
- IEnumerable<BaseItem> children = CurrentUser.Name == "Physical" ? _libraryManager.RootFolder.Children : _libraryManager.RootFolder.GetChildren(CurrentUser, true);
+ IEnumerable<BaseItem> children = CurrentUser.Name == "Physical" ? new[] { _libraryManager.RootFolder } : _libraryManager.RootFolder.GetChildren(CurrentUser, true);
children = OrderByName(children, CurrentUser);
foreach (Folder folder in children)
@@ -237,9 +237,9 @@ namespace MediaBrowser.ServerApplication
{
previews.Add(new PreviewItem(item.GetImage(ImageType.Thumb), "Thumb"));
}
- previews.AddRange(
- item.BackdropImagePaths.Select(
- image => new PreviewItem(image, "Backdrop")));
+ previews.AddRange(
+ item.BackdropImagePaths.Select(
+ image => new PreviewItem(image, "Backdrop")));
});
lstPreviews.ItemsSource = previews;
lstPreviews.Items.Refresh();
diff --git a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj
index e02bb1d69a..38e082f12e 100644
--- a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj
+++ b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj
@@ -162,6 +162,7 @@
</Compile>
<Compile Include="EntryPoints\ResourceEntryPoint.cs" />
<Compile Include="EntryPoints\StartupWizard.cs" />
+ <Compile Include="EntryPoints\WanAddressEntryPoint.cs" />
<Compile Include="FFMpeg\FFMpegDownloadInfo.cs" />
<Compile Include="FFMpeg\FFMpegInfo.cs" />
<Compile Include="IO\FileSystemFactory.cs" />