From 53d605095b52da8e838d2992e27866edcf411edd Mon Sep 17 00:00:00 2001 From: tidusjar Date: Mon, 15 Feb 2021 14:59:15 +0000 Subject: [PATCH] Added Jellyfin to the landing page media checks --- .../Controllers/V1/LandingPageController.cs | 33 +++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/src/Ombi/Controllers/V1/LandingPageController.cs b/src/Ombi/Controllers/V1/LandingPageController.cs index 54e1638b4..5f054165b 100644 --- a/src/Ombi/Controllers/V1/LandingPageController.cs +++ b/src/Ombi/Controllers/V1/LandingPageController.cs @@ -4,6 +4,7 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Ombi.Api.Emby; +using Ombi.Api.Jellyfin; using Ombi.Api.Plex; using Ombi.Core.Settings; using Ombi.Core.Settings.Models.External; @@ -18,19 +19,22 @@ namespace Ombi.Controllers.V1 public class LandingPageController : ControllerBase { public LandingPageController(ISettingsService plex, ISettingsService emby, - IPlexApi plexApi, IEmbyApiFactory embyApi) + IPlexApi plexApi, IEmbyApiFactory embyApi, ISettingsService jellyfin, IJellyfinApi jellyfinApi) { _plexSettings = plex; _embySettings = emby; _plexApi = plexApi; _embyApi = embyApi; + _jellyfin = jellyfin; + _jellyfinApi = jellyfinApi; } private readonly IPlexApi _plexApi; private readonly IEmbyApiFactory _embyApi; private readonly ISettingsService _plexSettings; private readonly ISettingsService _embySettings; - + private readonly ISettingsService _jellyfin; + private readonly IJellyfinApi _jellyfinApi; [HttpGet] public async Task GetMediaServerStatus() @@ -86,6 +90,31 @@ namespace Ombi.Controllers.V1 } } } + + + var jellyfin = await _jellyfin.GetSettingsAsync(); + if (jellyfin.Enable) + { + foreach (var server in jellyfin.Servers) + { + try + { + var result = await _jellyfinApi.GetUsers(server.FullUri, server.ApiKey); + if (result.Any()) + { + model.ServersAvailable++; + } + else + { + model.ServersUnavailable++; + } + } + catch (Exception) + { + model.ServersUnavailable++; + } + } + } return model; } }