|
|
|
@ -3,7 +3,6 @@ using System.Collections.Generic;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using Microsoft.Extensions.Caching.Memory;
|
|
|
|
|
using Ombi.Api.Radarr;
|
|
|
|
|
using Ombi.Api.Radarr.Models;
|
|
|
|
|
using Ombi.Attributes;
|
|
|
|
@ -13,9 +12,9 @@ using Ombi.Settings.Settings.Models.External;
|
|
|
|
|
|
|
|
|
|
namespace Ombi.Controllers.External
|
|
|
|
|
{
|
|
|
|
|
[Authorize]
|
|
|
|
|
[ApiV1]
|
|
|
|
|
[Produces("application/json")]
|
|
|
|
|
[Authorize]
|
|
|
|
|
[ApiV1]
|
|
|
|
|
[Produces("application/json")]
|
|
|
|
|
public class RadarrController : Controller
|
|
|
|
|
{
|
|
|
|
|
public RadarrController(IRadarrApi radarr, ISettingsService<RadarrSettings> settings,
|
|
|
|
@ -24,6 +23,7 @@ namespace Ombi.Controllers.External
|
|
|
|
|
RadarrApi = radarr;
|
|
|
|
|
RadarrSettings = settings;
|
|
|
|
|
Cache = mem;
|
|
|
|
|
RadarrSettings.ClearCache();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private IRadarrApi RadarrApi { get; }
|
|
|
|
@ -61,15 +61,12 @@ namespace Ombi.Controllers.External
|
|
|
|
|
[HttpGet("Profiles")]
|
|
|
|
|
public async Task<IEnumerable<RadarrProfile>> GetProfiles()
|
|
|
|
|
{
|
|
|
|
|
return await Cache.GetOrAdd(CacheKeys.RadarrQualityProfiles, async () =>
|
|
|
|
|
var settings = await RadarrSettings.GetSettingsAsync();
|
|
|
|
|
if (settings.Enabled)
|
|
|
|
|
{
|
|
|
|
|
var settings = await RadarrSettings.GetSettingsAsync();
|
|
|
|
|
if (settings.Enabled)
|
|
|
|
|
{
|
|
|
|
|
return await RadarrApi.GetProfiles(settings.ApiKey, settings.FullUri);
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}, DateTime.Now.AddHours(1));
|
|
|
|
|
return await RadarrApi.GetProfiles(settings.ApiKey, settings.FullUri);
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -80,15 +77,12 @@ namespace Ombi.Controllers.External
|
|
|
|
|
[HttpGet("RootFolders")]
|
|
|
|
|
public async Task<IEnumerable<RadarrRootFolder>> GetRootFolders()
|
|
|
|
|
{
|
|
|
|
|
return await Cache.GetOrAdd(CacheKeys.RadarrRootProfiles, async () =>
|
|
|
|
|
var settings = await RadarrSettings.GetSettingsAsync();
|
|
|
|
|
if (settings.Enabled)
|
|
|
|
|
{
|
|
|
|
|
var settings = await RadarrSettings.GetSettingsAsync();
|
|
|
|
|
if (settings.Enabled)
|
|
|
|
|
{
|
|
|
|
|
return await RadarrApi.GetRootFolders(settings.ApiKey, settings.FullUri);
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}, DateTime.Now.AddHours(1));
|
|
|
|
|
return await RadarrApi.GetRootFolders(settings.ApiKey, settings.FullUri);
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|