mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-20 21:33:15 -07:00
fix(sonarr): 🐛 Correctly monitor episodes
This commit is contained in:
parent
18c3b314d6
commit
57e7830f8e
2 changed files with 16 additions and 56 deletions
|
@ -49,7 +49,7 @@ namespace Ombi.Api.Sonarr
|
||||||
|
|
||||||
public async Task<List<MonitoredEpisodeResult>> MonitorEpisode(int[] episodeIds, bool monitor, string apiKey, string baseUrl)
|
public async Task<List<MonitoredEpisodeResult>> MonitorEpisode(int[] episodeIds, bool monitor, string apiKey, string baseUrl)
|
||||||
{
|
{
|
||||||
var request = new Request($"{ApiBaseUrl}Episode/monitor", baseUrl, HttpMethod.Put);
|
var request = new Request($"{ApiBaseUrl}episode/monitor", baseUrl, HttpMethod.Put);
|
||||||
request.AddHeader("X-Api-Key", apiKey);
|
request.AddHeader("X-Api-Key", apiKey);
|
||||||
request.AddJsonBody(new { episodeIds = episodeIds, monitored = monitor });
|
request.AddJsonBody(new { episodeIds = episodeIds, monitored = monitor });
|
||||||
return await Api.Request<List<MonitoredEpisodeResult>>(request);
|
return await Api.Request<List<MonitoredEpisodeResult>>(request);
|
||||||
|
|
|
@ -1,13 +1,9 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.VisualBasic;
|
|
||||||
using Ombi.Api.DogNzb;
|
|
||||||
using Ombi.Api.DogNzb.Models;
|
|
||||||
using Ombi.Api.SickRage;
|
using Ombi.Api.SickRage;
|
||||||
using Ombi.Api.SickRage.Models;
|
using Ombi.Api.SickRage.Models;
|
||||||
using Ombi.Api.Sonarr;
|
using Ombi.Api.Sonarr;
|
||||||
|
@ -23,15 +19,13 @@ namespace Ombi.Core.Senders
|
||||||
{
|
{
|
||||||
public class TvSender : ITvSender
|
public class TvSender : ITvSender
|
||||||
{
|
{
|
||||||
public TvSender(ISonarrApi sonarrApi, ISonarrV3Api sonarrV3Api, ILogger<TvSender> log, ISettingsService<SonarrSettings> sonarrSettings,
|
public TvSender(ISonarrV3Api sonarrV3Api, ILogger<TvSender> log, ISettingsService<SonarrSettings> sonarrSettings,
|
||||||
ISettingsService<DogNzbSettings> dog, IDogNzbApi dogApi, ISettingsService<SickRageSettings> srSettings,
|
ISettingsService<SickRageSettings> srSettings,
|
||||||
ISickRageApi srApi, IRepository<UserQualityProfiles> userProfiles, IRepository<RequestQueue> requestQueue, INotificationHelper notify)
|
ISickRageApi srApi, IRepository<UserQualityProfiles> userProfiles, IRepository<RequestQueue> requestQueue, INotificationHelper notify)
|
||||||
{
|
{
|
||||||
SonarrApi = sonarrV3Api;
|
SonarrApi = sonarrV3Api;
|
||||||
Logger = log;
|
Logger = log;
|
||||||
SonarrSettings = sonarrSettings;
|
SonarrSettings = sonarrSettings;
|
||||||
DogNzbSettings = dog;
|
|
||||||
DogNzbApi = dogApi;
|
|
||||||
SickRageSettings = srSettings;
|
SickRageSettings = srSettings;
|
||||||
SickRageApi = srApi;
|
SickRageApi = srApi;
|
||||||
UserQualityProfiles = userProfiles;
|
UserQualityProfiles = userProfiles;
|
||||||
|
@ -40,11 +34,9 @@ namespace Ombi.Core.Senders
|
||||||
}
|
}
|
||||||
|
|
||||||
private ISonarrV3Api SonarrApi { get; }
|
private ISonarrV3Api SonarrApi { get; }
|
||||||
private IDogNzbApi DogNzbApi { get; }
|
|
||||||
private ISickRageApi SickRageApi { get; }
|
private ISickRageApi SickRageApi { get; }
|
||||||
private ILogger<TvSender> Logger { get; }
|
private ILogger<TvSender> Logger { get; }
|
||||||
private ISettingsService<SonarrSettings> SonarrSettings { get; }
|
private ISettingsService<SonarrSettings> SonarrSettings { get; }
|
||||||
private ISettingsService<DogNzbSettings> DogNzbSettings { get; }
|
|
||||||
private ISettingsService<SickRageSettings> SickRageSettings { get; }
|
private ISettingsService<SickRageSettings> SickRageSettings { get; }
|
||||||
private IRepository<UserQualityProfiles> UserQualityProfiles { get; }
|
private IRepository<UserQualityProfiles> UserQualityProfiles { get; }
|
||||||
private readonly IRepository<RequestQueue> _requestQueueRepository;
|
private readonly IRepository<RequestQueue> _requestQueueRepository;
|
||||||
|
@ -67,23 +59,7 @@ namespace Ombi.Core.Senders
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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
|
|
||||||
{
|
|
||||||
Message = result.ErrorMessage
|
|
||||||
};
|
|
||||||
}
|
|
||||||
var sr = await SickRageSettings.GetSettingsAsync();
|
var sr = await SickRageSettings.GetSettingsAsync();
|
||||||
if (sr.Enabled)
|
if (sr.Enabled)
|
||||||
{
|
{
|
||||||
|
@ -137,12 +113,6 @@ namespace Ombi.Core.Senders
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<DogNzbAddResult> SendToDogNzb(ChildRequests model, DogNzbSettings settings)
|
|
||||||
{
|
|
||||||
var id = model.ParentRequest.ExternalProviderId;
|
|
||||||
return await DogNzbApi.AddTvShow(settings.ApiKey, id.ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Send the request to Sonarr to process
|
/// Send the request to Sonarr to process
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -216,30 +186,19 @@ namespace Ombi.Core.Senders
|
||||||
}
|
}
|
||||||
|
|
||||||
// Overrides on the request take priority
|
// Overrides on the request take priority
|
||||||
if (model.ParentRequest.QualityOverride.HasValue)
|
if (model.ParentRequest.QualityOverride.HasValue && model.ParentRequest.QualityOverride.Value > 0)
|
||||||
{
|
{
|
||||||
var qualityOverride = model.ParentRequest.QualityOverride.Value;
|
qualityToUse = model.ParentRequest.QualityOverride.Value;
|
||||||
if (qualityOverride > 0)
|
|
||||||
{
|
|
||||||
qualityToUse = qualityOverride;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (model.ParentRequest.RootFolder.HasValue)
|
|
||||||
{
|
|
||||||
var rootfolderOverride = model.ParentRequest.RootFolder.Value;
|
|
||||||
if (rootfolderOverride > 0)
|
|
||||||
{
|
|
||||||
rootFolderPath = await GetSonarrRootPath(rootfolderOverride, s);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (model.ParentRequest.LanguageProfile.HasValue)
|
if (model.ParentRequest.RootFolder.HasValue && model.ParentRequest.RootFolder.Value > 0)
|
||||||
{
|
{
|
||||||
var languageProfile = model.ParentRequest.LanguageProfile.Value;
|
rootFolderPath = await GetSonarrRootPath(model.ParentRequest.RootFolder.Value, s);
|
||||||
if (languageProfile > 0)
|
|
||||||
{
|
|
||||||
languageProfileId = languageProfile;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (model.ParentRequest.LanguageProfile.HasValue && model.ParentRequest.LanguageProfile.Value > 0)
|
||||||
|
{
|
||||||
|
languageProfileId = model.ParentRequest.LanguageProfile.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -424,10 +383,11 @@ namespace Ombi.Core.Senders
|
||||||
|
|
||||||
await SonarrApi.MonitorEpisode(epToUnmonitored.Select(x => x.id).ToArray(), false, s.ApiKey, s.FullUri);
|
await SonarrApi.MonitorEpisode(epToUnmonitored.Select(x => x.id).ToArray(), false, s.ApiKey, s.FullUri);
|
||||||
}
|
}
|
||||||
// Now update the episodes that need updating
|
|
||||||
await SonarrApi.MonitorEpisode(episodesToUpdate.Where(x => x.seasonNumber == season.SeasonNumber).Select(x => x.id).ToArray(), true, s.ApiKey, s.FullUri);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Now update the episodes that need updating
|
||||||
|
await SonarrApi.MonitorEpisode(episodesToUpdate.Select(x => x.id).ToArray(), true, s.ApiKey, s.FullUri);
|
||||||
|
|
||||||
if (!s.AddOnly)
|
if (!s.AddOnly)
|
||||||
{
|
{
|
||||||
await SearchForRequest(model, sonarrEpList, result, s, episodesToUpdate);
|
await SearchForRequest(model, sonarrEpList, result, s, episodesToUpdate);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue