|
|
|
@ -1,4 +1,5 @@
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Hangfire;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
@ -6,10 +7,12 @@ using Microsoft.Extensions.Caching.Memory;
|
|
|
|
|
using Ombi.Api.Service;
|
|
|
|
|
using Ombi.Attributes;
|
|
|
|
|
using Ombi.Helpers;
|
|
|
|
|
using Ombi.Schedule;
|
|
|
|
|
using Ombi.Schedule.Jobs;
|
|
|
|
|
using Ombi.Schedule.Jobs.Emby;
|
|
|
|
|
using Ombi.Schedule.Jobs.Ombi;
|
|
|
|
|
using Ombi.Schedule.Jobs.Plex;
|
|
|
|
|
using Quartz;
|
|
|
|
|
|
|
|
|
|
namespace Ombi.Controllers
|
|
|
|
|
{
|
|
|
|
@ -19,35 +22,23 @@ namespace Ombi.Controllers
|
|
|
|
|
[ApiController]
|
|
|
|
|
public class JobController : ControllerBase
|
|
|
|
|
{
|
|
|
|
|
public JobController(IOmbiAutomaticUpdater updater, IPlexUserImporter userImporter,
|
|
|
|
|
ICacheService mem, IEmbyUserImporter embyImporter, IPlexContentSync plexContentSync,
|
|
|
|
|
IEmbyContentSync embyContentSync, INewsletterJob newsletter)
|
|
|
|
|
public JobController(IOmbiAutomaticUpdater updater, ICacheService mem)
|
|
|
|
|
{
|
|
|
|
|
_updater = updater;
|
|
|
|
|
_plexUserImporter = userImporter;
|
|
|
|
|
_embyUserImporter = embyImporter;
|
|
|
|
|
_memCache = mem;
|
|
|
|
|
_plexContentSync = plexContentSync;
|
|
|
|
|
_embyContentSync = embyContentSync;
|
|
|
|
|
_newsletterJob = newsletter;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private readonly IOmbiAutomaticUpdater _updater;
|
|
|
|
|
private readonly IPlexUserImporter _plexUserImporter;
|
|
|
|
|
private readonly IEmbyUserImporter _embyUserImporter;
|
|
|
|
|
private readonly ICacheService _memCache;
|
|
|
|
|
private readonly IPlexContentSync _plexContentSync;
|
|
|
|
|
private readonly IEmbyContentSync _embyContentSync;
|
|
|
|
|
private readonly INewsletterJob _newsletterJob;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Runs the update job
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost("update")]
|
|
|
|
|
public bool ForceUpdate()
|
|
|
|
|
public async Task<bool> ForceUpdate()
|
|
|
|
|
{
|
|
|
|
|
BackgroundJob.Enqueue(() => _updater.Update(null));
|
|
|
|
|
|
|
|
|
|
await OmbiQuartz.TriggerJob(nameof(IOmbiAutomaticUpdater));
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -94,9 +85,9 @@ namespace Ombi.Controllers
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost("plexuserimporter")]
|
|
|
|
|
public bool PlexUserImporter()
|
|
|
|
|
public async Task<bool> PlexUserImporter()
|
|
|
|
|
{
|
|
|
|
|
BackgroundJob.Enqueue(() => _plexUserImporter.Start());
|
|
|
|
|
await OmbiQuartz.TriggerJob(nameof(IPlexUserImporter));
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -105,9 +96,9 @@ namespace Ombi.Controllers
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost("embyuserimporter")]
|
|
|
|
|
public bool EmbyUserImporter()
|
|
|
|
|
public async Task<bool> EmbyUserImporter()
|
|
|
|
|
{
|
|
|
|
|
BackgroundJob.Enqueue(() => _embyUserImporter.Start());
|
|
|
|
|
await OmbiQuartz.TriggerJob(nameof(IEmbyUserImporter));
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -118,7 +109,7 @@ namespace Ombi.Controllers
|
|
|
|
|
[HttpPost("plexcontentcacher")]
|
|
|
|
|
public bool StartPlexContentCacher()
|
|
|
|
|
{
|
|
|
|
|
BackgroundJob.Enqueue(() => _plexContentSync.CacheContent(false));
|
|
|
|
|
OmbiQuartz.Scheduler.TriggerJob(new JobKey(nameof(PlexContentSync)), new JobDataMap(new Dictionary<string, string> { { "recentlyAddedSearch", "false" } }));
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -129,7 +120,7 @@ namespace Ombi.Controllers
|
|
|
|
|
[HttpPost("plexrecentlyadded")]
|
|
|
|
|
public bool StartRecentlyAdded()
|
|
|
|
|
{
|
|
|
|
|
BackgroundJob.Enqueue(() => _plexContentSync.CacheContent(true));
|
|
|
|
|
OmbiQuartz.Scheduler.TriggerJob(new JobKey(nameof(PlexContentSync)), new JobDataMap(new Dictionary<string, string> { { "recentlyAddedSearch", "true" } }));
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -138,9 +129,9 @@ namespace Ombi.Controllers
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost("embycontentcacher")]
|
|
|
|
|
public bool StartEmbyContentCacher()
|
|
|
|
|
public async Task<bool> StartEmbyContentCacher()
|
|
|
|
|
{
|
|
|
|
|
BackgroundJob.Enqueue(() => _embyContentSync.Start());
|
|
|
|
|
await OmbiQuartz.TriggerJob(nameof(IEmbyContentSync));
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -149,9 +140,9 @@ namespace Ombi.Controllers
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost("newsletter")]
|
|
|
|
|
public bool StartNewsletter()
|
|
|
|
|
public async Task<bool> StartNewsletter()
|
|
|
|
|
{
|
|
|
|
|
BackgroundJob.Enqueue(() => _newsletterJob.Start());
|
|
|
|
|
await OmbiQuartz.TriggerJob(nameof(INewsletterJob));
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|