mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-19 21:03:17 -07:00
commit
46d9900ad5
5 changed files with 75 additions and 60 deletions
|
@ -97,7 +97,7 @@ namespace Ombi.Core.Queue
|
||||||
Content = ByteConverterHelper.ReturnBytes(request),
|
Content = ByteConverterHelper.ReturnBytes(request),
|
||||||
PrimaryIdentifier = id,
|
PrimaryIdentifier = id,
|
||||||
FaultType = faultType,
|
FaultType = faultType,
|
||||||
Message = description ?? string.Empty
|
Description = description ?? string.Empty
|
||||||
};
|
};
|
||||||
await RequestQueue.InsertAsync(queue);
|
await RequestQueue.InsertAsync(queue);
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ namespace Ombi.Store.Models
|
||||||
|
|
||||||
public FaultType FaultType { get; set; }
|
public FaultType FaultType { get; set; }
|
||||||
public DateTime? LastRetry { get; set; }
|
public DateTime? LastRetry { get; set; }
|
||||||
public string Message { get; set; }
|
public string Description { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum FaultType
|
public enum FaultType
|
||||||
|
|
|
@ -184,9 +184,6 @@ namespace Ombi.UI.Modules.Admin
|
||||||
Post["/sonarr"] = _ => SaveSonarr();
|
Post["/sonarr"] = _ => SaveSonarr();
|
||||||
Post["/sonarrprofiles"] = _ => GetSonarrQualityProfiles();
|
Post["/sonarrprofiles"] = _ => GetSonarrQualityProfiles();
|
||||||
|
|
||||||
Get["/radarr", true] = async (x, ct) => await Radarr();
|
|
||||||
Post["/radarr", true] = async (x, ct) => await SaveRadarr();
|
|
||||||
Post["/radarrprofiles"] = _ => GetRadarrQualityProfiles();
|
|
||||||
|
|
||||||
Get["/sickrage"] = _ => Sickrage();
|
Get["/sickrage"] = _ => Sickrage();
|
||||||
Post["/sickrage"] = _ => SaveSickrage();
|
Post["/sickrage"] = _ => SaveSickrage();
|
||||||
|
@ -486,57 +483,9 @@ namespace Ombi.UI.Modules.Admin
|
||||||
: new JsonResponseModel { Result = false, Message = "Could not update the settings, take a look at the logs." });
|
: new JsonResponseModel { Result = false, Message = "Could not update the settings, take a look at the logs." });
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<Negotiator> Radarr()
|
|
||||||
{
|
|
||||||
var settings = await RadarrSettings.GetSettingsAsync();
|
|
||||||
|
|
||||||
return View["Radarr", settings];
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task<Response> SaveRadarr()
|
|
||||||
{
|
|
||||||
var radarrSettings = this.Bind<RadarrSettings>();
|
|
||||||
|
|
||||||
//Check Watcher and CP make sure they are not enabled
|
|
||||||
var watcher = await WatcherSettings.GetSettingsAsync();
|
|
||||||
if (watcher.Enabled)
|
|
||||||
{
|
|
||||||
return Response.AsJson(new JsonResponseModel { Result = false, Message = "Watcher is enabled, we cannot enable Watcher and Radarr" });
|
|
||||||
}
|
|
||||||
|
|
||||||
var cp = await CpService.GetSettingsAsync();
|
|
||||||
if (cp.Enabled)
|
|
||||||
{
|
|
||||||
return Response.AsJson(new JsonResponseModel { Result = false, Message = "CouchPotato is enabled, we cannot enable Watcher and CouchPotato" });
|
|
||||||
}
|
|
||||||
|
|
||||||
var valid = this.Validate(radarrSettings);
|
|
||||||
if (!valid.IsValid)
|
|
||||||
{
|
|
||||||
return Response.AsJson(valid.SendJsonError());
|
|
||||||
}
|
|
||||||
|
|
||||||
radarrSettings.ApiKey = radarrSettings.ApiKey.Trim();
|
|
||||||
var result = await RadarrSettings.SaveSettingsAsync(radarrSettings);
|
|
||||||
|
|
||||||
return Response.AsJson(result
|
|
||||||
? new JsonResponseModel { Result = true, Message = "Successfully Updated the Settings for Radarr!" }
|
|
||||||
: new JsonResponseModel { Result = false, Message = "Could not update the settings, take a look at the logs." });
|
|
||||||
}
|
|
||||||
|
|
||||||
private Response GetRadarrQualityProfiles()
|
|
||||||
{
|
|
||||||
var settings = this.Bind<RadarrSettings>();
|
|
||||||
var profiles = RadarrApi.GetProfiles(settings.ApiKey, settings.FullUri);
|
|
||||||
|
|
||||||
// set the cache
|
|
||||||
if (profiles != null)
|
|
||||||
{
|
|
||||||
Cache.Set(CacheKeys.RadarrQualityProfiles, profiles);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Response.AsJson(profiles);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Negotiator Sickrage()
|
private Negotiator Sickrage()
|
||||||
{
|
{
|
||||||
|
|
|
@ -64,7 +64,7 @@ namespace Ombi.UI.Modules.Admin
|
||||||
Id = r.Id,
|
Id = r.Id,
|
||||||
PrimaryIdentifier = r.PrimaryIdentifier,
|
PrimaryIdentifier = r.PrimaryIdentifier,
|
||||||
LastRetry = r.LastRetry,
|
LastRetry = r.LastRetry,
|
||||||
Message = r.Message
|
Message = r.Description
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
return View["RequestFaultQueue", model];
|
return View["RequestFaultQueue", model];
|
||||||
|
|
|
@ -36,6 +36,7 @@ using Nancy;
|
||||||
using Nancy.ModelBinding;
|
using Nancy.ModelBinding;
|
||||||
using Nancy.Responses.Negotiation;
|
using Nancy.Responses.Negotiation;
|
||||||
using Nancy.Validation;
|
using Nancy.Validation;
|
||||||
|
using Ombi.Api.Interfaces;
|
||||||
using Ombi.Core;
|
using Ombi.Core;
|
||||||
using Ombi.Core.SettingModels;
|
using Ombi.Core.SettingModels;
|
||||||
using Ombi.Core.StatusChecker;
|
using Ombi.Core.StatusChecker;
|
||||||
|
@ -52,21 +53,34 @@ namespace Ombi.UI.Modules.Admin
|
||||||
public class IntegrationModule : BaseModule
|
public class IntegrationModule : BaseModule
|
||||||
{
|
{
|
||||||
public IntegrationModule(ISettingsService<PlexRequestSettings> settingsService, ISettingsService<WatcherSettings> watcher,
|
public IntegrationModule(ISettingsService<PlexRequestSettings> settingsService, ISettingsService<WatcherSettings> watcher,
|
||||||
ISettingsService<CouchPotatoSettings> cp,ISecurityExtensions security, IAnalytics a) : base("admin", settingsService, security)
|
ISettingsService<CouchPotatoSettings> cp,ISecurityExtensions security, IAnalytics a, ISettingsService<RadarrSettings> radarrSettings,
|
||||||
|
ICacheProvider cache, IRadarrApi radarrApi) : base("admin", settingsService, security)
|
||||||
{
|
{
|
||||||
|
|
||||||
WatcherSettings = watcher;
|
WatcherSettings = watcher;
|
||||||
Analytics = a;
|
Analytics = a;
|
||||||
CpSettings = cp;
|
CpSettings = cp;
|
||||||
|
Cache = cache;
|
||||||
|
RadarrApi = radarrApi;
|
||||||
|
RadarrSettings = radarrSettings;
|
||||||
|
|
||||||
Before += (ctx) => Security.AdminLoginRedirect(Permissions.Administrator, ctx);
|
Before += (ctx) => Security.AdminLoginRedirect(Permissions.Administrator, ctx);
|
||||||
|
|
||||||
Get["/watcher", true] = async (x, ct) => await Watcher();
|
Get["/watcher", true] = async (x, ct) => await Watcher();
|
||||||
Post["/watcher", true] = async (x, ct) => await SaveWatcher();
|
Post["/watcher", true] = async (x, ct) => await SaveWatcher();
|
||||||
|
|
||||||
|
Get["/radarr", true] = async (x, ct) => await Radarr();
|
||||||
|
Post["/radarr", true] = async (x, ct) => await SaveRadarr();
|
||||||
|
|
||||||
|
|
||||||
|
Post["/radarrprofiles"] = _ => GetRadarrQualityProfiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
private ISettingsService<WatcherSettings> WatcherSettings { get; }
|
private ISettingsService<WatcherSettings> WatcherSettings { get; }
|
||||||
private ISettingsService<CouchPotatoSettings> CpSettings { get; }
|
private ISettingsService<CouchPotatoSettings> CpSettings { get; }
|
||||||
|
private ISettingsService<RadarrSettings> RadarrSettings { get; }
|
||||||
|
private IRadarrApi RadarrApi { get; }
|
||||||
|
private ICacheProvider Cache { get; }
|
||||||
private IAnalytics Analytics { get; }
|
private IAnalytics Analytics { get; }
|
||||||
|
|
||||||
private async Task<Negotiator> Watcher()
|
private async Task<Negotiator> Watcher()
|
||||||
|
@ -97,15 +111,15 @@ namespace Ombi.UI.Modules.Admin
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var watcherSettings = await WatcherSettings.GetSettingsAsync();
|
var radarrSettings = await RadarrSettings.GetSettingsAsync();
|
||||||
|
|
||||||
if (watcherSettings.Enabled)
|
if (radarrSettings.Enabled)
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
Response.AsJson(new JsonResponseModel
|
Response.AsJson(new JsonResponseModel
|
||||||
{
|
{
|
||||||
Result = false,
|
Result = false,
|
||||||
Message = "Cannot have Watcher and CouchPotato both enabled."
|
Message = "Cannot have Radarr and CouchPotato both enabled."
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,5 +130,57 @@ namespace Ombi.UI.Modules.Admin
|
||||||
: new JsonResponseModel { Result = false, Message = "Could not update the settings, take a look at the logs." });
|
: new JsonResponseModel { Result = false, Message = "Could not update the settings, take a look at the logs." });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task<Negotiator> Radarr()
|
||||||
|
{
|
||||||
|
var settings = await RadarrSettings.GetSettingsAsync();
|
||||||
|
|
||||||
|
return View["Radarr", settings];
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<Response> SaveRadarr()
|
||||||
|
{
|
||||||
|
var radarrSettings = this.Bind<RadarrSettings>();
|
||||||
|
|
||||||
|
//Check Watcher and CP make sure they are not enabled
|
||||||
|
var watcher = await WatcherSettings.GetSettingsAsync();
|
||||||
|
if (watcher.Enabled)
|
||||||
|
{
|
||||||
|
return Response.AsJson(new JsonResponseModel { Result = false, Message = "Watcher is enabled, we cannot enable Watcher and Radarr" });
|
||||||
|
}
|
||||||
|
|
||||||
|
var cp = await CpSettings.GetSettingsAsync();
|
||||||
|
if (cp.Enabled)
|
||||||
|
{
|
||||||
|
return Response.AsJson(new JsonResponseModel { Result = false, Message = "CouchPotato is enabled, we cannot enable Watcher and CouchPotato" });
|
||||||
|
}
|
||||||
|
|
||||||
|
var valid = this.Validate(radarrSettings);
|
||||||
|
if (!valid.IsValid)
|
||||||
|
{
|
||||||
|
return Response.AsJson(valid.SendJsonError());
|
||||||
|
}
|
||||||
|
|
||||||
|
radarrSettings.ApiKey = radarrSettings.ApiKey.Trim();
|
||||||
|
var result = await RadarrSettings.SaveSettingsAsync(radarrSettings);
|
||||||
|
|
||||||
|
return Response.AsJson(result
|
||||||
|
? new JsonResponseModel { Result = true, Message = "Successfully Updated the Settings for Radarr!" }
|
||||||
|
: new JsonResponseModel { Result = false, Message = "Could not update the settings, take a look at the logs." });
|
||||||
|
}
|
||||||
|
|
||||||
|
private Response GetRadarrQualityProfiles()
|
||||||
|
{
|
||||||
|
var settings = this.Bind<RadarrSettings>();
|
||||||
|
var profiles = RadarrApi.GetProfiles(settings.ApiKey, settings.FullUri);
|
||||||
|
|
||||||
|
// set the cache
|
||||||
|
if (profiles != null)
|
||||||
|
{
|
||||||
|
Cache.Set(CacheKeys.RadarrQualityProfiles, profiles);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Response.AsJson(profiles);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue