mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-10 07:22:35 -07:00
The landing page now works for emby #435
This commit is contained in:
parent
febdaa0a15
commit
12ff7378ba
5 changed files with 123 additions and 12 deletions
|
@ -14,5 +14,6 @@ namespace Ombi.Api.Interfaces
|
||||||
EmbyItemContainer<EmbyLibrary> ViewLibrary(string apiKey, string userId, Uri baseUri);
|
EmbyItemContainer<EmbyLibrary> ViewLibrary(string apiKey, string userId, Uri baseUri);
|
||||||
EmbyInformation GetInformation(string mediaId, EmbyMediaType type, string apiKey, string userId, Uri baseUri);
|
EmbyInformation GetInformation(string mediaId, EmbyMediaType type, string apiKey, string userId, Uri baseUri);
|
||||||
EmbyUser LogIn(string username, string password, string apiKey, Uri baseUri);
|
EmbyUser LogIn(string username, string password, string apiKey, Uri baseUri);
|
||||||
|
EmbySystemInfo GetSystemInformation(string apiKey, Uri baseUrl);
|
||||||
}
|
}
|
||||||
}
|
}
|
63
Ombi.Api.Models/Emby/EmbySystemInfo.cs
Normal file
63
Ombi.Api.Models/Emby/EmbySystemInfo.cs
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
#region Copyright
|
||||||
|
// /************************************************************************
|
||||||
|
// Copyright (c) 2017 Jamie Rees
|
||||||
|
// File: EmbySystemInfo.cs
|
||||||
|
// Created By: Jamie Rees
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
// a copy of this software and associated documentation files (the
|
||||||
|
// "Software"), to deal in the Software without restriction, including
|
||||||
|
// without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
// permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
// the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be
|
||||||
|
// included in all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
// ************************************************************************/
|
||||||
|
#endregion
|
||||||
|
namespace Ombi.Api.Models.Emby
|
||||||
|
{
|
||||||
|
public class EmbySystemInfo
|
||||||
|
{
|
||||||
|
public string SystemUpdateLevel { get; set; }
|
||||||
|
public string OperatingSystemDisplayName { get; set; }
|
||||||
|
public bool SupportsRunningAsService { get; set; }
|
||||||
|
public string MacAddress { get; set; }
|
||||||
|
public bool HasPendingRestart { get; set; }
|
||||||
|
public bool SupportsLibraryMonitor { get; set; }
|
||||||
|
public object[] InProgressInstallations { get; set; }
|
||||||
|
public int WebSocketPortNumber { get; set; }
|
||||||
|
public object[] CompletedInstallations { get; set; }
|
||||||
|
public bool CanSelfRestart { get; set; }
|
||||||
|
public bool CanSelfUpdate { get; set; }
|
||||||
|
public object[] FailedPluginAssemblies { get; set; }
|
||||||
|
public string ProgramDataPath { get; set; }
|
||||||
|
public string ItemsByNamePath { get; set; }
|
||||||
|
public string CachePath { get; set; }
|
||||||
|
public string LogPath { get; set; }
|
||||||
|
public string InternalMetadataPath { get; set; }
|
||||||
|
public string TranscodingTempPath { get; set; }
|
||||||
|
public int HttpServerPortNumber { get; set; }
|
||||||
|
public bool SupportsHttps { get; set; }
|
||||||
|
public int HttpsPortNumber { get; set; }
|
||||||
|
public bool HasUpdateAvailable { get; set; }
|
||||||
|
public bool SupportsAutoRunAtStartup { get; set; }
|
||||||
|
public string EncoderLocationType { get; set; }
|
||||||
|
public string SystemArchitecture { get; set; }
|
||||||
|
public string LocalAddress { get; set; }
|
||||||
|
public string WanAddress { get; set; }
|
||||||
|
public string ServerName { get; set; }
|
||||||
|
public string Version { get; set; }
|
||||||
|
public string OperatingSystem { get; set; }
|
||||||
|
public string Id { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -71,6 +71,7 @@
|
||||||
<Compile Include="Emby\EmbySeriesItem.cs" />
|
<Compile Include="Emby\EmbySeriesItem.cs" />
|
||||||
<Compile Include="Emby\EmbySeriesstudioinfo.cs" />
|
<Compile Include="Emby\EmbySeriesstudioinfo.cs" />
|
||||||
<Compile Include="Emby\EmbyStudio.cs" />
|
<Compile Include="Emby\EmbyStudio.cs" />
|
||||||
|
<Compile Include="Emby\EmbySystemInfo.cs" />
|
||||||
<Compile Include="Emby\EmbyUser.cs" />
|
<Compile Include="Emby\EmbyUser.cs" />
|
||||||
<Compile Include="Emby\EmbyUserdata.cs" />
|
<Compile Include="Emby\EmbyUserdata.cs" />
|
||||||
<Compile Include="Emby\EmbyMovieInformation.cs" />
|
<Compile Include="Emby\EmbyMovieInformation.cs" />
|
||||||
|
|
|
@ -71,6 +71,26 @@ namespace Ombi.Api
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public EmbySystemInfo GetSystemInformation(string apiKey, Uri baseUrl)
|
||||||
|
{
|
||||||
|
var request = new RestRequest
|
||||||
|
{
|
||||||
|
Resource = "emby/System/Info",
|
||||||
|
Method = Method.GET
|
||||||
|
};
|
||||||
|
|
||||||
|
AddHeaders(request, apiKey);
|
||||||
|
|
||||||
|
var policy = RetryHandler.RetryAndWaitPolicy((exception, timespan) => Log.Error(exception, "Exception when calling GetSystemInformation for Emby, Retrying {0}", timespan), new[] {
|
||||||
|
TimeSpan.FromSeconds (1),
|
||||||
|
TimeSpan.FromSeconds(5)
|
||||||
|
});
|
||||||
|
|
||||||
|
var obj = policy.Execute(() => Api.ExecuteJson<EmbySystemInfo>(request, baseUrl));
|
||||||
|
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
public EmbyItemContainer<EmbyLibrary> ViewLibrary(string apiKey, string userId, Uri baseUri)
|
public EmbyItemContainer<EmbyLibrary> ViewLibrary(string apiKey, string userId, Uri baseUri)
|
||||||
{
|
{
|
||||||
var request = new RestRequest
|
var request = new RestRequest
|
||||||
|
|
|
@ -40,12 +40,15 @@ namespace Ombi.UI.Modules
|
||||||
public class LandingPageModule : BaseModule
|
public class LandingPageModule : BaseModule
|
||||||
{
|
{
|
||||||
public LandingPageModule(ISettingsService<PlexRequestSettings> settingsService, ISettingsService<LandingPageSettings> landing,
|
public LandingPageModule(ISettingsService<PlexRequestSettings> settingsService, ISettingsService<LandingPageSettings> landing,
|
||||||
ISettingsService<PlexSettings> ps, IPlexApi pApi, IResourceLinker linker, ISecurityExtensions security) : base("landing", settingsService, security)
|
ISettingsService<PlexSettings> ps, IPlexApi pApi, IResourceLinker linker, ISecurityExtensions security, ISettingsService<EmbySettings> emby,
|
||||||
|
IEmbyApi embyApi) : base("landing", settingsService, security)
|
||||||
{
|
{
|
||||||
LandingSettings = landing;
|
LandingSettings = landing;
|
||||||
PlexSettings = ps;
|
PlexSettings = ps;
|
||||||
PlexApi = pApi;
|
PlexApi = pApi;
|
||||||
Linker = linker;
|
Linker = linker;
|
||||||
|
EmbySettings = emby;
|
||||||
|
EmbyApi = embyApi;
|
||||||
|
|
||||||
Get["LandingPageIndex","/", true] = async (x, ct) =>
|
Get["LandingPageIndex","/", true] = async (x, ct) =>
|
||||||
{
|
{
|
||||||
|
@ -75,26 +78,49 @@ namespace Ombi.UI.Modules
|
||||||
|
|
||||||
private ISettingsService<LandingPageSettings> LandingSettings { get; }
|
private ISettingsService<LandingPageSettings> LandingSettings { get; }
|
||||||
private ISettingsService<PlexSettings> PlexSettings { get; }
|
private ISettingsService<PlexSettings> PlexSettings { get; }
|
||||||
|
private ISettingsService<EmbySettings> EmbySettings { get; }
|
||||||
private IPlexApi PlexApi { get; }
|
private IPlexApi PlexApi { get; }
|
||||||
|
private IEmbyApi EmbyApi { get; }
|
||||||
private IResourceLinker Linker { get; }
|
private IResourceLinker Linker { get; }
|
||||||
|
|
||||||
private async Task<Response> CheckStatus()
|
private async Task<Response> CheckStatus()
|
||||||
{
|
{
|
||||||
var plexSettings = await PlexSettings.GetSettingsAsync();
|
var plexSettings = await PlexSettings.GetSettingsAsync();
|
||||||
if (string.IsNullOrEmpty(plexSettings.PlexAuthToken) || string.IsNullOrEmpty(plexSettings.Ip))
|
if (plexSettings.Enable)
|
||||||
{
|
{
|
||||||
return Response.AsJson(false);
|
if (string.IsNullOrEmpty(plexSettings.PlexAuthToken) || string.IsNullOrEmpty(plexSettings.Ip))
|
||||||
}
|
{
|
||||||
try
|
return Response.AsJson(false);
|
||||||
{
|
}
|
||||||
var status = PlexApi.GetStatus(plexSettings.PlexAuthToken, plexSettings.FullUri);
|
try
|
||||||
return Response.AsJson(status != null);
|
{
|
||||||
}
|
var status = PlexApi.GetStatus(plexSettings.PlexAuthToken, plexSettings.FullUri);
|
||||||
catch (Exception)
|
return Response.AsJson(status != null);
|
||||||
{
|
}
|
||||||
return Response.AsJson(false);
|
catch (Exception)
|
||||||
|
{
|
||||||
|
return Response.AsJson(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var emby = await EmbySettings.GetSettingsAsync();
|
||||||
|
if (emby.Enable)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(emby.AdministratorId) || string.IsNullOrEmpty(emby.Ip))
|
||||||
|
{
|
||||||
|
return Response.AsJson(false);
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var status = EmbyApi.GetSystemInformation(emby.ApiKey, emby.FullUri);
|
||||||
|
return Response.AsJson(status?.Version != null);
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
return Response.AsJson(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Response.AsJson(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue