mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-15 01:32:55 -07:00
Finished off the job
This commit is contained in:
parent
207fbe0a8f
commit
da5d4f0738
17 changed files with 241 additions and 122 deletions
|
@ -11,7 +11,7 @@ using Ombi.Core.Models;
|
||||||
using Ombi.Core.Models.UI;
|
using Ombi.Core.Models.UI;
|
||||||
using Ombi.Core.Rule.Interfaces;
|
using Ombi.Core.Rule.Interfaces;
|
||||||
using Ombi.Core.Settings;
|
using Ombi.Core.Settings;
|
||||||
using Ombi.Schedule.Jobs.Ombi;
|
using Ombi.Helpers;
|
||||||
using Ombi.Settings.Settings.Models;
|
using Ombi.Settings.Settings.Models;
|
||||||
using Ombi.Store.Entities;
|
using Ombi.Store.Entities;
|
||||||
using Ombi.Store.Repository;
|
using Ombi.Store.Repository;
|
||||||
|
@ -114,7 +114,7 @@ namespace Ombi.Core.Engine
|
||||||
foreach (var epInformation in childRequests.SeasonRequests.OrderBy(x => x.SeasonNumber))
|
foreach (var epInformation in childRequests.SeasonRequests.OrderBy(x => x.SeasonNumber))
|
||||||
{
|
{
|
||||||
var orderedEpisodes = epInformation.Episodes.OrderBy(x => x.EpisodeNumber).ToList();
|
var orderedEpisodes = epInformation.Episodes.OrderBy(x => x.EpisodeNumber).ToList();
|
||||||
var episodeString = NewsletterJob.BuildEpisodeList(orderedEpisodes.Select(x => x.EpisodeNumber));
|
var episodeString = StringHelper.BuildEpisodeList(orderedEpisodes.Select(x => x.EpisodeNumber));
|
||||||
finalsb.Append($"Season: {epInformation.SeasonNumber} - Episodes: {episodeString}");
|
finalsb.Append($"Season: {epInformation.SeasonNumber} - Episodes: {episodeString}");
|
||||||
finalsb.Append("<br />");
|
finalsb.Append("<br />");
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,16 +20,17 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Ombi.Api.CouchPotato\Ombi.Api.CouchPotato.csproj" />
|
||||||
<ProjectReference Include="..\Ombi.Api.DogNzb\Ombi.Api.DogNzb.csproj" />
|
<ProjectReference Include="..\Ombi.Api.DogNzb\Ombi.Api.DogNzb.csproj" />
|
||||||
<ProjectReference Include="..\Ombi.Api.Lidarr\Ombi.Api.Lidarr.csproj" />
|
<ProjectReference Include="..\Ombi.Api.Lidarr\Ombi.Api.Lidarr.csproj" />
|
||||||
<ProjectReference Include="..\Ombi.Api.Plex\Ombi.Api.Plex.csproj" />
|
<ProjectReference Include="..\Ombi.Api.Plex\Ombi.Api.Plex.csproj" />
|
||||||
|
<ProjectReference Include="..\Ombi.Api.Radarr\Ombi.Api.Radarr.csproj" />
|
||||||
<ProjectReference Include="..\Ombi.Api.SickRage\Ombi.Api.SickRage.csproj" />
|
<ProjectReference Include="..\Ombi.Api.SickRage\Ombi.Api.SickRage.csproj" />
|
||||||
<ProjectReference Include="..\Ombi.Api.Sonarr\Ombi.Api.Sonarr.csproj" />
|
<ProjectReference Include="..\Ombi.Api.Sonarr\Ombi.Api.Sonarr.csproj" />
|
||||||
<ProjectReference Include="..\Ombi.Api.Trakt\Ombi.Api.Trakt.csproj" />
|
<ProjectReference Include="..\Ombi.Api.Trakt\Ombi.Api.Trakt.csproj" />
|
||||||
<ProjectReference Include="..\Ombi.Api.TvMaze\Ombi.Api.TvMaze.csproj" />
|
<ProjectReference Include="..\Ombi.Api.TvMaze\Ombi.Api.TvMaze.csproj" />
|
||||||
<ProjectReference Include="..\Ombi.Helpers\Ombi.Helpers.csproj" />
|
<ProjectReference Include="..\Ombi.Helpers\Ombi.Helpers.csproj" />
|
||||||
<ProjectReference Include="..\Ombi.Notifications\Ombi.Notifications.csproj" />
|
<ProjectReference Include="..\Ombi.Notifications\Ombi.Notifications.csproj" />
|
||||||
<ProjectReference Include="..\Ombi.Schedule\Ombi.Schedule.csproj" />
|
|
||||||
<ProjectReference Include="..\Ombi.Settings\Ombi.Settings.csproj" />
|
<ProjectReference Include="..\Ombi.Settings\Ombi.Settings.csproj" />
|
||||||
<ProjectReference Include="..\Ombi.Store\Ombi.Store.csproj" />
|
<ProjectReference Include="..\Ombi.Store\Ombi.Store.csproj" />
|
||||||
<ProjectReference Include="..\Ombi.TheMovieDbApi\Ombi.Api.TheMovieDb.csproj" />
|
<ProjectReference Include="..\Ombi.TheMovieDbApi\Ombi.Api.TheMovieDb.csproj" />
|
||||||
|
|
|
@ -76,16 +76,28 @@ namespace Ombi.Core.Senders
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Log.LogError(e, "Error when seing movie to DVR app, added to the request queue"S);
|
Log.LogError(e, "Error when seing movie to DVR app, added to the request queue");
|
||||||
await _requestQueuRepository.Add(new RequestQueue
|
|
||||||
|
// Check if already in request quee
|
||||||
|
var existingQueue = await _requestQueuRepository.FirstOrDefaultAsync(x => x.RequestId == model.Id);
|
||||||
|
if (existingQueue != null)
|
||||||
{
|
{
|
||||||
Dts = DateTime.UtcNow,
|
existingQueue.RetryCount++;
|
||||||
Error = e.Message,
|
existingQueue.Error = e.Message;
|
||||||
RequestId = model.Id,
|
await _requestQueuRepository.SaveChangesAsync();
|
||||||
Type = RequestType.Movie,
|
}
|
||||||
RetryCount = 0
|
else
|
||||||
});
|
{
|
||||||
_notificationHelper.Notify(model, NotificationType.ItemAddedToFaultQueue);
|
await _requestQueuRepository.Add(new RequestQueue
|
||||||
|
{
|
||||||
|
Dts = DateTime.UtcNow,
|
||||||
|
Error = e.Message,
|
||||||
|
RequestId = model.Id,
|
||||||
|
Type = RequestType.Movie,
|
||||||
|
RetryCount = 0
|
||||||
|
});
|
||||||
|
_notificationHelper.Notify(model, NotificationType.ItemAddedToFaultQueue);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new SenderResult
|
return new SenderResult
|
||||||
|
|
|
@ -49,15 +49,25 @@ namespace Ombi.Core.Senders
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
_log.LogError(e, "Exception thrown when sending a music to DVR app, added to the request queue");
|
_log.LogError(e, "Exception thrown when sending a music to DVR app, added to the request queue");
|
||||||
await _requestQueueRepository.Add(new RequestQueue
|
var existingQueue = await _requestQueueRepository.FirstOrDefaultAsync(x => x.RequestId == model.Id);
|
||||||
|
if (existingQueue != null)
|
||||||
{
|
{
|
||||||
Dts = DateTime.UtcNow,
|
existingQueue.RetryCount++;
|
||||||
Error = e.Message,
|
existingQueue.Error = e.Message;
|
||||||
RequestId = model.Id,
|
await _requestQueueRepository.SaveChangesAsync();
|
||||||
Type = RequestType.Album,
|
}
|
||||||
RetryCount = 0
|
else
|
||||||
});
|
{
|
||||||
_notificationHelper.Notify(model, NotificationType.ItemAddedToFaultQueue);
|
await _requestQueueRepository.Add(new RequestQueue
|
||||||
|
{
|
||||||
|
Dts = DateTime.UtcNow,
|
||||||
|
Error = e.Message,
|
||||||
|
RequestId = model.Id,
|
||||||
|
Type = RequestType.Album,
|
||||||
|
RetryCount = 0
|
||||||
|
});
|
||||||
|
_notificationHelper.Notify(model, NotificationType.ItemAddedToFaultQueue);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -52,72 +52,81 @@ namespace Ombi.Core.Senders
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
var sonarr = await SonarrSettings.GetSettingsAsync();
|
||||||
|
if (sonarr.Enabled)
|
||||||
var sonarr = await SonarrSettings.GetSettingsAsync();
|
|
||||||
if (sonarr.Enabled)
|
|
||||||
{
|
|
||||||
var result = await SendToSonarr(model);
|
|
||||||
if (result != null)
|
|
||||||
{
|
{
|
||||||
|
var result = await SendToSonarr(model);
|
||||||
|
if (result != null)
|
||||||
|
{
|
||||||
|
return new SenderResult
|
||||||
|
{
|
||||||
|
Sent = true,
|
||||||
|
Success = true
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var dog = await DogNzbSettings.GetSettingsAsync();
|
||||||
|
if (dog.Enabled)
|
||||||
|
{
|
||||||
|
var result = await SendToDogNzb(model, dog);
|
||||||
|
if (!result.Failure)
|
||||||
|
{
|
||||||
|
return new SenderResult
|
||||||
|
{
|
||||||
|
Sent = true,
|
||||||
|
Success = true
|
||||||
|
};
|
||||||
|
}
|
||||||
return new SenderResult
|
return new SenderResult
|
||||||
{
|
{
|
||||||
Sent = true,
|
Message = result.ErrorMessage
|
||||||
Success = true
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
var sr = await SickRageSettings.GetSettingsAsync();
|
||||||
var dog = await DogNzbSettings.GetSettingsAsync();
|
if (sr.Enabled)
|
||||||
if (dog.Enabled)
|
|
||||||
{
|
|
||||||
var result = await SendToDogNzb(model, dog);
|
|
||||||
if (!result.Failure)
|
|
||||||
{
|
{
|
||||||
|
var result = await SendToSickRage(model, sr);
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
return new SenderResult
|
||||||
|
{
|
||||||
|
Sent = true,
|
||||||
|
Success = true
|
||||||
|
};
|
||||||
|
}
|
||||||
return new SenderResult
|
return new SenderResult
|
||||||
{
|
{
|
||||||
Sent = true,
|
Message = "Could not send to SickRage!"
|
||||||
Success = true
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return new SenderResult
|
return new SenderResult
|
||||||
{
|
{
|
||||||
Message = result.ErrorMessage
|
Success = true
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
var sr = await SickRageSettings.GetSettingsAsync();
|
|
||||||
if (sr.Enabled)
|
|
||||||
{
|
|
||||||
var result = await SendToSickRage(model, sr);
|
|
||||||
if (result)
|
|
||||||
{
|
|
||||||
return new SenderResult
|
|
||||||
{
|
|
||||||
Sent = true,
|
|
||||||
Success = true
|
|
||||||
};
|
|
||||||
}
|
|
||||||
return new SenderResult
|
|
||||||
{
|
|
||||||
Message = "Could not send to SickRage!"
|
|
||||||
};
|
|
||||||
}
|
|
||||||
return new SenderResult
|
|
||||||
{
|
|
||||||
Success = true
|
|
||||||
};
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Logger.LogError(e, "Exception thrown when sending a movie to DVR app, added to the request queue");
|
Logger.LogError(e, "Exception thrown when sending a movie to DVR app, added to the request queue");
|
||||||
await _requestQueueRepository.Add(new RequestQueue
|
// Check if already in request quee
|
||||||
|
var existingQueue = await _requestQueueRepository.FirstOrDefaultAsync(x => x.RequestId == model.Id);
|
||||||
|
if (existingQueue != null)
|
||||||
{
|
{
|
||||||
Dts = DateTime.UtcNow,
|
existingQueue.RetryCount++;
|
||||||
Error = e.Message,
|
existingQueue.Error = e.Message;
|
||||||
RequestId = model.Id,
|
await _requestQueueRepository.SaveChangesAsync();
|
||||||
Type = RequestType.TvShow,
|
}
|
||||||
RetryCount = 0
|
else
|
||||||
});
|
{
|
||||||
_notificationHelper.Notify(model, NotificationType.ItemAddedToFaultQueue);
|
await _requestQueueRepository.Add(new RequestQueue
|
||||||
|
{
|
||||||
|
Dts = DateTime.UtcNow,
|
||||||
|
Error = e.Message,
|
||||||
|
RequestId = model.Id,
|
||||||
|
Type = RequestType.TvShow,
|
||||||
|
RetryCount = 0
|
||||||
|
});
|
||||||
|
_notificationHelper.Notify(model, NotificationType.ItemAddedToFaultQueue);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new SenderResult
|
return new SenderResult
|
||||||
|
@ -171,7 +180,7 @@ namespace Ombi.Core.Senders
|
||||||
}
|
}
|
||||||
if (profiles.SonarrQualityProfileAnime > 0)
|
if (profiles.SonarrQualityProfileAnime > 0)
|
||||||
{
|
{
|
||||||
qualityToUse = profiles.SonarrQualityProfileAnime;
|
qualityToUse = profiles.SonarrQualityProfileAnime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
seriesType = "anime";
|
seriesType = "anime";
|
||||||
|
@ -191,7 +200,7 @@ namespace Ombi.Core.Senders
|
||||||
}
|
}
|
||||||
if (profiles.SonarrQualityProfile > 0)
|
if (profiles.SonarrQualityProfile > 0)
|
||||||
{
|
{
|
||||||
qualityToUse = profiles.SonarrQualityProfile;
|
qualityToUse = profiles.SonarrQualityProfile;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
seriesType = "standard";
|
seriesType = "standard";
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security;
|
using System.Security;
|
||||||
|
@ -76,6 +77,49 @@ namespace Ombi.Helpers
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string BuildEpisodeList(IEnumerable<int> orderedEpisodes)
|
||||||
|
{
|
||||||
|
var epSb = new StringBuilder();
|
||||||
|
var previousEpisodes = new List<int>();
|
||||||
|
var previousEpisode = -1;
|
||||||
|
foreach (var ep in orderedEpisodes)
|
||||||
|
{
|
||||||
|
if (ep - 1 == previousEpisode)
|
||||||
|
{
|
||||||
|
// This is the next one
|
||||||
|
previousEpisodes.Add(ep);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (previousEpisodes.Count > 1)
|
||||||
|
{
|
||||||
|
// End it
|
||||||
|
epSb.Append($"{previousEpisodes.First()}-{previousEpisodes.Last()}, ");
|
||||||
|
}
|
||||||
|
else if (previousEpisodes.Count == 1)
|
||||||
|
{
|
||||||
|
epSb.Append($"{previousEpisodes.FirstOrDefault()}, ");
|
||||||
|
}
|
||||||
|
// New one
|
||||||
|
previousEpisodes.Clear();
|
||||||
|
previousEpisodes.Add(ep);
|
||||||
|
}
|
||||||
|
previousEpisode = ep;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (previousEpisodes.Count > 1)
|
||||||
|
{
|
||||||
|
// Got some left over
|
||||||
|
epSb.Append($"{previousEpisodes.First()}-{previousEpisodes.Last()}");
|
||||||
|
}
|
||||||
|
else if (previousEpisodes.Count == 1)
|
||||||
|
{
|
||||||
|
epSb.Append(previousEpisodes.FirstOrDefault());
|
||||||
|
}
|
||||||
|
|
||||||
|
return epSb.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
public static string RemoveSpaces(this string str)
|
public static string RemoveSpaces(this string str)
|
||||||
{
|
{
|
||||||
return str.Replace(" ", "");
|
return str.Replace(" ", "");
|
||||||
|
|
|
@ -21,7 +21,7 @@ namespace Ombi.Schedule
|
||||||
IEmbyUserImporter embyUserImporter, ISonarrSync cache, ICouchPotatoSync cpCache,
|
IEmbyUserImporter embyUserImporter, ISonarrSync cache, ICouchPotatoSync cpCache,
|
||||||
ISettingsService<JobSettings> jobsettings, ISickRageSync srSync, IRefreshMetadata refresh,
|
ISettingsService<JobSettings> jobsettings, ISickRageSync srSync, IRefreshMetadata refresh,
|
||||||
INewsletterJob newsletter, IPlexRecentlyAddedSync recentlyAddedPlex, ILidarrArtistSync artist,
|
INewsletterJob newsletter, IPlexRecentlyAddedSync recentlyAddedPlex, ILidarrArtistSync artist,
|
||||||
IIssuesPurge purge)
|
IIssuesPurge purge, IResendFailedRequests resender)
|
||||||
{
|
{
|
||||||
_plexContentSync = plexContentSync;
|
_plexContentSync = plexContentSync;
|
||||||
_radarrSync = radarrSync;
|
_radarrSync = radarrSync;
|
||||||
|
@ -38,6 +38,7 @@ namespace Ombi.Schedule
|
||||||
_plexRecentlyAddedSync = recentlyAddedPlex;
|
_plexRecentlyAddedSync = recentlyAddedPlex;
|
||||||
_lidarrArtistSync = artist;
|
_lidarrArtistSync = artist;
|
||||||
_issuesPurge = purge;
|
_issuesPurge = purge;
|
||||||
|
_resender = resender;
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly IPlexContentSync _plexContentSync;
|
private readonly IPlexContentSync _plexContentSync;
|
||||||
|
@ -55,6 +56,7 @@ namespace Ombi.Schedule
|
||||||
private readonly INewsletterJob _newsletter;
|
private readonly INewsletterJob _newsletter;
|
||||||
private readonly ILidarrArtistSync _lidarrArtistSync;
|
private readonly ILidarrArtistSync _lidarrArtistSync;
|
||||||
private readonly IIssuesPurge _issuesPurge;
|
private readonly IIssuesPurge _issuesPurge;
|
||||||
|
private readonly IResendFailedRequests _resender;
|
||||||
|
|
||||||
public void Setup()
|
public void Setup()
|
||||||
{
|
{
|
||||||
|
@ -76,6 +78,8 @@ namespace Ombi.Schedule
|
||||||
RecurringJob.AddOrUpdate(() => _embyUserImporter.Start(), JobSettingsHelper.UserImporter(s));
|
RecurringJob.AddOrUpdate(() => _embyUserImporter.Start(), JobSettingsHelper.UserImporter(s));
|
||||||
RecurringJob.AddOrUpdate(() => _plexUserImporter.Start(), JobSettingsHelper.UserImporter(s));
|
RecurringJob.AddOrUpdate(() => _plexUserImporter.Start(), JobSettingsHelper.UserImporter(s));
|
||||||
RecurringJob.AddOrUpdate(() => _newsletter.Start(), JobSettingsHelper.Newsletter(s));
|
RecurringJob.AddOrUpdate(() => _newsletter.Start(), JobSettingsHelper.Newsletter(s));
|
||||||
|
RecurringJob.AddOrUpdate(() => _newsletter.Start(), JobSettingsHelper.Newsletter(s));
|
||||||
|
RecurringJob.AddOrUpdate(() => _resender.Start(), JobSettingsHelper.ResendFailedRequests(s));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
9
src/Ombi.Schedule/Jobs/Ombi/IResendFailedRequests.cs
Normal file
9
src/Ombi.Schedule/Jobs/Ombi/IResendFailedRequests.cs
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Ombi.Schedule.Jobs.Ombi
|
||||||
|
{
|
||||||
|
public interface IResendFailedRequests
|
||||||
|
{
|
||||||
|
Task Start();
|
||||||
|
}
|
||||||
|
}
|
|
@ -677,7 +677,7 @@ namespace Ombi.Schedule.Jobs.Ombi
|
||||||
foreach (var epInformation in results.OrderBy(x => x.SeasonNumber))
|
foreach (var epInformation in results.OrderBy(x => x.SeasonNumber))
|
||||||
{
|
{
|
||||||
var orderedEpisodes = epInformation.Episodes.OrderBy(x => x.EpisodeNumber).ToList();
|
var orderedEpisodes = epInformation.Episodes.OrderBy(x => x.EpisodeNumber).ToList();
|
||||||
var episodeString = BuildEpisodeList(orderedEpisodes.Select(x => x.EpisodeNumber));
|
var episodeString = StringHelper.BuildEpisodeList(orderedEpisodes.Select(x => x.EpisodeNumber));
|
||||||
finalsb.Append($"Season: {epInformation.SeasonNumber} - Episodes: {episodeString}");
|
finalsb.Append($"Season: {epInformation.SeasonNumber} - Episodes: {episodeString}");
|
||||||
finalsb.Append("<br />");
|
finalsb.Append("<br />");
|
||||||
}
|
}
|
||||||
|
@ -715,48 +715,7 @@ namespace Ombi.Schedule.Jobs.Ombi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string BuildEpisodeList(IEnumerable<int> orderedEpisodes)
|
|
||||||
{
|
|
||||||
var epSb = new StringBuilder();
|
|
||||||
var previousEpisodes = new List<int>();
|
|
||||||
var previousEpisode = -1;
|
|
||||||
foreach (var ep in orderedEpisodes)
|
|
||||||
{
|
|
||||||
if (ep - 1 == previousEpisode)
|
|
||||||
{
|
|
||||||
// This is the next one
|
|
||||||
previousEpisodes.Add(ep);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (previousEpisodes.Count > 1)
|
|
||||||
{
|
|
||||||
// End it
|
|
||||||
epSb.Append($"{previousEpisodes.First()}-{previousEpisodes.Last()}, ");
|
|
||||||
}
|
|
||||||
else if (previousEpisodes.Count == 1)
|
|
||||||
{
|
|
||||||
epSb.Append($"{previousEpisodes.FirstOrDefault()}, ");
|
|
||||||
}
|
|
||||||
// New one
|
|
||||||
previousEpisodes.Clear();
|
|
||||||
previousEpisodes.Add(ep);
|
|
||||||
}
|
|
||||||
previousEpisode = ep;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (previousEpisodes.Count > 1)
|
|
||||||
{
|
|
||||||
// Got some left over
|
|
||||||
epSb.Append($"{previousEpisodes.First()}-{previousEpisodes.Last()}");
|
|
||||||
}
|
|
||||||
else if(previousEpisodes.Count == 1)
|
|
||||||
{
|
|
||||||
epSb.Append(previousEpisodes.FirstOrDefault());
|
|
||||||
}
|
|
||||||
|
|
||||||
return epSb.ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task ProcessEmbyTv(HashSet<EmbyEpisode> embyContent, StringBuilder sb)
|
private async Task ProcessEmbyTv(HashSet<EmbyEpisode> embyContent, StringBuilder sb)
|
||||||
{
|
{
|
||||||
|
@ -841,7 +800,7 @@ namespace Ombi.Schedule.Jobs.Ombi
|
||||||
foreach (var epInformation in results.OrderBy(x => x.SeasonNumber))
|
foreach (var epInformation in results.OrderBy(x => x.SeasonNumber))
|
||||||
{
|
{
|
||||||
var orderedEpisodes = epInformation.Episodes.OrderBy(x => x.EpisodeNumber).ToList();
|
var orderedEpisodes = epInformation.Episodes.OrderBy(x => x.EpisodeNumber).ToList();
|
||||||
var episodeString = BuildEpisodeList(orderedEpisodes.Select(x => x.EpisodeNumber));
|
var episodeString = StringHelper.BuildEpisodeList(orderedEpisodes.Select(x => x.EpisodeNumber));
|
||||||
finalsb.Append($"Season: {epInformation.SeasonNumber} - Episodes: {episodeString}");
|
finalsb.Append($"Season: {epInformation.SeasonNumber} - Episodes: {episodeString}");
|
||||||
finalsb.Append("<br />");
|
finalsb.Append("<br />");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,19 +1,75 @@
|
||||||
using System.Threading.Tasks;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Ombi.Core;
|
||||||
|
using Ombi.Core.Senders;
|
||||||
using Ombi.Store.Entities;
|
using Ombi.Store.Entities;
|
||||||
using Ombi.Store.Repository;
|
using Ombi.Store.Repository;
|
||||||
|
using Ombi.Store.Repository.Requests;
|
||||||
|
|
||||||
namespace Ombi.Schedule.Jobs.Ombi
|
namespace Ombi.Schedule.Jobs.Ombi
|
||||||
{
|
{
|
||||||
public class ResendFailedRequests
|
public class ResendFailedRequests : IResendFailedRequests
|
||||||
{
|
{
|
||||||
public ResendFailedRequests(IRepository<RequestQueue> queue, IMovieSender movieSender)
|
public ResendFailedRequests(IRepository<RequestQueue> queue, IMovieSender movieSender, ITvSender tvSender, IMusicSender musicSender,
|
||||||
|
IMovieRequestRepository movieRepo, ITvRequestRepository tvRepo, IMusicRequestRepository music)
|
||||||
{
|
{
|
||||||
|
_requestQueue = queue;
|
||||||
|
_movieSender = movieSender;
|
||||||
|
_tvSender = tvSender;
|
||||||
|
_musicSender = musicSender;
|
||||||
|
_movieRequestRepository = movieRepo;
|
||||||
|
_tvRequestRepository = tvRepo;
|
||||||
|
_musicRequestRepository = music;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private readonly IRepository<RequestQueue> _requestQueue;
|
||||||
|
private readonly IMovieSender _movieSender;
|
||||||
|
private readonly ITvSender _tvSender;
|
||||||
|
private readonly IMusicSender _musicSender;
|
||||||
|
private readonly IMovieRequestRepository _movieRequestRepository;
|
||||||
|
private readonly ITvRequestRepository _tvRequestRepository;
|
||||||
|
private readonly IMusicRequestRepository _musicRequestRepository;
|
||||||
|
|
||||||
public async Task Start()
|
public async Task Start()
|
||||||
{
|
{
|
||||||
|
// Get all the failed ones!
|
||||||
|
var failedRequests = _requestQueue.GetAll().Where(x => !x.Completed.HasValue);
|
||||||
|
|
||||||
|
foreach (var request in failedRequests)
|
||||||
|
{
|
||||||
|
if (request.Type == RequestType.Movie)
|
||||||
|
{
|
||||||
|
var movieRequest = await _movieRequestRepository.GetAll().FirstOrDefaultAsync(x => x.Id == request.RequestId);
|
||||||
|
var result = await _movieSender.Send(movieRequest);
|
||||||
|
if (result.Success)
|
||||||
|
{
|
||||||
|
request.Completed = DateTime.UtcNow;
|
||||||
|
await _requestQueue.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (request.Type == RequestType.TvShow)
|
||||||
|
{
|
||||||
|
var tvRequest = await _tvRequestRepository.GetChild().FirstOrDefaultAsync(x => x.Id == request.RequestId);
|
||||||
|
var result = await _tvSender.Send(tvRequest);
|
||||||
|
if (result.Success)
|
||||||
|
{
|
||||||
|
request.Completed = DateTime.UtcNow;
|
||||||
|
await _requestQueue.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (request.Type == RequestType.Album)
|
||||||
|
{
|
||||||
|
var musicRequest = await _musicRequestRepository.GetAll().FirstOrDefaultAsync(x => x.Id == request.RequestId);
|
||||||
|
var result = await _musicSender.Send(musicRequest);
|
||||||
|
if (result.Success)
|
||||||
|
{
|
||||||
|
request.Completed = DateTime.UtcNow;
|
||||||
|
await _requestQueue.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -34,6 +34,7 @@
|
||||||
<ProjectReference Include="..\Ombi.Api.SickRage\Ombi.Api.SickRage.csproj" />
|
<ProjectReference Include="..\Ombi.Api.SickRage\Ombi.Api.SickRage.csproj" />
|
||||||
<ProjectReference Include="..\Ombi.Api.Sonarr\Ombi.Api.Sonarr.csproj" />
|
<ProjectReference Include="..\Ombi.Api.Sonarr\Ombi.Api.Sonarr.csproj" />
|
||||||
<ProjectReference Include="..\Ombi.Api.TvMaze\Ombi.Api.TvMaze.csproj" />
|
<ProjectReference Include="..\Ombi.Api.TvMaze\Ombi.Api.TvMaze.csproj" />
|
||||||
|
<ProjectReference Include="..\Ombi.Core\Ombi.Core.csproj" />
|
||||||
<ProjectReference Include="..\Ombi.Notifications\Ombi.Notifications.csproj" />
|
<ProjectReference Include="..\Ombi.Notifications\Ombi.Notifications.csproj" />
|
||||||
<ProjectReference Include="..\Ombi.Settings\Ombi.Settings.csproj" />
|
<ProjectReference Include="..\Ombi.Settings\Ombi.Settings.csproj" />
|
||||||
<ProjectReference Include="..\Ombi.TheMovieDbApi\Ombi.Api.TheMovieDb.csproj" />
|
<ProjectReference Include="..\Ombi.TheMovieDbApi\Ombi.Api.TheMovieDb.csproj" />
|
||||||
|
|
|
@ -15,5 +15,6 @@
|
||||||
public string Newsletter { get; set; }
|
public string Newsletter { get; set; }
|
||||||
public string LidarrArtistSync { get; set; }
|
public string LidarrArtistSync { get; set; }
|
||||||
public string IssuesPurge { get; set; }
|
public string IssuesPurge { get; set; }
|
||||||
|
public string RetryRequests { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -61,6 +61,10 @@ namespace Ombi.Settings.Settings.Models
|
||||||
{
|
{
|
||||||
return Get(s.IssuesPurge, Cron.Daily());
|
return Get(s.IssuesPurge, Cron.Daily());
|
||||||
}
|
}
|
||||||
|
public static string ResendFailedRequests(JobSettings s)
|
||||||
|
{
|
||||||
|
return Get(s.RetryRequests, Cron.Daily(6));
|
||||||
|
}
|
||||||
|
|
||||||
private static string Get(string settings, string defaultCron)
|
private static string Get(string settings, string defaultCron)
|
||||||
{
|
{
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace Ombi.Store.Entities
|
||||||
public RequestType Type { get; set; }
|
public RequestType Type { get; set; }
|
||||||
public DateTime Dts { get; set; }
|
public DateTime Dts { get; set; }
|
||||||
public string Error { get; set; }
|
public string Error { get; set; }
|
||||||
public DateTime Completed { get; set; }
|
public DateTime? Completed { get; set; }
|
||||||
public int RetryCount { get; set; }
|
public int RetryCount { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -145,6 +145,7 @@ export interface IJobSettings {
|
||||||
plexRecentlyAddedSync: string;
|
plexRecentlyAddedSync: string;
|
||||||
lidarrArtistSync: string;
|
lidarrArtistSync: string;
|
||||||
issuesPurge: string;
|
issuesPurge: string;
|
||||||
|
retryRequests: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IIssueSettings extends ISettings {
|
export interface IIssueSettings extends ISettings {
|
||||||
|
|
|
@ -48,6 +48,13 @@
|
||||||
<small *ngIf="form.get('automaticUpdater').hasError('required')" class="error-text">The Automatic Update is required</small>
|
<small *ngIf="form.get('automaticUpdater').hasError('required')" class="error-text">The Automatic Update is required</small>
|
||||||
<button type="button" class="btn btn-sm btn-primary-outline" (click)="testCron(form.get('automaticUpdater')?.value)">Test</button>
|
<button type="button" class="btn btn-sm btn-primary-outline" (click)="testCron(form.get('automaticUpdater')?.value)">Test</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="retryRequests" class="control-label">Retry Failed Requests</label>
|
||||||
|
<input type="text" class="form-control form-control-custom" [ngClass]="{'form-error': form.get('retryRequests').hasError('required')}" id="retryRequests" name="retryRequests" formControlName="retryRequests">
|
||||||
|
<small *ngIf="form.get('retryRequests').hasError('required')" class="error-text">The Retry Requests is required</small>
|
||||||
|
<button type="button" class="btn btn-sm btn-primary-outline" (click)="testCron(form.get('retryRequests')?.value)">Test</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
|
|
@ -520,6 +520,7 @@ namespace Ombi.Controllers
|
||||||
j.Newsletter = j.Newsletter.HasValue() ? j.Newsletter : JobSettingsHelper.Newsletter(j);
|
j.Newsletter = j.Newsletter.HasValue() ? j.Newsletter : JobSettingsHelper.Newsletter(j);
|
||||||
j.LidarrArtistSync = j.LidarrArtistSync.HasValue() ? j.LidarrArtistSync : JobSettingsHelper.LidarrArtistSync(j);
|
j.LidarrArtistSync = j.LidarrArtistSync.HasValue() ? j.LidarrArtistSync : JobSettingsHelper.LidarrArtistSync(j);
|
||||||
j.IssuesPurge = j.IssuesPurge.HasValue() ? j.IssuesPurge : JobSettingsHelper.IssuePurge(j);
|
j.IssuesPurge = j.IssuesPurge.HasValue() ? j.IssuesPurge : JobSettingsHelper.IssuePurge(j);
|
||||||
|
j.RetryRequests = j.RetryRequests.HasValue() ? j.RetryRequests : JobSettingsHelper.ResendFailedRequests(j);
|
||||||
|
|
||||||
return j;
|
return j;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue