mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-08 06:00:50 -07:00
Started adding Emby, Lots of backend work done. Need a few more services done and login and user management. #435
This commit is contained in:
parent
2ab7aaa4b9
commit
868301f552
43 changed files with 1495 additions and 18 deletions
|
@ -97,6 +97,8 @@ namespace Ombi.UI.Modules.Admin
|
|||
private IDiscordApi DiscordApi { get; }
|
||||
private ISettingsService<RadarrSettings> RadarrSettings { get; }
|
||||
private IRadarrApi RadarrApi { get; }
|
||||
private ISettingsService<EmbySettings> EmbySettings { get; }
|
||||
private IEmbyApi EmbyApi { get; }
|
||||
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
public AdminModule(ISettingsService<PlexRequestSettings> prService,
|
||||
|
@ -124,7 +126,8 @@ namespace Ombi.UI.Modules.Admin
|
|||
ISettingsService<NotificationSettingsV2> notifyService, IRecentlyAdded recentlyAdded,
|
||||
ISettingsService<WatcherSettings> watcherSettings ,
|
||||
ISettingsService<DiscordNotificationSettings> discord,
|
||||
IDiscordApi discordapi, ISettingsService<RadarrSettings> settings, IRadarrApi radarrApi
|
||||
IDiscordApi discordapi, ISettingsService<RadarrSettings> settings, IRadarrApi radarrApi,
|
||||
ISettingsService<EmbySettings> embySettings, IEmbyApi emby
|
||||
, ISecurityExtensions security) : base("admin", prService, security)
|
||||
{
|
||||
PrService = prService;
|
||||
|
@ -160,7 +163,9 @@ namespace Ombi.UI.Modules.Admin
|
|||
DiscordApi = discordapi;
|
||||
RadarrSettings = settings;
|
||||
RadarrApi = radarrApi;
|
||||
|
||||
EmbyApi = emby;
|
||||
EmbySettings = embySettings;
|
||||
|
||||
Before += (ctx) => Security.AdminLoginRedirect(Permissions.Administrator, ctx);
|
||||
|
||||
Get["/"] = _ => Admin();
|
||||
|
@ -180,6 +185,10 @@ namespace Ombi.UI.Modules.Admin
|
|||
Get["/plex"] = _ => Plex();
|
||||
Post["/plex", true] = async (x, ct) => await SavePlex();
|
||||
|
||||
Get["/emby", true] = async (x, ct) => await Emby();
|
||||
Post["/emby", true] = async (x, ct) => await SaveEmby();
|
||||
|
||||
|
||||
Get["/sonarr"] = _ => Sonarr();
|
||||
Post["/sonarr"] = _ => SaveSonarr();
|
||||
Post["/sonarrprofiles"] = _ => GetSonarrQualityProfiles();
|
||||
|
@ -438,6 +447,13 @@ namespace Ombi.UI.Modules.Admin
|
|||
return Response.AsJson(valid.SendJsonError());
|
||||
}
|
||||
|
||||
var embySettings = await EmbySettings.GetSettingsAsync();
|
||||
|
||||
if (embySettings.Enable)
|
||||
{
|
||||
return Response.AsJson(new JsonResponseModel { Result = false, Message = "Emby is enabled, we cannot enable Plex and Emby" });
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(plexSettings.MachineIdentifier))
|
||||
{
|
||||
//Lookup identifier
|
||||
|
@ -453,6 +469,41 @@ namespace Ombi.UI.Modules.Admin
|
|||
: new JsonResponseModel { Result = false, Message = "Could not update the settings, take a look at the logs." });
|
||||
}
|
||||
|
||||
private async Task<Negotiator> Emby()
|
||||
{
|
||||
var settings = await EmbySettings.GetSettingsAsync();
|
||||
|
||||
return View["Emby", settings];
|
||||
}
|
||||
|
||||
private async Task<Response> SaveEmby()
|
||||
{
|
||||
var emby = this.Bind<EmbySettings>();
|
||||
var valid = this.Validate(emby);
|
||||
if (!valid.IsValid)
|
||||
{
|
||||
return Response.AsJson(valid.SendJsonError());
|
||||
}
|
||||
|
||||
var plexSettings = await PlexService.GetSettingsAsync();
|
||||
if (plexSettings.Enable)
|
||||
{
|
||||
return Response.AsJson(new JsonResponseModel { Result = false, Message = "Plex is enabled, we cannot enable Plex and Emby" });
|
||||
}
|
||||
|
||||
// Get the users
|
||||
var users = EmbyApi.GetUsers(emby.FullUri, emby.ApiKey);
|
||||
// Find admin
|
||||
var admin = users.FirstOrDefault(x => x.Policy.IsAdministrator);
|
||||
emby.AdministratorId = admin?.Id;
|
||||
|
||||
var result = await EmbySettings.SaveSettingsAsync(emby);
|
||||
|
||||
return Response.AsJson(result
|
||||
? new JsonResponseModel { Result = true, Message = "Successfully Updated the Settings for Emby!" }
|
||||
: new JsonResponseModel { Result = false, Message = "Could not update the settings, take a look at the logs." });
|
||||
}
|
||||
|
||||
private Negotiator Sonarr()
|
||||
{
|
||||
var settings = SonarrService.GetSettings();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue