Trigger a metadata refresh when we finish scanning the libraries

pull/2225/head
Jamie Rees 7 years ago
parent 6b2e9760e3
commit 0c7a13f728

@ -9,6 +9,7 @@ using Ombi.Api.Emby.Models.Movie;
using Ombi.Core.Settings;
using Ombi.Core.Settings.Models.External;
using Ombi.Helpers;
using Ombi.Schedule.Jobs.Ombi;
using Ombi.Store.Entities;
using Ombi.Store.Repository;
using Serilog;
@ -19,13 +20,14 @@ namespace Ombi.Schedule.Jobs.Emby
public class EmbyContentSync : IEmbyContentSync
{
public EmbyContentSync(ISettingsService<EmbySettings> settings, IEmbyApi api, ILogger<EmbyContentSync> logger,
IEmbyContentRepository repo, IEmbyEpisodeSync epSync)
IEmbyContentRepository repo, IEmbyEpisodeSync epSync, IRefreshMetadata metadata)
{
_logger = logger;
_settings = settings;
_api = api;
_repo = repo;
_episodeSync = epSync;
_metadata = metadata;
_settings.ClearCache();
}
@ -34,6 +36,7 @@ namespace Ombi.Schedule.Jobs.Emby
private readonly IEmbyApi _api;
private readonly IEmbyContentRepository _repo;
private readonly IEmbyEpisodeSync _episodeSync;
private readonly IRefreshMetadata _metadata;
public async Task Start()
@ -56,6 +59,7 @@ namespace Ombi.Schedule.Jobs.Emby
// Episodes
BackgroundJob.Enqueue(() => _episodeSync.Start());
BackgroundJob.Enqueue(() => _metadata.Start());
}

@ -37,6 +37,7 @@ using Ombi.Api.Plex.Models;
using Ombi.Core.Settings;
using Ombi.Core.Settings.Models.External;
using Ombi.Helpers;
using Ombi.Schedule.Jobs.Ombi;
using Ombi.Schedule.Jobs.Plex.Interfaces;
using Ombi.Store.Entities;
using Ombi.Store.Repository;
@ -46,13 +47,14 @@ namespace Ombi.Schedule.Jobs.Plex
public class PlexContentSync : IPlexContentSync
{
public PlexContentSync(ISettingsService<PlexSettings> plex, IPlexApi plexApi, ILogger<PlexContentSync> logger, IPlexContentRepository repo,
IPlexEpisodeSync epsiodeSync)
IPlexEpisodeSync epsiodeSync, IRefreshMetadata metadataRefresh)
{
Plex = plex;
PlexApi = plexApi;
Logger = logger;
Repo = repo;
EpisodeSync = epsiodeSync;
Metadata = metadataRefresh;
plex.ClearCache();
}
@ -61,6 +63,7 @@ namespace Ombi.Schedule.Jobs.Plex
private ILogger<PlexContentSync> Logger { get; }
private IPlexContentRepository Repo { get; }
private IPlexEpisodeSync EpisodeSync { get; }
private IRefreshMetadata Metadata { get; }
public async Task CacheContent(bool recentlyAddedSearch = false)
{
@ -87,6 +90,7 @@ namespace Ombi.Schedule.Jobs.Plex
Logger.LogInformation("Starting EP Cacher");
BackgroundJob.Enqueue(() => EpisodeSync.Start());
BackgroundJob.Enqueue(() => Metadata.Start());
}
private async Task StartTheCache(PlexSettings plexSettings, bool recentlyAddedSearch)

@ -50,12 +50,13 @@ namespace Ombi.Schedule.Jobs.Plex
await Cache(server);
}
BackgroundJob.Enqueue(() => _availabilityChecker.Start());
}
catch (Exception e)
{
_log.LogError(LoggingEvents.Cacher, e, "Caching Episodes Failed");
}
BackgroundJob.Enqueue(() => _availabilityChecker.Start());
}
private async Task Cache(PlexServers settings)

@ -21,7 +21,7 @@ namespace Ombi.Settings.Settings.Models
}
public static string PlexContent(JobSettings s)
{
return Get(s.PlexContentSync, Cron.HourInterval(6));
return Get(s.PlexContentSync, Cron.Daily(2));
}
public static string PlexRecentlyAdded(JobSettings s)
{
@ -50,7 +50,7 @@ namespace Ombi.Settings.Settings.Models
}
public static string RefreshMetadata(JobSettings s)
{
return Get(s.RefreshMetadata, Cron.Daily(3));
return Get(s.RefreshMetadata, Cron.DayInterval(2));
}
private static string Get(string settings, string defaultCron)

Loading…
Cancel
Save