mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-19 21:03:17 -07:00
Finished #884
This commit is contained in:
parent
ad2169ca17
commit
ba80dfe3aa
4 changed files with 26 additions and 22 deletions
|
@ -28,6 +28,7 @@
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using NLog;
|
using NLog;
|
||||||
using Ombi.Api.Interfaces;
|
using Ombi.Api.Interfaces;
|
||||||
|
@ -73,7 +74,9 @@ namespace Ombi.Api
|
||||||
{
|
{
|
||||||
return new WatcherListStatusResultContainer();
|
return new WatcherListStatusResultContainer();
|
||||||
}
|
}
|
||||||
return JsonConvert.DeserializeObject<WatcherListStatusResultContainer>(response.Content);
|
var items = JsonConvert.DeserializeObject<List<WatcherListStatusResult>>(response.Content);
|
||||||
|
|
||||||
|
return new WatcherListStatusResultContainer {Results = items};
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -95,7 +98,9 @@ namespace Ombi.Api
|
||||||
{
|
{
|
||||||
return new WatcherListStatusResultContainer();
|
return new WatcherListStatusResultContainer();
|
||||||
}
|
}
|
||||||
return JsonConvert.DeserializeObject<WatcherListStatusResultContainer>(response.Content);
|
var items = JsonConvert.DeserializeObject<List<WatcherListStatusResult>>(response.Content);
|
||||||
|
|
||||||
|
return new WatcherListStatusResultContainer { Results = items };
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -114,9 +119,10 @@ namespace Ombi.Api
|
||||||
RestRequest request;
|
RestRequest request;
|
||||||
request = new RestRequest
|
request = new RestRequest
|
||||||
{
|
{
|
||||||
Resource = "/api"
|
Resource = string.IsNullOrEmpty(imdbid) ? "/api?apikey={apikey}&mode={mode}" : "/api?apikey={apikey}&mode={mode}&imdbid={imdbid}"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
request.AddUrlSegment("apikey", apiKey);
|
request.AddUrlSegment("apikey", apiKey);
|
||||||
if (!string.IsNullOrEmpty(imdbid))
|
if (!string.IsNullOrEmpty(imdbid))
|
||||||
{
|
{
|
||||||
|
|
|
@ -53,7 +53,7 @@ namespace Ombi.Services.Jobs
|
||||||
ISickRageApi srApi, ISettingsService<SonarrSettings> sonarrSettings, ISettingsService<SickRageSettings> srSettings,
|
ISickRageApi srApi, ISettingsService<SonarrSettings> sonarrSettings, ISettingsService<SickRageSettings> srSettings,
|
||||||
ICouchPotatoApi cpApi, ISettingsService<CouchPotatoSettings> cpsettings, IRequestService requestService,
|
ICouchPotatoApi cpApi, ISettingsService<CouchPotatoSettings> cpsettings, IRequestService requestService,
|
||||||
ISettingsService<HeadphonesSettings> hpSettings, IHeadphonesApi headphonesApi, ISettingsService<PlexRequestSettings> prSettings,
|
ISettingsService<HeadphonesSettings> hpSettings, IHeadphonesApi headphonesApi, ISettingsService<PlexRequestSettings> prSettings,
|
||||||
ISecurityExtensions security)
|
ISecurityExtensions security, IMovieSender movieSender)
|
||||||
{
|
{
|
||||||
Record = record;
|
Record = record;
|
||||||
Repo = repo;
|
Repo = repo;
|
||||||
|
@ -70,8 +70,10 @@ namespace Ombi.Services.Jobs
|
||||||
HeadphoneSettings = hpSettings;
|
HeadphoneSettings = hpSettings;
|
||||||
Security = security;
|
Security = security;
|
||||||
PrSettings = prSettings.GetSettings();
|
PrSettings = prSettings.GetSettings();
|
||||||
|
MovieSender = movieSender;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private IMovieSender MovieSender { get; }
|
||||||
private IRepository<RequestQueue> Repo { get; }
|
private IRepository<RequestQueue> Repo { get; }
|
||||||
private IJobRecord Record { get; }
|
private IJobRecord Record { get; }
|
||||||
private ISonarrApi SonarrApi { get; }
|
private ISonarrApi SonarrApi { get; }
|
||||||
|
@ -197,24 +199,19 @@ namespace Ombi.Services.Jobs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool ProcessMovies(RequestedModel model, CouchPotatoSettings cp)
|
private bool ProcessMovies(RequestedModel model)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (cp.Enabled)
|
var result = MovieSender.Send(model).Result;
|
||||||
|
if (result.Result)
|
||||||
{
|
{
|
||||||
var result = CpApi.AddMovie(model.ImdbId, cp.ApiKey, model.Title,
|
// Approve it now
|
||||||
cp.FullUri, cp.ProfileId);
|
model.Approved = true;
|
||||||
|
RequestService.UpdateRequest(model);
|
||||||
if (result)
|
return true;
|
||||||
{
|
};
|
||||||
// Approve it now
|
|
||||||
model.Approved = true;
|
|
||||||
RequestService.UpdateRequest(model);
|
|
||||||
};
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
@ -272,7 +269,7 @@ namespace Ombi.Services.Jobs
|
||||||
switch (request.Type)
|
switch (request.Type)
|
||||||
{
|
{
|
||||||
case RequestType.Movie:
|
case RequestType.Movie:
|
||||||
result = ProcessMovies(model, cpSettings);
|
result = ProcessMovies(model);
|
||||||
break;
|
break;
|
||||||
case RequestType.TvShow:
|
case RequestType.TvShow:
|
||||||
result = ProcessTvShow(model, sonarrSettings, sickrageSettings);
|
result = ProcessTvShow(model, sonarrSettings, sickrageSettings);
|
||||||
|
|
|
@ -47,7 +47,7 @@ namespace Ombi.Services.Jobs
|
||||||
IWatcherApi watcherApi, ICacheProvider cache, IJobRecord rec)
|
IWatcherApi watcherApi, ICacheProvider cache, IJobRecord rec)
|
||||||
{
|
{
|
||||||
WatcherSettings = watcher;
|
WatcherSettings = watcher;
|
||||||
WatcherApi = WatcherApi;
|
WatcherApi = watcherApi;
|
||||||
Cache = cache;
|
Cache = cache;
|
||||||
Job = rec;
|
Job = rec;
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ namespace Ombi.Services.Jobs
|
||||||
movies?.Results?.Where(x => x.status.Equals("Wanted", StringComparison.CurrentCultureIgnoreCase));
|
movies?.Results?.Where(x => x.status.Equals("Wanted", StringComparison.CurrentCultureIgnoreCase));
|
||||||
if (wantedMovies != null && wantedMovies.Any())
|
if (wantedMovies != null && wantedMovies.Any())
|
||||||
{
|
{
|
||||||
Cache.Set(CacheKeys.WatcherQueued, movies.Results.Select(x => x.imdbid), CacheKeys.TimeFrameMinutes.SchedulerCaching);
|
Cache.Set(CacheKeys.WatcherQueued, movies.Results.Select(x => x.imdbid).ToArray(), CacheKeys.TimeFrameMinutes.SchedulerCaching);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -217,7 +217,8 @@ namespace Ombi.UI.Jobs
|
||||||
var watcherCacher =
|
var watcherCacher =
|
||||||
TriggerBuilder.Create()
|
TriggerBuilder.Create()
|
||||||
.WithIdentity("WatcherCacher", "Cache")
|
.WithIdentity("WatcherCacher", "Cache")
|
||||||
.StartAt(DateBuilder.FutureDate(4, IntervalUnit.Minute))
|
//.StartNow()
|
||||||
|
.StartAt(DateBuilder.FutureDate(3, IntervalUnit.Minute))
|
||||||
.WithSimpleSchedule(x => x.WithIntervalInMinutes(s.WatcherCacher).RepeatForever())
|
.WithSimpleSchedule(x => x.WithIntervalInMinutes(s.WatcherCacher).RepeatForever())
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue