feat(emby): Added a emby recently added sync!

pull/4412/head
tidusjar 3 years ago
parent d9ee25b575
commit a0e14068f4

@ -1,12 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore.Internal;
using Newtonsoft.Json;
using Ombi.Api.Emby.Models;
using Ombi.Api.Emby.Models.Media;
using Ombi.Api.Emby.Models.Media.Tv;
using Ombi.Api.Emby.Models.Movie;
using Ombi.Helpers;
@ -124,22 +120,36 @@ namespace Ombi.Api.Emby
return response;
}
public async Task<EmbyItemContainer<EmbyMovie>> GetAllMovies(string apiKey, string parentIdFilder, int startIndex, int count, string userId, string baseUri)
{
return await GetAll<EmbyMovie>("Movie", apiKey, userId, baseUri, true, startIndex, count, parentIdFilder);
}
public async Task<EmbyItemContainer<EmbyMovie>> RecentlyAddedMovies(string apiKey, string parentIdFilder, int startIndex, int count, string userId, string baseUri)
{
return await RecentlyAdded<EmbyMovie>("Movie", apiKey, userId, baseUri, true, startIndex, count, parentIdFilder);
}
public async Task<EmbyItemContainer<EmbyEpisodes>> GetAllEpisodes(string apiKey, string parentIdFilder, int startIndex, int count, string userId, string baseUri)
{
return await GetAll<EmbyEpisodes>("Episode", apiKey, userId, baseUri, false, startIndex, count, parentIdFilder);
}
public async Task<EmbyItemContainer<EmbyEpisodes>> RecentlyAddedEpisodes(string apiKey, string parentIdFilder, int startIndex, int count, string userId, string baseUri)
{
return await RecentlyAdded<EmbyEpisodes>("Episode", apiKey, userId, baseUri, false, startIndex, count, parentIdFilder);
}
public async Task<EmbyItemContainer<EmbySeries>> GetAllShows(string apiKey, string parentIdFilder, int startIndex, int count, string userId, string baseUri)
{
return await GetAll<EmbySeries>("Series", apiKey, userId, baseUri, false, startIndex, count, parentIdFilder);
}
public async Task<EmbyItemContainer<EmbySeries>> RecentlyAddedShows(string apiKey, string parentIdFilder, int startIndex, int count, string userId, string baseUri)
{
return await RecentlyAdded<EmbySeries>("Series", apiKey, userId, baseUri, false, startIndex, count, parentIdFilder);
}
public async Task<SeriesInformation> GetSeriesInformation(string mediaId, string apiKey, string userId, string baseUrl)
{
return await GetInformation<SeriesInformation>(mediaId, apiKey, userId, baseUrl);
@ -154,6 +164,31 @@ namespace Ombi.Api.Emby
return await GetInformation<EpisodeInformation>(mediaId, apiKey, userId, baseUrl);
}
private async Task<EmbyItemContainer<T>> RecentlyAdded<T>(string type, string apiKey, string userId, string baseUri, bool includeOverview, int startIndex, int count, string parentIdFilder = default)
{
var request = new Request($"emby/users/{userId}/items", baseUri, HttpMethod.Get);
request.AddQueryString("Recursive", true.ToString());
request.AddQueryString("IncludeItemTypes", type);
request.AddQueryString("Fields", includeOverview ? "ProviderIds,Overview" : "ProviderIds");
request.AddQueryString("startIndex", startIndex.ToString());
request.AddQueryString("limit", count.ToString());
request.AddQueryString("sortBy", "DateCreated");
request.AddQueryString("SortOrder", "Descending");
if (!string.IsNullOrEmpty(parentIdFilder))
{
request.AddQueryString("ParentId", parentIdFilder);
}
request.AddQueryString("IsVirtualItem", "False");
AddHeaders(request, apiKey);
var obj = await Api.Request<EmbyItemContainer<T>>(request);
return obj;
}
private async Task<T> GetInformation<T>(string mediaId, string apiKey, string userId, string baseUrl)
{
var request = new Request($"emby/users/{userId}/items/{mediaId}", baseUrl, HttpMethod.Get);

@ -29,5 +29,8 @@ namespace Ombi.Api.Emby
Task<MovieInformation> GetMovieInformation(string mediaId, string apiKey, string userId, string baseUrl);
Task<EpisodeInformation> GetEpisodeInformation(string mediaId, string apiKey, string userId, string baseUrl);
Task<PublicInfo> GetPublicInformation(string baseUrl);
Task<EmbyItemContainer<EmbyMovie>> RecentlyAddedMovies(string apiKey, string parentIdFilder, int startIndex, int count, string userId, string baseUri);
Task<EmbyItemContainer<EmbyEpisodes>> RecentlyAddedEpisodes(string apiKey, string parentIdFilder, int startIndex, int count, string userId, string baseUri);
Task<EmbyItemContainer<EmbySeries>> RecentlyAddedShows(string apiKey, string parentIdFilder, int startIndex, int count, string userId, string baseUri);
}
}

@ -3,6 +3,7 @@
public class JobDataKeys
{
public const string RecentlyAddedSearch = "recentlyAddedSearch";
public const string EmbyRecentlyAddedSearch = nameof(EmbyRecentlyAddedSearch);
public const string NotificationOptions = nameof(NotificationOptions);
}
}

@ -5,6 +5,8 @@ using System.Threading.Tasks;
using Microsoft.AspNetCore.SignalR;
using Microsoft.Extensions.Logging;
using Ombi.Api.Emby;
using Ombi.Api.Emby.Models;
using Ombi.Api.Emby.Models.Media.Tv;
using Ombi.Api.Emby.Models.Movie;
using Ombi.Core.Settings;
using Ombi.Core.Settings.Models.External;
@ -36,24 +38,33 @@ namespace Ombi.Schedule.Jobs.Emby
private readonly IEmbyContentRepository _repo;
private readonly IHubContext<NotificationHub> _notification;
private const int AmountToTake = 100;
private IEmbyApi Api { get; set; }
public async Task Execute(IJobExecutionContext job)
public async Task Execute(IJobExecutionContext context)
{
JobDataMap dataMap = context.JobDetail.JobDataMap;
var recentlyAddedSearch = false;
if (dataMap.TryGetValue(JobDataKeys.EmbyRecentlyAddedSearch, out var recentlyAddedObj))
{
recentlyAddedSearch = Convert.ToBoolean(recentlyAddedObj);
}
var embySettings = await _settings.GetSettingsAsync();
if (!embySettings.Enable)
return;
Api = _apiFactory.CreateClient(embySettings);
await _notification.Clients.Clients(NotificationHub.AdminConnectionIds)
.SendAsync(NotificationHub.NotificationEvent, "Emby Content Sync Started");
.SendAsync(NotificationHub.NotificationEvent, recentlyAddedSearch ? "Emby Recently Added Started" : "Emby Content Sync Started");
foreach (var server in embySettings.Servers)
{
try
{
await StartServerCache(server, embySettings);
await StartServerCache(server, recentlyAddedSearch);
}
catch (Exception e)
{
@ -67,11 +78,12 @@ namespace Ombi.Schedule.Jobs.Emby
.SendAsync(NotificationHub.NotificationEvent, "Emby Content Sync Finished");
// Episodes
await OmbiQuartz.TriggerJob(nameof(IEmbyEpisodeSync), "Emby");
await OmbiQuartz.Scheduler.TriggerJob(new JobKey(nameof(IEmbyEpisodeSync), "Emby"), new JobDataMap(new Dictionary<string, string> { { JobDataKeys.EmbyRecentlyAddedSearch, "true" } }));
}
private async Task StartServerCache(EmbyServers server, EmbySettings settings)
private async Task StartServerCache(EmbyServers server, bool recentlyAdded)
{
if (!ValidateSettings(server))
return;
@ -86,14 +98,14 @@ namespace Ombi.Schedule.Jobs.Emby
foreach (var movieParentIdFilder in movieLibsToFilter)
{
_logger.LogInformation($"Scanning Lib '{movieParentIdFilder.Title}'");
await ProcessMovies(server, movieParentIdFilder.Key);
await ProcessMovies(server, recentlyAdded, movieParentIdFilder.Key);
}
var tvLibsToFilter = server.EmbySelectedLibraries.Where(x => x.Enabled && x.CollectionType == "tvshows");
foreach (var tvParentIdFilter in tvLibsToFilter)
{
_logger.LogInformation($"Scanning Lib '{tvParentIdFilter.Title}'");
await ProcessTv(server, tvParentIdFilter.Key);
await ProcessTv(server, recentlyAdded, tvParentIdFilter.Key);
}
@ -101,68 +113,74 @@ namespace Ombi.Schedule.Jobs.Emby
foreach (var m in mixedLibs)
{
_logger.LogInformation($"Scanning Lib '{m.Title}'");
await ProcessTv(server, m.Key);
await ProcessMovies(server, m.Key);
await ProcessTv(server, recentlyAdded, m.Key);
await ProcessMovies(server, recentlyAdded, m.Key);
}
}
else
{
await ProcessMovies(server);
await ProcessTv(server);
await ProcessMovies(server, recentlyAdded);
await ProcessTv(server, recentlyAdded);
}
}
private async Task ProcessTv(EmbyServers server, string parentId = default)
private async Task ProcessTv(EmbyServers server, bool recentlyAdded, string parentId = default)
{
// TV Time
var mediaToAdd = new HashSet<EmbyContent>();
var tv = await Api.GetAllShows(server.ApiKey, parentId, 0, 200, server.AdministratorId, server.FullUri);
EmbyItemContainer<EmbySeries> tv;
if (recentlyAdded)
{
var recentlyAddedAmountToTake = AmountToTake / 2;
tv = await Api.RecentlyAddedShows(server.ApiKey, parentId, 0, recentlyAddedAmountToTake, server.AdministratorId, server.FullUri);
if (tv.TotalRecordCount > recentlyAddedAmountToTake)
{
tv.TotalRecordCount = recentlyAddedAmountToTake;
}
}
else
{
tv = await Api.GetAllShows(server.ApiKey, parentId, 0, AmountToTake, server.AdministratorId, server.FullUri);
}
var totalTv = tv.TotalRecordCount;
var processed = 1;
while (processed < totalTv)
{
foreach (var tvShow in tv.Items)
{
try
processed++;
if (string.IsNullOrEmpty(tvShow.ProviderIds?.Tvdb))
{
_logger.LogInformation("Provider Id on tv {0} is null", tvShow.Name);
continue;
}
processed++;
if (string.IsNullOrEmpty(tvShow.ProviderIds?.Tvdb))
{
_logger.LogInformation("Provider Id on tv {0} is null", tvShow.Name);
continue;
}
var existingTv = await _repo.GetByEmbyId(tvShow.Id);
if (existingTv == null)
{
_logger.LogDebug("Adding new TV Show {0}", tvShow.Name);
mediaToAdd.Add(new EmbyContent
{
TvDbId = tvShow.ProviderIds?.Tvdb,
ImdbId = tvShow.ProviderIds?.Imdb,
TheMovieDbId = tvShow.ProviderIds?.Tmdb,
Title = tvShow.Name,
Type = EmbyMediaType.Series,
EmbyId = tvShow.Id,
Url = EmbyHelper.GetEmbyMediaUrl(tvShow.Id, server?.ServerId, server.ServerHostname),
AddedAt = DateTime.UtcNow
});
}
else
var existingTv = await _repo.GetByEmbyId(tvShow.Id);
if (existingTv == null)
{
_logger.LogDebug("Adding new TV Show {0}", tvShow.Name);
mediaToAdd.Add(new EmbyContent
{
_logger.LogDebug("We already have TV Show {0}", tvShow.Name);
}
TvDbId = tvShow.ProviderIds?.Tvdb,
ImdbId = tvShow.ProviderIds?.Imdb,
TheMovieDbId = tvShow.ProviderIds?.Tmdb,
Title = tvShow.Name,
Type = EmbyMediaType.Series,
EmbyId = tvShow.Id,
Url = EmbyHelper.GetEmbyMediaUrl(tvShow.Id, server?.ServerId, server.ServerHostname),
AddedAt = DateTime.UtcNow
});
}
catch (Exception)
else
{
throw;
_logger.LogDebug("We already have TV Show {0}", tvShow.Name);
}
}
// Get the next batch
tv = await Api.GetAllShows(server.ApiKey, parentId, processed, 200, server.AdministratorId, server.FullUri);
if (!recentlyAdded)
{
tv = await Api.GetAllShows(server.ApiKey, parentId, processed, AmountToTake, server.AdministratorId, server.FullUri);
}
await _repo.AddRange(mediaToAdd);
mediaToAdd.Clear();
}
@ -171,9 +189,23 @@ namespace Ombi.Schedule.Jobs.Emby
await _repo.AddRange(mediaToAdd);
}
private async Task ProcessMovies(EmbyServers server, string parentId = default)
private async Task ProcessMovies(EmbyServers server, bool recentlyAdded, string parentId = default)
{
var movies = await Api.GetAllMovies(server.ApiKey, parentId, 0, 200, server.AdministratorId, server.FullUri);
EmbyItemContainer<EmbyMovie> movies;
if (recentlyAdded)
{
var recentlyAddedAmountToTake = AmountToTake / 2;
movies = await Api.RecentlyAddedMovies(server.ApiKey, parentId, 0, recentlyAddedAmountToTake, server.AdministratorId, server.FullUri);
// Setting this so we don't attempt to grab more than we need
if (movies.TotalRecordCount > recentlyAddedAmountToTake)
{
movies.TotalRecordCount = recentlyAddedAmountToTake;
}
}
else
{
movies = await Api.GetAllMovies(server.ApiKey, parentId, 0, AmountToTake, server.AdministratorId, server.FullUri);
}
var totalCount = movies.TotalRecordCount;
var processed = 1;
var mediaToAdd = new HashSet<EmbyContent>();
@ -189,22 +221,25 @@ namespace Ombi.Schedule.Jobs.Emby
{
await ProcessMovies(item, mediaToAdd, server);
}
processed++;
}
else
{
processed++;
// Regular movie
await ProcessMovies(movie, mediaToAdd, server);
}
processed++;
}
// Get the next batch
movies = await Api.GetAllMovies(server.ApiKey, parentId, processed, 200, server.AdministratorId, server.FullUri);
// Recently Added should never be checked as the TotalRecords should equal the amount to take
if (!recentlyAdded)
{
movies = await Api.GetAllMovies(server.ApiKey, parentId, processed, AmountToTake, server.AdministratorId, server.FullUri);
}
else
await _repo.AddRange(mediaToAdd);
mediaToAdd.Clear();
}
}

@ -40,6 +40,8 @@ using Ombi.Store.Entities;
using Ombi.Store.Repository;
using Quartz;
using Ombi.Schedule.Jobs.Ombi;
using Ombi.Api.Emby.Models;
using Ombi.Api.Emby.Models.Media.Tv;
namespace Ombi.Schedule.Jobs.Emby
{
@ -61,13 +63,22 @@ namespace Ombi.Schedule.Jobs.Emby
private readonly IEmbyContentRepository _repo;
private readonly IHubContext<NotificationHub> _notification;
private const int AmountToTake = 100;
private IEmbyApi Api { get; set; }
public async Task Execute(IJobExecutionContext job)
public async Task Execute(IJobExecutionContext context)
{
JobDataMap dataMap = context.MergedJobDataMap;
var recentlyAddedSearch = false;
if (dataMap.TryGetValue(JobDataKeys.EmbyRecentlyAddedSearch, out var recentlyAddedObj))
{
recentlyAddedSearch = Convert.ToBoolean(recentlyAddedObj);
}
var settings = await _settings.GetSettingsAsync();
Api = _apiFactory.CreateClient(settings);
await _notification.Clients.Clients(NotificationHub.AdminConnectionIds)
.SendAsync(NotificationHub.NotificationEvent, "Emby Episode Sync Started");
@ -79,12 +90,12 @@ namespace Ombi.Schedule.Jobs.Emby
foreach (var tvParentIdFilter in tvLibsToFilter)
{
_logger.LogInformation($"Scanning Lib for episodes '{tvParentIdFilter.Title}'");
await CacheEpisodes(server, tvParentIdFilter.Key);
await CacheEpisodes(server, recentlyAddedSearch, tvParentIdFilter.Key);
}
}
else
{
await CacheEpisodes(server, string.Empty);
await CacheEpisodes(server, recentlyAddedSearch, string.Empty);
}
}
@ -94,9 +105,22 @@ namespace Ombi.Schedule.Jobs.Emby
await OmbiQuartz.TriggerJob(nameof(IRefreshMetadata), "System");
}
private async Task CacheEpisodes(EmbyServers server, string parentIdFilter)
private async Task CacheEpisodes(EmbyServers server, bool recentlyAdded, string parentIdFilter)
{
var allEpisodes = await Api.GetAllEpisodes(server.ApiKey, parentIdFilter, 0, 200, server.AdministratorId, server.FullUri);
EmbyItemContainer<EmbyEpisodes> allEpisodes;
if (recentlyAdded)
{
var recentlyAddedAmountToTake = AmountToTake;
allEpisodes = await Api.RecentlyAddedEpisodes(server.ApiKey, parentIdFilter, 0, recentlyAddedAmountToTake, server.AdministratorId, server.FullUri);
if (allEpisodes.TotalRecordCount > recentlyAddedAmountToTake)
{
allEpisodes.TotalRecordCount = recentlyAddedAmountToTake;
}
}
else
{
allEpisodes = await Api.GetAllEpisodes(server.ApiKey, parentIdFilter, 0, AmountToTake, server.AdministratorId, server.FullUri);
}
var total = allEpisodes.TotalRecordCount;
var processed = 1;
var epToAdd = new HashSet<EmbyEpisode>();
@ -163,7 +187,10 @@ namespace Ombi.Schedule.Jobs.Emby
await _repo.AddRange(epToAdd);
epToAdd.Clear();
allEpisodes = await Api.GetAllEpisodes(server.ApiKey, parentIdFilter, processed, 200, server.AdministratorId, server.FullUri);
if (!recentlyAdded)
{
allEpisodes = await Api.GetAllEpisodes(server.ApiKey, parentIdFilter, processed, AmountToTake, server.AdministratorId, server.FullUri);
}
}
if (epToAdd.Any())

@ -96,6 +96,7 @@ namespace Ombi.Schedule
private static async Task AddEmby(JobSettings s)
{
await OmbiQuartz.Instance.AddJob<IEmbyContentSync>(nameof(IEmbyContentSync), "Emby", JobSettingsHelper.EmbyContent(s));
await OmbiQuartz.Instance.AddJob<IEmbyContentSync>(nameof(IEmbyContentSync) + "RecentlyAdded", "Emby", JobSettingsHelper.EmbyRecentlyAddedSync(s), new Dictionary<string, string> { { JobDataKeys.EmbyRecentlyAddedSearch, "true" } });
await OmbiQuartz.Instance.AddJob<IEmbyEpisodeSync>(nameof(IEmbyEpisodeSync), "Emby", null);
await OmbiQuartz.Instance.AddJob<IEmbyAvaliabilityChecker>(nameof(IEmbyAvaliabilityChecker), "Emby", null);
await OmbiQuartz.Instance.AddJob<IEmbyUserImporter>(nameof(IEmbyUserImporter), "Emby", JobSettingsHelper.UserImporter(s));

@ -3,6 +3,7 @@
public class JobSettings : Settings
{
public string EmbyContentSync { get; set; }
public string EmbyRecentlyAddedSync { get; set; }
public string JellyfinContentSync { get; set; }
public string SonarrSync { get; set; }
public string RadarrSync { get; set; }

@ -1,5 +1,4 @@
using System;
using Ombi.Helpers;
using Ombi.Helpers;
using Quartz;
namespace Ombi.Settings.Settings.Models
@ -18,7 +17,12 @@ namespace Ombi.Settings.Settings.Models
public static string EmbyContent(JobSettings s)
{
return ValidateCron(Get(s.EmbyContentSync, Cron.Hourly(5)));
return ValidateCron(Get(s.EmbyContentSync, Cron.Daily(2)));
}
public static string EmbyRecentlyAddedSync(JobSettings s)
{
return ValidateCron(Get(s.EmbyRecentlyAddedSync, Cron.Hourly(30)));
}
public static string JellyfinContent(JobSettings s)

@ -18,6 +18,7 @@
"user-management",
"newsletter",
"mass-email",
"issues"
"issues",
"emby"
]
}

@ -212,6 +212,7 @@ export interface IJobSettings {
retryRequests: string;
mediaDatabaseRefresh: string;
autoDeleteRequests: string;
embyRecentlyAddedSync: string;
}
export interface IIssueSettings extends ISettings {

@ -43,6 +43,10 @@ export class JobService extends ServiceHelpers {
return this.http.post<boolean>(`${this.url}plexrecentlyadded/`, {headers: this.headers});
}
public runEmbyRecentlyAddedCacher(): Observable<boolean> {
return this.http.post<boolean>(`${this.url}embyrecentlyadded/`, {headers: this.headers});
}
public clearMediaserverData(): Observable<boolean> {
return this.http.post<boolean>(`${this.url}clearmediaserverdata/`, {headers: this.headers});
}

@ -105,12 +105,29 @@
<button mat-raised-button id="discover" type="button" (click)="discoverServerInfo(server)" class="mat-focus-indicator mat-stroked-button mat-button-base">Discover Server Information <div id="spinner"></div></button>
</div>
</div>
<div class="form-group">
<div>
<button mat-raised-button (click)="runCacher()" type="button" id="save" class="mat-focus-indicator mat-stroked-button mat-button-base">Manually Run Full Sync</button>
</div>
</div>
<div class="form-group">
<button mat-raised-button (click)="runRecentlyAddedCacher()" type="button" id="recentlyAddedSync"
class="mat-focus-indicator mat-stroked-button mat-button-base">Manually Run Recently
Added Sync</button>
</div>
<div class="form-group">
<button mat-raised-button (click)="clearDataAndResync()" type="button" id="clearData"
class="mat-focus-indicator mat-stroked-button mat-button-base">
Clear Data And Resync
</button>
</div>
</div>
</mat-tab>
<mat-tab label="" disabled=true> </mat-tab>
<mat-tab label="Add Server" position=100> </mat-tab>
</mat-tab-group>
<div class="row">
<div class="col-md-2">
<div class="form-group">
<div>
@ -118,19 +135,8 @@
</div>
</div>
</div>
<div class="col-md-2">
<div class="form-group">
<div>
<button mat-raised-button (click)="runCacher()" type="button" id="save" class="mat-focus-indicator mat-stroked-button mat-button-base">Manually Run Cacher</button>
</div>
</div>
<div class="form-group">
<button mat-raised-button (click)="clearDataAndResync()" type="button" id="clearData"
class="mat-focus-indicator mat-stroked-button mat-button-base">
Clear Data And Resync
</button>
</div>
</div>
</div>
</fieldset>
</div>
</div>

@ -93,6 +93,14 @@ export class EmbyComponent implements OnInit {
});
}
public runRecentlyAddedCacher(): void {
this.jobService.runEmbyRecentlyAddedCacher().subscribe(x => {
if (x) {
this.notificationService.success("Triggered the Emby Recently Added Sync");
}
});
}
public clearDataAndResync(): void {
this.jobService.clearMediaserverData().subscribe(x => {
if (x) {

@ -1,7 +1,6 @@
import { Component, OnInit } from "@angular/core";
import { FormBuilder, FormGroup, Validators } from "@angular/forms";
import { NotificationService, SettingsService, JobService } from "../../services";
import { JobService, NotificationService, SettingsService } from "../../services";
@Component({
templateUrl: "./jobs.component.html",
@ -36,7 +35,8 @@ export class JobsComponent implements OnInit {
issuesPurge: [x.issuesPurge, Validators.required],
retryRequests: [x.retryRequests, Validators.required],
mediaDatabaseRefresh: [x.mediaDatabaseRefresh, Validators.required],
autoDeleteRequests: [x.autoDeleteRequests, Validators.required]
autoDeleteRequests: [x.autoDeleteRequests, Validators.required],
EmbyRecentlyAddedSync: [x.embyRecentlyAddedSync, Validators.required],
});
});
}

@ -118,9 +118,9 @@ namespace Ombi.Controllers.V1
/// </summary>
/// <returns></returns>
[HttpPost("plexcontentcacher")]
public bool StartPlexContentCacher()
public async Task<bool> StartPlexContentCacher()
{
OmbiQuartz.Scheduler.TriggerJob(new JobKey(nameof(IPlexContentSync), "Plex"), new JobDataMap(new Dictionary<string, string> { { "recentlyAddedSearch", "false" } }));
await OmbiQuartz.Scheduler.TriggerJob(new JobKey(nameof(IPlexContentSync), "Plex"), new JobDataMap(new Dictionary<string, string> { { "recentlyAddedSearch", "false" } }));
return true;
}
@ -129,9 +129,9 @@ namespace Ombi.Controllers.V1
/// </summary>
/// <returns></returns>
[HttpPost("clearmediaserverdata")]
public bool ClearMediaServerData()
public async Task<bool> ClearMediaServerData()
{
OmbiQuartz.Scheduler.TriggerJob(new JobKey(nameof(IMediaDatabaseRefresh), "System"));
await OmbiQuartz.Scheduler.TriggerJob(new JobKey(nameof(IMediaDatabaseRefresh), "System"));
return true;
}
@ -140,9 +140,9 @@ namespace Ombi.Controllers.V1
/// </summary>
/// <returns></returns>
[HttpPost("plexrecentlyadded")]
public bool StartRecentlyAdded()
public async Task<bool> StartRecentlyAdded()
{
OmbiQuartz.Scheduler.TriggerJob(new JobKey(nameof(IPlexContentSync) + "RecentlyAdded", "Plex"), new JobDataMap(new Dictionary<string, string> { { "recentlyAddedSearch", "true" } }));
await OmbiQuartz.Scheduler.TriggerJob(new JobKey(nameof(IPlexContentSync) + "RecentlyAdded", "Plex"), new JobDataMap(new Dictionary<string, string> { { "recentlyAddedSearch", "true" } }));
return true;
}
@ -153,7 +153,18 @@ namespace Ombi.Controllers.V1
[HttpPost("embycontentcacher")]
public async Task<bool> StartEmbyContentCacher()
{
await OmbiQuartz.TriggerJob(nameof(IEmbyContentSync), "Emby");
await OmbiQuartz.Scheduler.TriggerJob(new JobKey(nameof(IEmbyContentSync), "Emby"), new JobDataMap(new Dictionary<string, string> { { JobDataKeys.EmbyRecentlyAddedSearch, "false" } }));
return true;
}
/// <summary>
/// Runs a smaller version of the content cacher
/// </summary>
/// <returns></returns>
[HttpPost("embyrecentlyadded")]
public async Task<bool> StartEmbyRecentlyAdded()
{
await OmbiQuartz.Scheduler.TriggerJob(new JobKey(nameof(IEmbyContentSync) + "RecentlyAdded", "Emby"), new JobDataMap(new Dictionary<string, string> { { JobDataKeys.EmbyRecentlyAddedSearch, "true" } }));
return true;
}

@ -618,6 +618,7 @@ namespace Ombi.Controllers.V1
j.RetryRequests = j.RetryRequests.HasValue() ? j.RetryRequests : JobSettingsHelper.ResendFailedRequests(j);
j.MediaDatabaseRefresh = j.MediaDatabaseRefresh.HasValue() ? j.MediaDatabaseRefresh : JobSettingsHelper.MediaDatabaseRefresh(j);
j.AutoDeleteRequests = j.AutoDeleteRequests.HasValue() ? j.AutoDeleteRequests : JobSettingsHelper.AutoDeleteRequests(j);
j.EmbyRecentlyAddedSync = j.EmbyRecentlyAddedSync.HasValue() ? j.EmbyRecentlyAddedSync : JobSettingsHelper.EmbyRecentlyAddedSync(j);
return j;
}

Loading…
Cancel
Save