mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-14 10:36:54 -07:00
Finished #923 !!!
This commit is contained in:
parent
02a1770b31
commit
4926255094
18 changed files with 283 additions and 22 deletions
|
@ -39,6 +39,7 @@ namespace Ombi.Core
|
|||
public const string SonarrQualityProfiles = nameof(SonarrQualityProfiles);
|
||||
public const string RadarrQualityProfiles = nameof(RadarrQualityProfiles);
|
||||
public const string SonarrQueued = nameof(SonarrQueued);
|
||||
public const string RadarrMovies = nameof(RadarrMovies);
|
||||
public const string SickRageQualityProfiles = nameof(SickRageQualityProfiles);
|
||||
public const string SickRageQueued = nameof(SickRageQueued);
|
||||
public const string CouchPotatoQualityProfiles = nameof(CouchPotatoQualityProfiles);
|
||||
|
|
|
@ -37,16 +37,20 @@ namespace Ombi.Core
|
|||
public class MovieSender : IMovieSender
|
||||
{
|
||||
public MovieSender(ISettingsService<CouchPotatoSettings> cp, ISettingsService<WatcherSettings> watcher,
|
||||
ICouchPotatoApi cpApi, IWatcherApi watcherApi)
|
||||
ICouchPotatoApi cpApi, IWatcherApi watcherApi, IRadarrApi radarrApi, ISettingsService<RadarrSettings> radarrSettings)
|
||||
{
|
||||
CouchPotatoSettings = cp;
|
||||
WatcherSettings = watcher;
|
||||
CpApi = cpApi;
|
||||
WatcherApi = watcherApi;
|
||||
RadarrSettings = radarrSettings;
|
||||
RadarrApi = radarrApi;
|
||||
}
|
||||
|
||||
private ISettingsService<CouchPotatoSettings> CouchPotatoSettings { get; }
|
||||
private ISettingsService<WatcherSettings> WatcherSettings { get; }
|
||||
private ISettingsService<RadarrSettings> RadarrSettings { get; }
|
||||
private IRadarrApi RadarrApi { get; }
|
||||
private ICouchPotatoApi CpApi { get; }
|
||||
private IWatcherApi WatcherApi { get; }
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
@ -55,6 +59,7 @@ namespace Ombi.Core
|
|||
{
|
||||
var cpSettings = await CouchPotatoSettings.GetSettingsAsync();
|
||||
var watcherSettings = await WatcherSettings.GetSettingsAsync();
|
||||
var radarrSettings = await RadarrSettings.GetSettingsAsync();
|
||||
|
||||
if (cpSettings.Enabled)
|
||||
{
|
||||
|
@ -66,6 +71,11 @@ namespace Ombi.Core
|
|||
return SendToWatcher(model, watcherSettings);
|
||||
}
|
||||
|
||||
if (radarrSettings.Enabled)
|
||||
{
|
||||
return SendToRadarr(model, radarrSettings);
|
||||
}
|
||||
|
||||
return new MovieSenderResult { Result = false, MovieSendingEnabled = false };
|
||||
}
|
||||
|
||||
|
@ -91,5 +101,23 @@ namespace Ombi.Core
|
|||
var result = CpApi.AddMovie(model.ImdbId, settings.ApiKey, model.Title, settings.FullUri, qualityId);
|
||||
return new MovieSenderResult { Result = result, MovieSendingEnabled = true };
|
||||
}
|
||||
|
||||
private MovieSenderResult SendToRadarr(RequestedModel model, RadarrSettings settings)
|
||||
{
|
||||
var qualityProfile = 0;
|
||||
int.TryParse(settings.QualityProfile, out qualityProfile);
|
||||
var result = RadarrApi.AddMovie(model.ProviderId, model.Title, qualityProfile, settings.RootPath, settings.ApiKey, settings.FullUri, true);
|
||||
|
||||
if (!string.IsNullOrEmpty(result.Error?.message))
|
||||
{
|
||||
Log.Error(result.Error.message);
|
||||
return new MovieSenderResult { Result = false };
|
||||
}
|
||||
if (!string.IsNullOrEmpty(result.title))
|
||||
{
|
||||
return new MovieSenderResult { Result = true, MovieSendingEnabled = true };
|
||||
}
|
||||
return new MovieSenderResult { Result = false, MovieSendingEnabled = true };
|
||||
}
|
||||
}
|
||||
}
|
|
@ -46,5 +46,6 @@ namespace Ombi.Core.SettingModels
|
|||
public int FaultQueueHandler { get; set; }
|
||||
public int PlexContentCacher { get; set; }
|
||||
public int PlexUserChecker { get; set; }
|
||||
public int RadarrCacher { get; set; }
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue