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