mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-20 13:23:20 -07:00
Added logging into the schedule jobs, users not get feedback about what is going on!
This commit is contained in:
parent
975a162edd
commit
7514881bd8
21 changed files with 177 additions and 35 deletions
|
@ -213,7 +213,6 @@ namespace Ombi.DependencyInjection
|
|||
services.AddTransient<ISickRageSync, SickRageSync>();
|
||||
services.AddTransient<IRefreshMetadata, RefreshMetadata>();
|
||||
services.AddTransient<INewsletterJob, NewsletterJob>();
|
||||
services.AddTransient<IPlexRecentlyAddedSync, PlexRecentlyAddedSync>();
|
||||
services.AddTransient<ILidarrAlbumSync, LidarrAlbumSync>();
|
||||
services.AddTransient<ILidarrArtistSync, LidarrArtistSync>();
|
||||
services.AddTransient<ILidarrAvailabilityChecker, LidarrAvailabilityChecker>();
|
||||
|
|
|
@ -101,7 +101,7 @@ namespace Ombi.Schedule.Tests
|
|||
|
||||
Settings.Setup(x => x.GetSettingsAsync()).ReturnsAsync(new IssueSettings { DeleteIssues = true, DaysAfterResolvedToDelete = 5 });
|
||||
Repo.Setup(x => x.GetAll()).Returns(new EnumerableQuery<Issues>(issues));
|
||||
await Job.Start();
|
||||
await Job.Execute(null);
|
||||
|
||||
Assert.That(issues[0].Status, Is.Not.EqualTo(IssueStatus.Deleted));
|
||||
Assert.That(issues[1].Status, Is.Not.EqualTo(IssueStatus.Deleted));
|
||||
|
|
|
@ -28,11 +28,13 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Ombi.Api.CouchPotato;
|
||||
using Ombi.Core.Settings;
|
||||
using Ombi.Helpers;
|
||||
using Ombi.Hubs;
|
||||
using Ombi.Settings.Settings.Models.External;
|
||||
using Ombi.Store.Context;
|
||||
using Ombi.Store.Entities;
|
||||
|
@ -43,12 +45,13 @@ namespace Ombi.Schedule.Jobs.Couchpotato
|
|||
public class CouchPotatoSync : ICouchPotatoSync
|
||||
{
|
||||
public CouchPotatoSync(ISettingsService<CouchPotatoSettings> cpSettings,
|
||||
ICouchPotatoApi api, ILogger<CouchPotatoSync> log, IExternalContext ctx)
|
||||
ICouchPotatoApi api, ILogger<CouchPotatoSync> log, IExternalContext ctx, IHubContext<NotificationHub> hub)
|
||||
{
|
||||
_settings = cpSettings;
|
||||
_api = api;
|
||||
_log = log;
|
||||
_ctx = ctx;
|
||||
_notification = hub;
|
||||
_settings.ClearCache();
|
||||
}
|
||||
|
||||
|
@ -56,6 +59,7 @@ namespace Ombi.Schedule.Jobs.Couchpotato
|
|||
private readonly ICouchPotatoApi _api;
|
||||
private readonly ILogger<CouchPotatoSync> _log;
|
||||
private readonly IExternalContext _ctx;
|
||||
private readonly IHubContext<NotificationHub> _notification;
|
||||
|
||||
public async Task Execute(IJobExecutionContext job)
|
||||
{
|
||||
|
@ -65,6 +69,8 @@ namespace Ombi.Schedule.Jobs.Couchpotato
|
|||
return;
|
||||
}
|
||||
|
||||
await _notification.Clients.Clients(NotificationHub.AdminConnectionIds)
|
||||
.SendAsync(NotificationHub.NotificationEvent, "Couch Potato Sync Started");
|
||||
try
|
||||
{
|
||||
_log.LogInformation(LoggingEvents.CouchPotatoCacher, "Getting all active movies from CP");
|
||||
|
@ -95,10 +101,15 @@ namespace Ombi.Schedule.Jobs.Couchpotato
|
|||
await _ctx.CouchPotatoCache.AddRangeAsync(movieIds);
|
||||
|
||||
await _ctx.SaveChangesAsync();
|
||||
|
||||
await _notification.Clients.Clients(NotificationHub.AdminConnectionIds)
|
||||
.SendAsync(NotificationHub.NotificationEvent, "Couch Potato Sync Finished");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
await _notification.Clients.Clients(NotificationHub.AdminConnectionIds)
|
||||
.SendAsync(NotificationHub.NotificationEvent, "Couch Potato Sync Failed");
|
||||
_log.LogError(LoggingEvents.CouchPotatoCacher, e, "error when trying to get movies from CP");
|
||||
throw;
|
||||
}
|
||||
|
|
|
@ -29,10 +29,12 @@ using System;
|
|||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Hangfire;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Ombi.Core.Notifications;
|
||||
using Ombi.Helpers;
|
||||
using Ombi.Hubs;
|
||||
using Ombi.Notifications.Models;
|
||||
using Ombi.Store.Entities;
|
||||
using Ombi.Store.Repository;
|
||||
|
@ -44,13 +46,14 @@ namespace Ombi.Schedule.Jobs.Emby
|
|||
public class EmbyAvaliabilityChecker : IEmbyAvaliabilityChecker
|
||||
{
|
||||
public EmbyAvaliabilityChecker(IEmbyContentRepository repo, ITvRequestRepository t, IMovieRequestRepository m,
|
||||
INotificationService n, ILogger<EmbyAvaliabilityChecker> log)
|
||||
INotificationService n, ILogger<EmbyAvaliabilityChecker> log, IHubContext<NotificationHub> notification)
|
||||
{
|
||||
_repo = repo;
|
||||
_tvRepo = t;
|
||||
_movieRepo = m;
|
||||
_notificationService = n;
|
||||
_log = log;
|
||||
_notification = notification;
|
||||
}
|
||||
|
||||
private readonly ITvRequestRepository _tvRepo;
|
||||
|
@ -58,11 +61,17 @@ namespace Ombi.Schedule.Jobs.Emby
|
|||
private readonly IEmbyContentRepository _repo;
|
||||
private readonly INotificationService _notificationService;
|
||||
private readonly ILogger<EmbyAvaliabilityChecker> _log;
|
||||
private readonly IHubContext<NotificationHub> _notification;
|
||||
|
||||
public async Task Execute(IJobExecutionContext job)
|
||||
{
|
||||
await _notification.Clients.Clients(NotificationHub.AdminConnectionIds)
|
||||
.SendAsync(NotificationHub.NotificationEvent, "Emby Availability Checker Started");
|
||||
await ProcessMovies();
|
||||
await ProcessTv();
|
||||
|
||||
await _notification.Clients.Clients(NotificationHub.AdminConnectionIds)
|
||||
.SendAsync(NotificationHub.NotificationEvent, "Emby Availability Checker Finished");
|
||||
}
|
||||
|
||||
private async Task ProcessMovies()
|
||||
|
|
|
@ -3,12 +3,14 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Hangfire;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Ombi.Api.Emby;
|
||||
using Ombi.Api.Emby.Models.Movie;
|
||||
using Ombi.Core.Settings;
|
||||
using Ombi.Core.Settings.Models.External;
|
||||
using Ombi.Helpers;
|
||||
using Ombi.Hubs;
|
||||
using Ombi.Schedule.Jobs.Ombi;
|
||||
using Ombi.Store.Entities;
|
||||
using Ombi.Store.Repository;
|
||||
|
@ -21,19 +23,20 @@ namespace Ombi.Schedule.Jobs.Emby
|
|||
public class EmbyContentSync : IEmbyContentSync
|
||||
{
|
||||
public EmbyContentSync(ISettingsService<EmbySettings> settings, IEmbyApi api, ILogger<EmbyContentSync> logger,
|
||||
IEmbyContentRepository repo)
|
||||
IEmbyContentRepository repo, IHubContext<NotificationHub> notification)
|
||||
{
|
||||
_logger = logger;
|
||||
_settings = settings;
|
||||
_api = api;
|
||||
_repo = repo;
|
||||
_notification = notification;
|
||||
}
|
||||
|
||||
private readonly ILogger<EmbyContentSync> _logger;
|
||||
private readonly ISettingsService<EmbySettings> _settings;
|
||||
private readonly IEmbyApi _api;
|
||||
private readonly IEmbyContentRepository _repo;
|
||||
|
||||
private readonly IHubContext<NotificationHub> _notification;
|
||||
|
||||
public async Task Execute(IJobExecutionContext job)
|
||||
{
|
||||
|
@ -41,6 +44,10 @@ namespace Ombi.Schedule.Jobs.Emby
|
|||
if (!embySettings.Enable)
|
||||
return;
|
||||
|
||||
|
||||
await _notification.Clients.Clients(NotificationHub.AdminConnectionIds)
|
||||
.SendAsync(NotificationHub.NotificationEvent, "Emby Content Sync Started");
|
||||
|
||||
foreach (var server in embySettings.Servers)
|
||||
{
|
||||
try
|
||||
|
@ -49,10 +56,14 @@ namespace Ombi.Schedule.Jobs.Emby
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
await _notification.Clients.Clients(NotificationHub.AdminConnectionIds)
|
||||
.SendAsync(NotificationHub.NotificationEvent, "Emby Content Sync Failed");
|
||||
_logger.LogError(e, "Exception when caching Emby for server {0}", server.Name);
|
||||
}
|
||||
}
|
||||
|
||||
await _notification.Clients.Clients(NotificationHub.AdminConnectionIds)
|
||||
.SendAsync(NotificationHub.NotificationEvent, "Emby Content Sync Finished");
|
||||
// Episodes
|
||||
|
||||
await OmbiQuartz.TriggerJob(nameof(IEmbyEpisodeSync), "Emby");
|
||||
|
|
|
@ -30,10 +30,12 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Hangfire;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Ombi.Api.Emby;
|
||||
using Ombi.Core.Settings;
|
||||
using Ombi.Core.Settings.Models.External;
|
||||
using Ombi.Hubs;
|
||||
using Ombi.Store.Entities;
|
||||
using Ombi.Store.Repository;
|
||||
using Quartz;
|
||||
|
@ -42,30 +44,37 @@ namespace Ombi.Schedule.Jobs.Emby
|
|||
{
|
||||
public class EmbyEpisodeSync : IEmbyEpisodeSync
|
||||
{
|
||||
public EmbyEpisodeSync(ISettingsService<EmbySettings> s, IEmbyApi api, ILogger<EmbyEpisodeSync> l, IEmbyContentRepository repo)
|
||||
public EmbyEpisodeSync(ISettingsService<EmbySettings> s, IEmbyApi api, ILogger<EmbyEpisodeSync> l, IEmbyContentRepository repo
|
||||
, IHubContext<NotificationHub> notification)
|
||||
{
|
||||
_api = api;
|
||||
_logger = l;
|
||||
_settings = s;
|
||||
_repo = repo;
|
||||
_notification = notification;
|
||||
}
|
||||
|
||||
private readonly ISettingsService<EmbySettings> _settings;
|
||||
private readonly IEmbyApi _api;
|
||||
private readonly ILogger<EmbyEpisodeSync> _logger;
|
||||
private readonly IEmbyContentRepository _repo;
|
||||
private readonly IHubContext<NotificationHub> _notification;
|
||||
|
||||
|
||||
public async Task Execute(IJobExecutionContext job)
|
||||
{
|
||||
var settings = await _settings.GetSettingsAsync();
|
||||
|
||||
await _notification.Clients.Clients(NotificationHub.AdminConnectionIds)
|
||||
.SendAsync(NotificationHub.NotificationEvent, "Emby Episode Sync Started");
|
||||
foreach (var server in settings.Servers)
|
||||
{
|
||||
await CacheEpisodes(server);
|
||||
}
|
||||
|
||||
|
||||
await _notification.Clients.Clients(NotificationHub.AdminConnectionIds)
|
||||
.SendAsync(NotificationHub.NotificationEvent, "Emby Episode Sync Finished");
|
||||
await OmbiQuartz.TriggerJob(nameof(IEmbyAvaliabilityChecker), "Emby");
|
||||
}
|
||||
|
||||
|
|
|
@ -29,12 +29,14 @@ using System;
|
|||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Ombi.Api.Emby;
|
||||
using Ombi.Core.Settings;
|
||||
using Ombi.Core.Settings.Models.External;
|
||||
using Ombi.Helpers;
|
||||
using Ombi.Hubs;
|
||||
using Ombi.Settings.Settings.Models;
|
||||
using Ombi.Store.Entities;
|
||||
using Quartz;
|
||||
|
@ -44,13 +46,14 @@ namespace Ombi.Schedule.Jobs.Emby
|
|||
public class EmbyUserImporter : IEmbyUserImporter
|
||||
{
|
||||
public EmbyUserImporter(IEmbyApi api, UserManager<OmbiUser> um, ILogger<EmbyUserImporter> log,
|
||||
ISettingsService<EmbySettings> embySettings, ISettingsService<UserManagementSettings> ums)
|
||||
ISettingsService<EmbySettings> embySettings, ISettingsService<UserManagementSettings> ums, IHubContext<NotificationHub> notification)
|
||||
{
|
||||
_api = api;
|
||||
_userManager = um;
|
||||
_log = log;
|
||||
_embySettings = embySettings;
|
||||
_userManagementSettings = ums;
|
||||
_notification = notification;
|
||||
}
|
||||
|
||||
private readonly IEmbyApi _api;
|
||||
|
@ -58,6 +61,7 @@ namespace Ombi.Schedule.Jobs.Emby
|
|||
private readonly ILogger<EmbyUserImporter> _log;
|
||||
private readonly ISettingsService<EmbySettings> _embySettings;
|
||||
private readonly ISettingsService<UserManagementSettings> _userManagementSettings;
|
||||
private readonly IHubContext<NotificationHub> _notification;
|
||||
|
||||
public async Task Execute(IJobExecutionContext job)
|
||||
{
|
||||
|
@ -71,6 +75,9 @@ namespace Ombi.Schedule.Jobs.Emby
|
|||
{
|
||||
return;
|
||||
}
|
||||
|
||||
await _notification.Clients.Clients(NotificationHub.AdminConnectionIds)
|
||||
.SendAsync(NotificationHub.NotificationEvent, "Emby User Importer Started");
|
||||
var allUsers = await _userManager.Users.Where(x => x.UserType == UserType.EmbyUser).ToListAsync();
|
||||
foreach (var server in settings.Servers)
|
||||
{
|
||||
|
@ -148,6 +155,9 @@ namespace Ombi.Schedule.Jobs.Emby
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
await _notification.Clients.Clients(NotificationHub.AdminConnectionIds)
|
||||
.SendAsync(NotificationHub.NotificationEvent, "Emby User Importer Finished");
|
||||
}
|
||||
|
||||
private bool _disposed;
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Ombi.Store.Entities;
|
||||
using Quartz;
|
||||
|
||||
namespace Ombi.Schedule.Jobs.Lidarr
|
||||
{
|
||||
public interface ILidarrAlbumSync
|
||||
public interface ILidarrAlbumSync : IJob
|
||||
{
|
||||
Task CacheContent();
|
||||
void Dispose();
|
||||
Task<IEnumerable<LidarrAlbumCache>> GetCachedContent();
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
using System.Threading.Tasks;
|
||||
using Quartz;
|
||||
|
||||
namespace Ombi.Schedule.Jobs.Lidarr
|
||||
{
|
||||
public interface ILidarrAvailabilityChecker
|
||||
public interface ILidarrAvailabilityChecker : IJob
|
||||
{
|
||||
Task Start();
|
||||
}
|
||||
}
|
|
@ -2,15 +2,18 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Hangfire;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Internal;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Ombi.Api.Lidarr;
|
||||
using Ombi.Core.Settings;
|
||||
using Ombi.Helpers;
|
||||
using Ombi.Hubs;
|
||||
using Ombi.Settings.Settings.Models.External;
|
||||
using Ombi.Store.Context;
|
||||
using Ombi.Store.Entities;
|
||||
using Quartz;
|
||||
using ILogger = Microsoft.Extensions.Logging.ILogger;
|
||||
|
||||
namespace Ombi.Schedule.Jobs.Lidarr
|
||||
|
@ -18,7 +21,7 @@ namespace Ombi.Schedule.Jobs.Lidarr
|
|||
public class LidarrAlbumSync : ILidarrAlbumSync
|
||||
{
|
||||
public LidarrAlbumSync(ISettingsService<LidarrSettings> lidarr, ILidarrApi lidarrApi, ILogger<LidarrAlbumSync> log, IExternalContext ctx,
|
||||
IBackgroundJobClient job, ILidarrAvailabilityChecker availability)
|
||||
IBackgroundJobClient job, ILidarrAvailabilityChecker availability, IHubContext<NotificationHub> notification)
|
||||
{
|
||||
_lidarrSettings = lidarr;
|
||||
_lidarrApi = lidarrApi;
|
||||
|
@ -26,6 +29,7 @@ namespace Ombi.Schedule.Jobs.Lidarr
|
|||
_ctx = ctx;
|
||||
_job = job;
|
||||
_availability = availability;
|
||||
_notification = notification;
|
||||
}
|
||||
|
||||
private readonly ISettingsService<LidarrSettings> _lidarrSettings;
|
||||
|
@ -34,14 +38,18 @@ namespace Ombi.Schedule.Jobs.Lidarr
|
|||
private readonly IExternalContext _ctx;
|
||||
private readonly IBackgroundJobClient _job;
|
||||
private readonly ILidarrAvailabilityChecker _availability;
|
||||
private readonly IHubContext<NotificationHub> _notification;
|
||||
|
||||
public async Task CacheContent()
|
||||
public async Task Execute(IJobExecutionContext ctx)
|
||||
{
|
||||
try
|
||||
{
|
||||
var settings = await _lidarrSettings.GetSettingsAsync();
|
||||
if (settings.Enabled)
|
||||
{
|
||||
|
||||
await _notification.Clients.Clients(NotificationHub.AdminConnectionIds)
|
||||
.SendAsync(NotificationHub.NotificationEvent, "Lidarr Album Sync Started");
|
||||
try
|
||||
{
|
||||
var albums = await _lidarrApi.GetAllAlbums(settings.ApiKey, settings.FullUri);
|
||||
|
@ -75,10 +83,15 @@ namespace Ombi.Schedule.Jobs.Lidarr
|
|||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
await _notification.Clients.Clients(NotificationHub.AdminConnectionIds)
|
||||
.SendAsync(NotificationHub.NotificationEvent, "Lidarr Album Sync Failed");
|
||||
_logger.LogError(LoggingEvents.Cacher, ex, "Failed caching queued items from Lidarr Album");
|
||||
}
|
||||
|
||||
_job.Enqueue(() => _availability.Start());
|
||||
await _notification.Clients.Clients(NotificationHub.AdminConnectionIds)
|
||||
.SendAsync(NotificationHub.NotificationEvent, "Lidarr Album Sync Finished");
|
||||
|
||||
await OmbiQuartz.TriggerJob(nameof(ILidarrAvailabilityChecker), "DVR");
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
|
|
|
@ -2,12 +2,14 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Hangfire;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Internal;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Ombi.Api.Lidarr;
|
||||
using Ombi.Core.Settings;
|
||||
using Ombi.Helpers;
|
||||
using Ombi.Hubs;
|
||||
using Ombi.Settings.Settings.Models.External;
|
||||
using Ombi.Store.Context;
|
||||
using Ombi.Store.Entities;
|
||||
|
@ -18,23 +20,21 @@ namespace Ombi.Schedule.Jobs.Lidarr
|
|||
{
|
||||
public class LidarrArtistSync : ILidarrArtistSync
|
||||
{
|
||||
public LidarrArtistSync(ISettingsService<LidarrSettings> lidarr, ILidarrApi lidarrApi, ILogger<LidarrArtistSync> log, IExternalContext ctx,
|
||||
IBackgroundJobClient background, ILidarrAlbumSync album)
|
||||
public LidarrArtistSync(ISettingsService<LidarrSettings> lidarr, ILidarrApi lidarrApi, ILogger<LidarrArtistSync> log, IExternalContext ctx
|
||||
, IHubContext<NotificationHub> notification)
|
||||
{
|
||||
_lidarrSettings = lidarr;
|
||||
_lidarrApi = lidarrApi;
|
||||
_logger = log;
|
||||
_ctx = ctx;
|
||||
_job = background;
|
||||
_albumSync = album;
|
||||
_notification = notification;
|
||||
}
|
||||
|
||||
private readonly ISettingsService<LidarrSettings> _lidarrSettings;
|
||||
private readonly ILidarrApi _lidarrApi;
|
||||
private readonly ILogger _logger;
|
||||
private readonly IExternalContext _ctx;
|
||||
private readonly IBackgroundJobClient _job;
|
||||
private readonly ILidarrAlbumSync _albumSync;
|
||||
private readonly IHubContext<NotificationHub> _notification;
|
||||
|
||||
public async Task Execute(IJobExecutionContext job)
|
||||
{
|
||||
|
@ -43,6 +43,9 @@ namespace Ombi.Schedule.Jobs.Lidarr
|
|||
var settings = await _lidarrSettings.GetSettingsAsync();
|
||||
if (settings.Enabled)
|
||||
{
|
||||
|
||||
await _notification.Clients.Clients(NotificationHub.AdminConnectionIds)
|
||||
.SendAsync(NotificationHub.NotificationEvent, "Lidarr Artist Sync Started");
|
||||
try
|
||||
{
|
||||
var artists = await _lidarrApi.GetArtists(settings.ApiKey, settings.FullUri);
|
||||
|
@ -72,10 +75,15 @@ namespace Ombi.Schedule.Jobs.Lidarr
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await _notification.Clients.Clients(NotificationHub.AdminConnectionIds)
|
||||
.SendAsync(NotificationHub.NotificationEvent, "Lidarr Artist Sync Failed");
|
||||
_logger.LogError(LoggingEvents.Cacher, ex, "Failed caching queued items from Lidarr");
|
||||
}
|
||||
|
||||
_job.Enqueue(() => _albumSync.CacheContent());
|
||||
await _notification.Clients.Clients(NotificationHub.AdminConnectionIds)
|
||||
.SendAsync(NotificationHub.NotificationEvent, "Lidarr Artist Sync Finished");
|
||||
|
||||
await OmbiQuartz.TriggerJob(nameof(ILidarrAlbumSync), "DVR");
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
|
|
|
@ -3,28 +3,32 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Hangfire;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Ombi.Core.Notifications;
|
||||
using Ombi.Helpers;
|
||||
using Ombi.Hubs;
|
||||
using Ombi.Notifications.Models;
|
||||
using Ombi.Store.Entities;
|
||||
using Ombi.Store.Entities.Requests;
|
||||
using Ombi.Store.Repository;
|
||||
using Ombi.Store.Repository.Requests;
|
||||
using Quartz;
|
||||
|
||||
namespace Ombi.Schedule.Jobs.Lidarr
|
||||
{
|
||||
public class LidarrAvailabilityChecker : ILidarrAvailabilityChecker
|
||||
{
|
||||
public LidarrAvailabilityChecker(IMusicRequestRepository requests, IRepository<LidarrAlbumCache> albums, ILogger<LidarrAvailabilityChecker> log,
|
||||
IBackgroundJobClient job, INotificationService notification)
|
||||
IBackgroundJobClient job, INotificationService notification, IHubContext<NotificationHub> notificationHub)
|
||||
{
|
||||
_cachedAlbums = albums;
|
||||
_requestRepository = requests;
|
||||
_logger = log;
|
||||
_job = job;
|
||||
_notificationService = notification;
|
||||
_notification = notificationHub;
|
||||
}
|
||||
|
||||
private readonly IMusicRequestRepository _requestRepository;
|
||||
|
@ -32,9 +36,13 @@ namespace Ombi.Schedule.Jobs.Lidarr
|
|||
private readonly ILogger _logger;
|
||||
private readonly IBackgroundJobClient _job;
|
||||
private readonly INotificationService _notificationService;
|
||||
private readonly IHubContext<NotificationHub> _notification;
|
||||
|
||||
public async Task Start()
|
||||
public async Task Execute(IJobExecutionContext ctx)
|
||||
{
|
||||
|
||||
await _notification.Clients.Clients(NotificationHub.AdminConnectionIds)
|
||||
.SendAsync(NotificationHub.NotificationEvent, "Lidarr Availability Check Started");
|
||||
var allAlbumRequests = _requestRepository.GetAll().Include(x => x.RequestedUser).Where(x => !x.Available);
|
||||
var albumsToUpdate = new List<AlbumRequest>();
|
||||
foreach (var request in allAlbumRequests)
|
||||
|
@ -68,6 +76,9 @@ namespace Ombi.Schedule.Jobs.Lidarr
|
|||
Recipient = recipient,
|
||||
}));
|
||||
}
|
||||
|
||||
await _notification.Clients.Clients(NotificationHub.AdminConnectionIds)
|
||||
.SendAsync(NotificationHub.NotificationEvent, "Lidarr Availability Check Finished");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ using System.Text;
|
|||
using System.Threading.Tasks;
|
||||
using MailKit;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using MimeKit;
|
||||
|
@ -18,6 +19,7 @@ using Ombi.Api.TvMaze;
|
|||
using Ombi.Core.Settings;
|
||||
using Ombi.Core.Settings.Models.External;
|
||||
using Ombi.Helpers;
|
||||
using Ombi.Hubs;
|
||||
using Ombi.Notifications;
|
||||
using Ombi.Notifications.Models;
|
||||
using Ombi.Notifications.Templates;
|
||||
|
@ -38,7 +40,8 @@ namespace Ombi.Schedule.Jobs.Ombi
|
|||
ISettingsService<EmailNotificationSettings> emailSettings, INotificationTemplatesRepository templateRepo,
|
||||
UserManager<OmbiUser> um, ISettingsService<NewsletterSettings> newsletter, ILogger<NewsletterJob> log,
|
||||
ILidarrApi lidarrApi, IRepository<LidarrAlbumCache> albumCache, ISettingsService<LidarrSettings> lidarrSettings,
|
||||
ISettingsService<OmbiSettings> ombiSettings, ISettingsService<PlexSettings> plexSettings, ISettingsService<EmbySettings> embySettings)
|
||||
ISettingsService<OmbiSettings> ombiSettings, ISettingsService<PlexSettings> plexSettings, ISettingsService<EmbySettings> embySettings
|
||||
, IHubContext<NotificationHub> notification)
|
||||
{
|
||||
_plex = plex;
|
||||
_emby = emby;
|
||||
|
@ -58,6 +61,7 @@ namespace Ombi.Schedule.Jobs.Ombi
|
|||
_ombiSettings = ombiSettings;
|
||||
_plexSettings = plexSettings;
|
||||
_embySettings = embySettings;
|
||||
_notification = notification;
|
||||
_ombiSettings.ClearCache();
|
||||
_plexSettings.ClearCache();
|
||||
_emailSettings.ClearCache();
|
||||
|
@ -82,6 +86,7 @@ namespace Ombi.Schedule.Jobs.Ombi
|
|||
private readonly ISettingsService<LidarrSettings> _lidarrSettings;
|
||||
private readonly ISettingsService<PlexSettings> _plexSettings;
|
||||
private readonly ISettingsService<EmbySettings> _embySettings;
|
||||
private readonly IHubContext<NotificationHub> _notification;
|
||||
|
||||
public async Task Start(NewsletterSettings settings, bool test)
|
||||
{
|
||||
|
@ -95,9 +100,13 @@ namespace Ombi.Schedule.Jobs.Ombi
|
|||
return;
|
||||
}
|
||||
|
||||
await _notification.Clients.Clients(NotificationHub.AdminConnectionIds)
|
||||
.SendAsync(NotificationHub.NotificationEvent, "Newsletter Started");
|
||||
var emailSettings = await _emailSettings.GetSettingsAsync();
|
||||
if (!ValidateConfiguration(emailSettings))
|
||||
{
|
||||
await _notification.Clients.Clients(NotificationHub.AdminConnectionIds)
|
||||
.SendAsync(NotificationHub.NotificationEvent, "Newsletter Email Settings Not Configured");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -284,9 +293,14 @@ namespace Ombi.Schedule.Jobs.Ombi
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
await _notification.Clients.Clients(NotificationHub.AdminConnectionIds)
|
||||
.SendAsync(NotificationHub.NotificationEvent, "Newsletter Failed");
|
||||
_log.LogError(e, "Error when attempting to create newsletter");
|
||||
throw;
|
||||
}
|
||||
|
||||
await _notification.Clients.Clients(NotificationHub.AdminConnectionIds)
|
||||
.SendAsync(NotificationHub.NotificationEvent, "Newsletter Finished");
|
||||
}
|
||||
|
||||
public async Task Execute(IJobExecutionContext job)
|
||||
|
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Hangfire;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Ombi.Api.Emby;
|
||||
using Ombi.Api.TheMovieDb;
|
||||
|
@ -11,6 +12,7 @@ using Ombi.Api.TvMaze;
|
|||
using Ombi.Core.Settings;
|
||||
using Ombi.Core.Settings.Models.External;
|
||||
using Ombi.Helpers;
|
||||
using Ombi.Hubs;
|
||||
using Ombi.Schedule.Jobs.Emby;
|
||||
using Ombi.Schedule.Jobs.Plex;
|
||||
using Ombi.Store.Entities;
|
||||
|
@ -23,7 +25,7 @@ namespace Ombi.Schedule.Jobs.Ombi
|
|||
{
|
||||
public RefreshMetadata(IPlexContentRepository plexRepo, IEmbyContentRepository embyRepo,
|
||||
ILogger<RefreshMetadata> log, ITvMazeApi tvApi, ISettingsService<PlexSettings> plexSettings,
|
||||
IMovieDbApi movieApi, ISettingsService<EmbySettings> embySettings, IEmbyApi embyApi)
|
||||
IMovieDbApi movieApi, ISettingsService<EmbySettings> embySettings, IEmbyApi embyApi, IHubContext<NotificationHub> notification)
|
||||
{
|
||||
_plexRepo = plexRepo;
|
||||
_embyRepo = embyRepo;
|
||||
|
@ -33,6 +35,7 @@ namespace Ombi.Schedule.Jobs.Ombi
|
|||
_plexSettings = plexSettings;
|
||||
_embySettings = embySettings;
|
||||
_embyApi = embyApi;
|
||||
_notification = notification;
|
||||
}
|
||||
|
||||
private readonly IPlexContentRepository _plexRepo;
|
||||
|
@ -43,10 +46,14 @@ namespace Ombi.Schedule.Jobs.Ombi
|
|||
private readonly ISettingsService<PlexSettings> _plexSettings;
|
||||
private readonly ISettingsService<EmbySettings> _embySettings;
|
||||
private readonly IEmbyApi _embyApi;
|
||||
private readonly IHubContext<NotificationHub> _notification;
|
||||
|
||||
public async Task Execute(IJobExecutionContext job)
|
||||
{
|
||||
_log.LogInformation("Starting the Metadata refresh");
|
||||
|
||||
await _notification.Clients.Clients(NotificationHub.AdminConnectionIds)
|
||||
.SendAsync(NotificationHub.NotificationEvent, "Metadata Refresh Started");
|
||||
try
|
||||
{
|
||||
var settings = await _plexSettings.GetSettingsAsync();
|
||||
|
@ -64,8 +71,14 @@ namespace Ombi.Schedule.Jobs.Ombi
|
|||
catch (Exception e)
|
||||
{
|
||||
_log.LogError(e, "Exception when refreshing the Plex Metadata");
|
||||
|
||||
await _notification.Clients.Clients(NotificationHub.AdminConnectionIds)
|
||||
.SendAsync(NotificationHub.NotificationEvent, "Metadata Refresh Failed");
|
||||
throw;
|
||||
}
|
||||
|
||||
await _notification.Clients.Clients(NotificationHub.AdminConnectionIds)
|
||||
.SendAsync(NotificationHub.NotificationEvent, "Metadata Refresh Finished");
|
||||
}
|
||||
|
||||
public async Task ProcessPlexServerContent(IEnumerable<int> contentIds)
|
||||
|
|
|
@ -3,10 +3,12 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Hangfire;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Ombi.Core.Notifications;
|
||||
using Ombi.Helpers;
|
||||
using Ombi.Hubs;
|
||||
using Ombi.Notifications.Models;
|
||||
using Ombi.Store.Entities;
|
||||
using Ombi.Store.Entities.Requests;
|
||||
|
@ -19,7 +21,7 @@ namespace Ombi.Schedule.Jobs.Plex
|
|||
public class PlexAvailabilityChecker : IPlexAvailabilityChecker
|
||||
{
|
||||
public PlexAvailabilityChecker(IPlexContentRepository repo, ITvRequestRepository tvRequest, IMovieRequestRepository movies,
|
||||
INotificationService notification, IBackgroundJobClient background, ILogger<PlexAvailabilityChecker> log)
|
||||
INotificationService notification, IBackgroundJobClient background, ILogger<PlexAvailabilityChecker> log, IHubContext<NotificationHub> hub)
|
||||
{
|
||||
_tvRepo = tvRequest;
|
||||
_repo = repo;
|
||||
|
@ -27,6 +29,7 @@ namespace Ombi.Schedule.Jobs.Plex
|
|||
_notificationService = notification;
|
||||
_backgroundJobClient = background;
|
||||
_log = log;
|
||||
_notification = hub;
|
||||
}
|
||||
|
||||
private readonly ITvRequestRepository _tvRepo;
|
||||
|
@ -35,18 +38,27 @@ namespace Ombi.Schedule.Jobs.Plex
|
|||
private readonly INotificationService _notificationService;
|
||||
private readonly IBackgroundJobClient _backgroundJobClient;
|
||||
private readonly ILogger _log;
|
||||
private readonly IHubContext<NotificationHub> _notification;
|
||||
|
||||
public async Task Execute(IJobExecutionContext job)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
await _notification.Clients.Clients(NotificationHub.AdminConnectionIds)
|
||||
.SendAsync(NotificationHub.NotificationEvent, "Plex Availability Check Started");
|
||||
await ProcessMovies();
|
||||
await ProcessTv();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
await _notification.Clients.Clients(NotificationHub.AdminConnectionIds)
|
||||
.SendAsync(NotificationHub.NotificationEvent, "Plex Availability Check Failed");
|
||||
_log.LogError(e, "Exception thrown in Plex availbility checker");
|
||||
}
|
||||
|
||||
await _notification.Clients.Clients(NotificationHub.AdminConnectionIds)
|
||||
.SendAsync(NotificationHub.NotificationEvent, "Plex Availability Check Finished");
|
||||
}
|
||||
|
||||
private Task ProcessTv()
|
||||
|
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Hangfire;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Ombi.Api.Plex;
|
||||
|
@ -10,6 +11,7 @@ using Ombi.Api.Plex.Models;
|
|||
using Ombi.Core.Settings;
|
||||
using Ombi.Core.Settings.Models.External;
|
||||
using Ombi.Helpers;
|
||||
using Ombi.Hubs;
|
||||
using Ombi.Schedule.Jobs.Plex.Interfaces;
|
||||
using Ombi.Store.Entities;
|
||||
using Ombi.Store.Repository;
|
||||
|
@ -20,12 +22,13 @@ namespace Ombi.Schedule.Jobs.Plex
|
|||
public class PlexEpisodeSync : IPlexEpisodeSync
|
||||
{
|
||||
public PlexEpisodeSync(ISettingsService<PlexSettings> s, ILogger<PlexEpisodeSync> log, IPlexApi plexApi,
|
||||
IPlexContentRepository repo)
|
||||
IPlexContentRepository repo, IHubContext<NotificationHub> hub)
|
||||
{
|
||||
_settings = s;
|
||||
_log = log;
|
||||
_api = plexApi;
|
||||
_repo = repo;
|
||||
_notification = hub;
|
||||
_settings.ClearCache();
|
||||
}
|
||||
|
||||
|
@ -33,6 +36,7 @@ namespace Ombi.Schedule.Jobs.Plex
|
|||
private readonly ILogger<PlexEpisodeSync> _log;
|
||||
private readonly IPlexApi _api;
|
||||
private readonly IPlexContentRepository _repo;
|
||||
private readonly IHubContext<NotificationHub> _notification;
|
||||
|
||||
public async Task Execute(IJobExecutionContext job)
|
||||
{
|
||||
|
@ -43,6 +47,8 @@ namespace Ombi.Schedule.Jobs.Plex
|
|||
{
|
||||
return;
|
||||
}
|
||||
await _notification.Clients.Clients(NotificationHub.AdminConnectionIds)
|
||||
.SendAsync(NotificationHub.NotificationEvent, "Plex Episode Sync Started");
|
||||
|
||||
foreach (var server in s.Servers)
|
||||
{
|
||||
|
@ -52,11 +58,15 @@ namespace Ombi.Schedule.Jobs.Plex
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
await _notification.Clients.Clients(NotificationHub.AdminConnectionIds)
|
||||
.SendAsync(NotificationHub.NotificationEvent, "Plex Episode Sync Failed");
|
||||
_log.LogError(LoggingEvents.Cacher, e, "Caching Episodes Failed");
|
||||
}
|
||||
|
||||
|
||||
await OmbiQuartz.TriggerJob(nameof(IPlexAvailabilityChecker), "Plex");
|
||||
await _notification.Clients.Clients(NotificationHub.AdminConnectionIds)
|
||||
.SendAsync(NotificationHub.NotificationEvent, "Plex Episode Sync Finished");
|
||||
}
|
||||
|
||||
private async Task Cache(PlexServers settings)
|
||||
|
|
|
@ -3,12 +3,14 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Ombi.Api.Plex;
|
||||
using Ombi.Core.Settings;
|
||||
using Ombi.Core.Settings.Models.External;
|
||||
using Ombi.Helpers;
|
||||
using Ombi.Hubs;
|
||||
using Ombi.Settings.Settings.Models;
|
||||
using Ombi.Store.Entities;
|
||||
using Quartz;
|
||||
|
@ -18,13 +20,14 @@ namespace Ombi.Schedule.Jobs.Plex
|
|||
public class PlexUserImporter : IPlexUserImporter
|
||||
{
|
||||
public PlexUserImporter(IPlexApi api, UserManager<OmbiUser> um, ILogger<PlexUserImporter> log,
|
||||
ISettingsService<PlexSettings> plexSettings, ISettingsService<UserManagementSettings> ums)
|
||||
ISettingsService<PlexSettings> plexSettings, ISettingsService<UserManagementSettings> ums, IHubContext<NotificationHub> hub)
|
||||
{
|
||||
_api = api;
|
||||
_userManager = um;
|
||||
_log = log;
|
||||
_plexSettings = plexSettings;
|
||||
_userManagementSettings = ums;
|
||||
_notification = hub;
|
||||
_plexSettings.ClearCache();
|
||||
_userManagementSettings.ClearCache();
|
||||
}
|
||||
|
@ -34,6 +37,7 @@ namespace Ombi.Schedule.Jobs.Plex
|
|||
private readonly ILogger<PlexUserImporter> _log;
|
||||
private readonly ISettingsService<PlexSettings> _plexSettings;
|
||||
private readonly ISettingsService<UserManagementSettings> _userManagementSettings;
|
||||
private readonly IHubContext<NotificationHub> _notification;
|
||||
|
||||
|
||||
public async Task Execute(IJobExecutionContext job)
|
||||
|
@ -50,6 +54,8 @@ namespace Ombi.Schedule.Jobs.Plex
|
|||
}
|
||||
|
||||
|
||||
await _notification.Clients.Clients(NotificationHub.AdminConnectionIds)
|
||||
.SendAsync(NotificationHub.NotificationEvent, "Plex User Importer Started");
|
||||
var allUsers = await _userManager.Users.Where(x => x.UserType == UserType.PlexUser).ToListAsync();
|
||||
foreach (var server in settings.Servers)
|
||||
{
|
||||
|
@ -121,6 +127,9 @@ namespace Ombi.Schedule.Jobs.Plex
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
await _notification.Clients.Clients(NotificationHub.AdminConnectionIds)
|
||||
.SendAsync(NotificationHub.NotificationEvent, "Plex User Importer Finished");
|
||||
}
|
||||
|
||||
private async Task ImportAdmin(UserManagementSettings settings, PlexServers server, List<OmbiUser> allUsers)
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Dapper" Version="1.50.2" />
|
||||
<PackageReference Include="Hangfire" Version="1.6.22" />
|
||||
<PackageReference Include="Hangfire.AspNetCore" Version="1.6.22" />
|
||||
<PackageReference Include="Hangfire" Version="1.7.1" />
|
||||
<PackageReference Include="Hangfire.AspNetCore" Version="1.7.1" />
|
||||
<PackageReference Include="Hangfire.Console" Version="1.3.10" />
|
||||
<PackageReference Include="Hangfire.MemoryStorage.Core" Version="1.4.0" />
|
||||
<PackageReference Include="Hangfire.RecurringJobExtensions" Version="1.1.6" />
|
||||
|
|
|
@ -76,6 +76,8 @@ namespace Ombi.Schedule
|
|||
await OmbiQuartz.Instance.AddJob<ICouchPotatoSync>(nameof(ICouchPotatoSync), "DVR", JobSettingsHelper.CouchPotato(s));
|
||||
await OmbiQuartz.Instance.AddJob<ISickRageSync>(nameof(ISickRageSync), "DVR", JobSettingsHelper.SickRageSync(s));
|
||||
await OmbiQuartz.Instance.AddJob<ILidarrArtistSync>(nameof(ILidarrArtistSync), "DVR", JobSettingsHelper.LidarrArtistSync(s));
|
||||
await OmbiQuartz.Instance.AddJob<ILidarrAlbumSync>(nameof(ILidarrAlbumSync), "DVR", null);
|
||||
await OmbiQuartz.Instance.AddJob<ILidarrAvailabilityChecker>(nameof(ILidarrAvailabilityChecker), "DVR", null);
|
||||
}
|
||||
|
||||
private static async Task AddPlex(JobSettings s)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||
|
@ -10,6 +10,7 @@
|
|||
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="2.2.0" />
|
||||
<PackageReference Include="Moq" Version="4.10.0" />
|
||||
<PackageReference Include="Nunit" Version="3.11.0" />
|
||||
<PackageReference Include="Hangfire" Version="1.7.1" />
|
||||
<PackageReference Include="NUnit.ConsoleRunner" Version="3.9.0" />
|
||||
<PackageReference Include="NUnit3TestAdapter" Version="3.13.0" />
|
||||
<packagereference Include="Microsoft.NET.Test.Sdk" Version="16.0.1"></packagereference>
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
<ItemGroup>
|
||||
<PackageReference Include="AutoMapper" Version="6.1.1" />
|
||||
<PackageReference Include="CommandLineParser" Version="2.4.3" />
|
||||
<PackageReference Include="Hangfire.AspNetCore" Version="1.7.0" />
|
||||
<PackageReference Include="Hangfire.AspNetCore" Version="1.7.1" />
|
||||
<PackageReference Include="Hangfire.Console" Version="1.4.2" />
|
||||
<PackageReference Include="Hangfire.MemoryStorage.Core" Version="1.4.0" />
|
||||
<PackageReference Include="Hangfire.RecurringJobExtensions" Version="1.1.6" />
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue