mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-16 02:02:55 -07:00
Merge remote-tracking branch 'upstream/develop' into original-language
This commit is contained in:
commit
18742776da
24 changed files with 145 additions and 197 deletions
|
@ -533,7 +533,10 @@ namespace Ombi.Core.Engine
|
|||
}
|
||||
else
|
||||
{
|
||||
x.ShowSubscribe = true;
|
||||
if (!x.Available && !x.Available4K && (!x.Denied ?? true) && (!x.Denied4K ?? true))
|
||||
{
|
||||
x.ShowSubscribe = true;
|
||||
}
|
||||
var hasSub = sub.FirstOrDefault(r => r.RequestId == x.Id);
|
||||
x.Subscribed = hasSub != null;
|
||||
}
|
||||
|
|
|
@ -270,7 +270,10 @@ namespace Ombi.Core.Engine
|
|||
}
|
||||
else
|
||||
{
|
||||
x.ShowSubscribe = true;
|
||||
if (!x.Available && (!x.Denied ?? false))
|
||||
{
|
||||
x.ShowSubscribe = true;
|
||||
}
|
||||
var hasSub = sub.FirstOrDefault(r => r.RequestId == x.Id);
|
||||
x.Subscribed = hasSub != null;
|
||||
}
|
||||
|
|
|
@ -886,7 +886,10 @@ namespace Ombi.Core.Engine
|
|||
}
|
||||
else
|
||||
{
|
||||
x.ShowSubscribe = true;
|
||||
if (!x.Available && (!x.Denied ?? true))
|
||||
{
|
||||
x.ShowSubscribe = true;
|
||||
}
|
||||
var result = relevantSubs.FirstOrDefault(s => s.RequestId == x.Id);
|
||||
x.Subscribed = result != null;
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ namespace Ombi.Core.Senders
|
|||
}
|
||||
|
||||
|
||||
return new SenderResult { Success = false, Sent = false, Message = "Something went wrong!" };
|
||||
return new SenderResult { Success = false, Sent = false };
|
||||
}
|
||||
|
||||
private async Task<SenderResult> SendToLidarr(AlbumRequest model, LidarrSettings settings)
|
||||
|
|
|
@ -133,8 +133,7 @@ namespace Ombi.Core.Senders
|
|||
|
||||
return new SenderResult
|
||||
{
|
||||
Success = false,
|
||||
Message = "Something went wrong!"
|
||||
Success = false
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -343,8 +342,6 @@ namespace Ombi.Core.Senders
|
|||
await Task.Delay(500);
|
||||
}
|
||||
|
||||
var seriesChanges = false;
|
||||
|
||||
foreach (var season in model.SeasonRequests)
|
||||
{
|
||||
foreach (var ep in season.Episodes)
|
||||
|
@ -359,72 +356,36 @@ namespace Ombi.Core.Senders
|
|||
}
|
||||
|
||||
existingSeason = result.seasons.FirstOrDefault(x => x.seasonNumber == season.SeasonNumber);
|
||||
var sonarrEpisodeList = sonarrEpList.Where(x => x.seasonNumber == season.SeasonNumber).ToList();
|
||||
var sonarrEpCount = sonarrEpisodeList.Count;
|
||||
var ourRequestCount = season.Episodes.Count;
|
||||
|
||||
var ourEpisodes = season.Episodes.Select(x => x.EpisodeNumber).ToList();
|
||||
var unairedEpisodes = sonarrEpisodeList.Where(x => x.airDateUtc > DateTime.UtcNow).Select(x => x.episodeNumber).ToList();
|
||||
|
||||
//// Check if we have requested all the latest episodes, if we have then monitor
|
||||
//// NOTE, not sure if needed since ombi ui displays future episodes anyway...
|
||||
//ourEpisodes.AddRange(unairedEpisodes);
|
||||
//var distinctEpisodes = ourEpisodes.Distinct().ToList();
|
||||
//var missingEpisodes = Enumerable.Range(distinctEpisodes.Min(), distinctEpisodes.Count).Except(distinctEpisodes);
|
||||
|
||||
|
||||
if (sonarrEpCount == ourRequestCount /*|| !missingEpisodes.Any()*/)
|
||||
// Make sure this season is set to monitored
|
||||
if (!existingSeason.monitored)
|
||||
{
|
||||
// We have the same amount of requests as all of the episodes in the season.
|
||||
// We need to monitor it, problem being is all episodes will now be monitored
|
||||
// So we need to monitor the series but unmonitor every episode
|
||||
existingSeason.monitored = true;
|
||||
seriesChanges = true;
|
||||
var sea = result.seasons.FirstOrDefault(x => x.seasonNumber == existingSeason.seasonNumber);
|
||||
sea.monitored = true;
|
||||
|
||||
// We do not need to update the episodes as marking the season as monitored will mark the episodes as monitored.
|
||||
var seasonToUpdate = result.seasons.FirstOrDefault(x => x.seasonNumber == season.SeasonNumber);
|
||||
seasonToUpdate.monitored = true; // Update by ref
|
||||
}
|
||||
else
|
||||
{
|
||||
// Make sure this season is set to monitored
|
||||
if (!existingSeason.monitored)
|
||||
result = await SonarrApi.UpdateSeries(result, s.ApiKey, s.FullUri);
|
||||
var epToUnmonitored = new List<Episode>();
|
||||
var newEpList = sonarrEpList.ConvertAll(ep => new Episode(ep)); // Clone it so we don't modify the original member
|
||||
foreach (var ep in newEpList.Where(x => x.seasonNumber == existingSeason.seasonNumber).ToList())
|
||||
{
|
||||
// We need to monitor it, problem being is all episodes will now be monitored
|
||||
// So we need to monitor the series but unmonitor every episode
|
||||
// Except the episodes that are already monitored before we update the series (we do not want to unmonitored episodes that are monitored beforehand)
|
||||
existingSeason.monitored = true;
|
||||
var sea = result.seasons.FirstOrDefault(x => x.seasonNumber == existingSeason.seasonNumber);
|
||||
sea.monitored = true;
|
||||
//var previouslyMonitoredEpisodes = sonarrEpList.Where(x =>
|
||||
// x.seasonNumber == existingSeason.seasonNumber && x.monitored).Select(x => x.episodeNumber).ToList(); // We probably don't actually care about this
|
||||
result = await SonarrApi.UpdateSeries(result, s.ApiKey, s.FullUri);
|
||||
var epToUnmonitored = new List<Episode>();
|
||||
var newEpList = sonarrEpList.ConvertAll(ep => new Episode(ep)); // Clone it so we don't modify the original member
|
||||
foreach (var ep in newEpList.Where(x => x.seasonNumber == existingSeason.seasonNumber).ToList())
|
||||
{
|
||||
//if (previouslyMonitoredEpisodes.Contains(ep.episodeNumber))
|
||||
//{
|
||||
// // This was previously monitored.
|
||||
// continue;
|
||||
//}
|
||||
ep.monitored = false;
|
||||
epToUnmonitored.Add(ep);
|
||||
}
|
||||
|
||||
foreach (var epToUpdate in epToUnmonitored)
|
||||
{
|
||||
await SonarrApi.UpdateEpisode(epToUpdate, s.ApiKey, s.FullUri);
|
||||
}
|
||||
ep.monitored = false;
|
||||
epToUnmonitored.Add(ep);
|
||||
}
|
||||
// Now update the episodes that need updating
|
||||
foreach (var epToUpdate in episodesToUpdate.Where(x => x.seasonNumber == season.SeasonNumber))
|
||||
|
||||
foreach (var epToUpdate in epToUnmonitored)
|
||||
{
|
||||
await SonarrApi.UpdateEpisode(epToUpdate, s.ApiKey, s.FullUri);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (seriesChanges)
|
||||
{
|
||||
await SonarrApi.SeasonPass(s.ApiKey, s.FullUri, result);
|
||||
// Now update the episodes that need updating
|
||||
foreach (var epToUpdate in episodesToUpdate.Where(x => x.seasonNumber == season.SeasonNumber))
|
||||
{
|
||||
await SonarrApi.UpdateEpisode(epToUpdate, s.ApiKey, s.FullUri);
|
||||
}
|
||||
}
|
||||
|
||||
if (!s.AddOnly)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue