Skip to content

Commit

Permalink
Added Jellyfin to the landing page media checks
Browse files Browse the repository at this point in the history
  • Loading branch information
tidusjar committed Feb 15, 2021
1 parent 996219c commit 53d6050
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions src/Ombi/Controllers/V1/LandingPageController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
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;
Expand All @@ -18,19 +19,22 @@ namespace Ombi.Controllers.V1
public class LandingPageController : ControllerBase
{
public LandingPageController(ISettingsService<PlexSettings> plex, ISettingsService<EmbySettings> emby,
IPlexApi plexApi, IEmbyApiFactory embyApi)
IPlexApi plexApi, IEmbyApiFactory embyApi, ISettingsService<JellyfinSettings> 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> _plexSettings;
private readonly ISettingsService<EmbySettings> _embySettings;

private readonly ISettingsService<JellyfinSettings> _jellyfin;
private readonly IJellyfinApi _jellyfinApi;

[HttpGet]
public async Task<MediaSeverAvailibilityViewModel> GetMediaServerStatus()
Expand Down Expand Up @@ -86,6 +90,31 @@ public async Task<MediaSeverAvailibilityViewModel> GetMediaServerStatus()
}
}
}


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;
}
}
Expand Down

0 comments on commit 53d6050

Please sign in to comment.