mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-14 02:26:55 -07:00
fix(sonarr): V4 actually works this time around
This commit is contained in:
parent
0e8940d79c
commit
f62e70fc49
5 changed files with 33 additions and 21 deletions
|
@ -10,5 +10,6 @@ namespace Ombi.Api.Sonarr
|
|||
Task<IEnumerable<LanguageProfiles>> LanguageProfiles(string apiKey, string baseUrl);
|
||||
Task<Tag> CreateTag(string apiKey, string baseUrl, string tagName);
|
||||
Task<Tag> GetTag(int tagId, string apiKey, string baseUrl);
|
||||
Task<List<MonitoredEpisodeResult>> MonitorEpisode(int[] episodeIds, bool monitor, string apiKey, string baseUrl);
|
||||
}
|
||||
}
|
|
@ -8,7 +8,7 @@ namespace Ombi.Api.Sonarr.Models
|
|||
{
|
||||
public Episode()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public Episode(Episode ep)
|
||||
|
@ -53,7 +53,7 @@ namespace Ombi.Api.Sonarr.Models
|
|||
{
|
||||
public Episodefile()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public Episodefile(Episodefile e)
|
||||
|
@ -85,7 +85,7 @@ namespace Ombi.Api.Sonarr.Models
|
|||
{
|
||||
public EpisodeQuality()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public EpisodeQuality(EpisodeQuality e)
|
||||
|
@ -101,7 +101,7 @@ namespace Ombi.Api.Sonarr.Models
|
|||
{
|
||||
public Revision()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public Revision(Revision r)
|
||||
|
@ -113,6 +113,17 @@ namespace Ombi.Api.Sonarr.Models
|
|||
public int real { get; set; }
|
||||
}
|
||||
|
||||
public class MonitoredEpisodeResult
|
||||
{
|
||||
public int seriesId { get; set; }
|
||||
public int tvdbId { get; set; }
|
||||
public int episodeFileId { get; set; }
|
||||
public int seasonNumber { get; set; }
|
||||
public int episodeNumber { get; set; }
|
||||
public string overview { get; set; }
|
||||
public bool monitored { get; set; }
|
||||
public int id { get; set; }
|
||||
}
|
||||
|
||||
public class EpisodeUpdateResult
|
||||
{
|
||||
|
|
|
@ -46,5 +46,13 @@ namespace Ombi.Api.Sonarr
|
|||
|
||||
return Api.Request<Tag>(request);
|
||||
}
|
||||
|
||||
public async Task<List<MonitoredEpisodeResult>> MonitorEpisode(int[] episodeIds, bool monitor, string apiKey, string baseUrl)
|
||||
{
|
||||
var request = new Request($"{ApiBaseUrl}Episode/monitor", baseUrl, HttpMethod.Put);
|
||||
request.AddHeader("X-Api-Key", apiKey);
|
||||
request.AddJsonBody(new { episodeIds = episodeIds, monitored = monitor });
|
||||
return await Api.Request<List<MonitoredEpisodeResult>>(request);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,8 +27,7 @@ namespace Ombi.Core.Senders
|
|||
ISettingsService<DogNzbSettings> dog, IDogNzbApi dogApi, ISettingsService<SickRageSettings> srSettings,
|
||||
ISickRageApi srApi, IRepository<UserQualityProfiles> userProfiles, IRepository<RequestQueue> requestQueue, INotificationHelper notify)
|
||||
{
|
||||
SonarrApi = sonarrApi;
|
||||
SonarrV3Api = sonarrV3Api;
|
||||
SonarrApi = sonarrV3Api;
|
||||
Logger = log;
|
||||
SonarrSettings = sonarrSettings;
|
||||
DogNzbSettings = dog;
|
||||
|
@ -40,8 +39,7 @@ namespace Ombi.Core.Senders
|
|||
_notificationHelper = notify;
|
||||
}
|
||||
|
||||
private ISonarrApi SonarrApi { get; }
|
||||
private ISonarrV3Api SonarrV3Api { get; }
|
||||
private ISonarrV3Api SonarrApi { get; }
|
||||
private IDogNzbApi DogNzbApi { get; }
|
||||
private ISickRageApi SickRageApi { get; }
|
||||
private ILogger<TvSender> Logger { get; }
|
||||
|
@ -324,16 +322,16 @@ namespace Ombi.Core.Senders
|
|||
var tagName = model.RequestedUser.UserName;
|
||||
// Does tag exist?
|
||||
|
||||
var allTags = await SonarrV3Api.GetTags(s.ApiKey, s.FullUri);
|
||||
var allTags = await SonarrApi.GetTags(s.ApiKey, s.FullUri);
|
||||
var existingTag = allTags.FirstOrDefault(x => x.label.Equals(tagName, StringComparison.InvariantCultureIgnoreCase));
|
||||
existingTag ??= await SonarrV3Api.CreateTag(s.ApiKey, s.FullUri, tagName);
|
||||
existingTag ??= await SonarrApi.CreateTag(s.ApiKey, s.FullUri, tagName);
|
||||
|
||||
return existingTag;
|
||||
}
|
||||
|
||||
private async Task<Tag> GetTag(int tagId, SonarrSettings s)
|
||||
{
|
||||
var tag = await SonarrV3Api.GetTag(tagId, s.ApiKey, s.FullUri);
|
||||
var tag = await SonarrApi.GetTag(tagId, s.ApiKey, s.FullUri);
|
||||
if (tag == null)
|
||||
{
|
||||
Logger.LogError($"Tag ID {tagId} does not exist in sonarr. Please update the settings");
|
||||
|
@ -424,16 +422,10 @@ namespace Ombi.Core.Senders
|
|||
epToUnmonitored.Add(ep);
|
||||
}
|
||||
|
||||
foreach (var epToUpdate in epToUnmonitored)
|
||||
{
|
||||
await SonarrApi.UpdateEpisode(epToUpdate, 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
|
||||
foreach (var epToUpdate in episodesToUpdate.Where(x => x.seasonNumber == season.SeasonNumber))
|
||||
{
|
||||
await SonarrApi.UpdateEpisode(epToUpdate, s.ApiKey, s.FullUri);
|
||||
}
|
||||
await SonarrApi.MonitorEpisode(episodesToUpdate.Where(x => x.seasonNumber == season.SeasonNumber).Select(x => x.id).ToArray(), true, s.ApiKey, s.FullUri);
|
||||
}
|
||||
|
||||
if (!s.AddOnly)
|
||||
|
@ -575,7 +567,7 @@ namespace Ombi.Core.Senders
|
|||
return rootFoldersResult.FirstOrDefault().path;
|
||||
}
|
||||
|
||||
foreach (var r in rootFoldersResult.Where(r => r.id == pathId))
|
||||
foreach (var r in rootFoldersResult?.Where(r => r.id == pathId))
|
||||
{
|
||||
return r.path;
|
||||
}
|
||||
|
|
|
@ -105,7 +105,7 @@ export class SonarrComponent implements OnInit {
|
|||
if (settings.rootPath) {
|
||||
this.getRootFolders(this.form);
|
||||
}
|
||||
if (settings.languageProfile) {
|
||||
if (settings.languageProfile && this.sonarrVersion === "3") {
|
||||
this.getLanguageProfiles(this.form);
|
||||
}
|
||||
if (settings.tag || settings.animeTag) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue