mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-19 21:03:17 -07:00
fixed #608 and some other small stuff
This commit is contained in:
parent
bbe52a17d8
commit
4dc4f83506
8 changed files with 109 additions and 35 deletions
|
@ -39,6 +39,10 @@ namespace PlexRequests.Api.Interfaces
|
||||||
int seasonCount, int[] seasons, string apiKey, Uri baseUrl, bool monitor = true,
|
int seasonCount, int[] seasons, string apiKey, Uri baseUrl, bool monitor = true,
|
||||||
bool searchForMissingEpisodes = false);
|
bool searchForMissingEpisodes = false);
|
||||||
|
|
||||||
|
SonarrAddSeries AddSeriesNew(int tvdbId, string title, int qualityId, bool seasonFolders, string rootPath,
|
||||||
|
int[] seasons, string apiKey, Uri baseUrl, bool monitor = true,
|
||||||
|
bool searchForMissingEpisodes = false);
|
||||||
|
|
||||||
SystemStatus SystemStatus(string apiKey, Uri baseUrl);
|
SystemStatus SystemStatus(string apiKey, Uri baseUrl);
|
||||||
|
|
||||||
List<Series> GetSeries(string apiKey, Uri baseUrl);
|
List<Series> GetSeries(string apiKey, Uri baseUrl);
|
||||||
|
|
|
@ -135,6 +135,75 @@ namespace PlexRequests.Api
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SonarrAddSeries AddSeriesNew(int tvdbId, string title, int qualityId, bool seasonFolders, string rootPath, int[] seasons, string apiKey, Uri baseUrl, bool monitor = true, bool searchForMissingEpisodes = false)
|
||||||
|
{
|
||||||
|
var request = new RestRequest
|
||||||
|
{
|
||||||
|
Resource = "/api/Series?",
|
||||||
|
Method = Method.POST
|
||||||
|
};
|
||||||
|
|
||||||
|
var options = new SonarrAddSeries
|
||||||
|
{
|
||||||
|
seasonFolder = seasonFolders,
|
||||||
|
title = title,
|
||||||
|
qualityProfileId = qualityId,
|
||||||
|
tvdbId = tvdbId,
|
||||||
|
titleSlug = title,
|
||||||
|
seasons = new List<Season>(),
|
||||||
|
rootFolderPath = rootPath,
|
||||||
|
monitored = monitor
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!searchForMissingEpisodes)
|
||||||
|
{
|
||||||
|
options.addOptions = new AddOptions
|
||||||
|
{
|
||||||
|
searchForMissingEpisodes = false,
|
||||||
|
ignoreEpisodesWithFiles = true,
|
||||||
|
ignoreEpisodesWithoutFiles = true
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var i = 1; i <= seasons.Length; i++)
|
||||||
|
{
|
||||||
|
var season = new Season
|
||||||
|
{
|
||||||
|
seasonNumber = i,
|
||||||
|
// ReSharper disable once SimplifyConditionalTernaryExpression
|
||||||
|
monitored = true
|
||||||
|
};
|
||||||
|
options.seasons.Add(season);
|
||||||
|
}
|
||||||
|
|
||||||
|
Log.Debug("Sonarr API Options:");
|
||||||
|
Log.Debug(options.DumpJson());
|
||||||
|
|
||||||
|
request.AddHeader("X-Api-Key", apiKey);
|
||||||
|
request.AddJsonBody(options);
|
||||||
|
|
||||||
|
SonarrAddSeries result;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var policy = RetryHandler.RetryAndWaitPolicy((exception, timespan) => Log.Error(exception, "Exception when calling AddSeries for Sonarr, Retrying {0}", timespan), new TimeSpan[] {
|
||||||
|
TimeSpan.FromSeconds (1),
|
||||||
|
TimeSpan.FromSeconds(2),
|
||||||
|
});
|
||||||
|
|
||||||
|
result = policy.Execute(() => Api.ExecuteJson<SonarrAddSeries>(request, baseUrl));
|
||||||
|
}
|
||||||
|
catch (JsonSerializationException jse)
|
||||||
|
{
|
||||||
|
Log.Error(jse);
|
||||||
|
var error = Api.ExecuteJson<List<SonarrError>>(request, baseUrl);
|
||||||
|
var messages = error?.Select(x => x.errorMessage).ToList();
|
||||||
|
messages?.ForEach(x => Log.Error(x));
|
||||||
|
result = new SonarrAddSeries { ErrorMessages = messages };
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
public SystemStatus SystemStatus(string apiKey, Uri baseUrl)
|
public SystemStatus SystemStatus(string apiKey, Uri baseUrl)
|
||||||
{
|
{
|
||||||
var request = new RestRequest { Resource = "/api/system/status", Method = Method.GET };
|
var request = new RestRequest { Resource = "/api/system/status", Method = Method.GET };
|
||||||
|
|
|
@ -144,7 +144,7 @@
|
||||||
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 100%;" width="100%">
|
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 100%;" width="100%">
|
||||||
<tr>
|
<tr>
|
||||||
<td align="center">
|
<td align="center">
|
||||||
<img src="http://i.imgur.com/s4nswSA.png?" width="400px" text-align="center" />
|
<img src="http://i.imgur.com/ROTp8mn.png" text-align="center" />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
|
|
@ -144,7 +144,7 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="Notification\Templates\BasicRequestTemplate.html">
|
<Content Include="Notification\Templates\BasicRequestTemplate.html">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
|
|
@ -144,7 +144,7 @@
|
||||||
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 100%;" width="100%">
|
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 100%;" width="100%">
|
||||||
<tr>
|
<tr>
|
||||||
<td align="center">
|
<td align="center">
|
||||||
<img src="http://i.imgur.com/s4nswSA.png?" width="400px" text-align="center" />
|
<img src="http://i.imgur.com/ROTp8mn.png" text-align="center" />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
|
|
@ -119,35 +119,12 @@ namespace PlexRequests.UI.Helpers
|
||||||
return addResult;
|
return addResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (requestAll ?? false)
|
|
||||||
{
|
|
||||||
//// Monitor all seasons
|
|
||||||
//foreach (var season in series.seasons)
|
|
||||||
//{
|
|
||||||
// season.monitored = true;
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
||||||
//SonarrApi.UpdateSeries(series, sonarrSettings.ApiKey, sonarrSettings.FullUri);
|
|
||||||
//SonarrApi.SearchForSeries(series.id, sonarrSettings.ApiKey, sonarrSettings.FullUri); // Search For all episodes!"
|
|
||||||
|
|
||||||
|
|
||||||
// This is a work around for this issue: https://github.com/Sonarr/Sonarr/issues/1507
|
|
||||||
// The above is the previous code.
|
|
||||||
SonarrApi.AddSeries(model.ProviderId, model.Title, qualityProfile,
|
|
||||||
sonarrSettings.SeasonFolders, sonarrSettings.RootPath, 0, model.SeasonList, sonarrSettings.ApiKey,
|
|
||||||
sonarrSettings.FullUri, true, true);
|
|
||||||
return new SonarrAddSeries { title = series.title }; // We have updated it
|
|
||||||
}
|
|
||||||
|
|
||||||
// Series exists, don't need to add it
|
// Series exists, don't need to add it
|
||||||
if (series == null)
|
if (series == null)
|
||||||
{
|
{
|
||||||
// Set the series as monitored with a season count as 0 so it doesn't search for anything
|
// Set the series as monitored with a season count as 0 so it doesn't search for anything
|
||||||
SonarrApi.AddSeries(model.ProviderId, model.Title, qualityProfile,
|
SonarrApi.AddSeriesNew(model.ProviderId, model.Title, qualityProfile,
|
||||||
sonarrSettings.SeasonFolders, sonarrSettings.RootPath, 0, model.SeasonList, sonarrSettings.ApiKey,
|
sonarrSettings.SeasonFolders, sonarrSettings.RootPath, new int[] {1,2,3,4,5,6,7,8,9,10,11,12,13}, sonarrSettings.ApiKey,
|
||||||
sonarrSettings.FullUri);
|
sonarrSettings.FullUri);
|
||||||
|
|
||||||
await Task.Delay(TimeSpan.FromSeconds(1));
|
await Task.Delay(TimeSpan.FromSeconds(1));
|
||||||
|
@ -155,7 +132,6 @@ namespace PlexRequests.UI.Helpers
|
||||||
series = await GetSonarrSeries(sonarrSettings, model.ProviderId);
|
series = await GetSonarrSeries(sonarrSettings, model.ProviderId);
|
||||||
|
|
||||||
|
|
||||||
// Due to the bug above, we need to make sure all seasons are not monitored
|
|
||||||
foreach (var s in series.seasons)
|
foreach (var s in series.seasons)
|
||||||
{
|
{
|
||||||
s.monitored = false;
|
s.monitored = false;
|
||||||
|
@ -164,6 +140,29 @@ namespace PlexRequests.UI.Helpers
|
||||||
SonarrApi.UpdateSeries(series, sonarrSettings.ApiKey, sonarrSettings.FullUri);
|
SonarrApi.UpdateSeries(series, sonarrSettings.ApiKey, sonarrSettings.FullUri);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (requestAll ?? false)
|
||||||
|
{
|
||||||
|
// Monitor all seasons
|
||||||
|
foreach (var season in series.seasons)
|
||||||
|
{
|
||||||
|
season.monitored = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SonarrApi.UpdateSeries(series, sonarrSettings.ApiKey, sonarrSettings.FullUri);
|
||||||
|
SonarrApi.SearchForSeries(series.id, sonarrSettings.ApiKey, sonarrSettings.FullUri); // Search For all episodes!"
|
||||||
|
|
||||||
|
|
||||||
|
//// This is a work around for this issue: https://github.com/Sonarr/Sonarr/issues/1507
|
||||||
|
//// The above is the previous code.
|
||||||
|
//SonarrApi.AddSeries(model.ProviderId, model.Title, qualityProfile,
|
||||||
|
// sonarrSettings.SeasonFolders, sonarrSettings.RootPath, 0, model.SeasonList, sonarrSettings.ApiKey,
|
||||||
|
// sonarrSettings.FullUri, true, true);
|
||||||
|
return new SonarrAddSeries { title = series.title }; // We have updated it
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (first ?? false)
|
if (first ?? false)
|
||||||
{
|
{
|
||||||
var firstSeries = (series?.seasons?.OrderBy(x => x.seasonNumber)).FirstOrDefault(x => x.seasonNumber > 0) ?? new Season();
|
var firstSeries = (series?.seasons?.OrderBy(x => x.seasonNumber)).FirstOrDefault(x => x.seasonNumber > 0) ?? new Season();
|
||||||
|
|
|
@ -50,7 +50,7 @@
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div>
|
<div>
|
||||||
<button id="recentlyAddedBtn" class="btn btn-primary-outline">Send test email to Admin</button>
|
<button id="recentlyAddedBtn" class="btn btn-primary-outline">Send test email to Admin <div id="spinner"></div></button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var base = '@Html.GetBaseUrl()';
|
var base = '@Html.GetBaseUrl()';
|
||||||
var url = createBaseUrl(base, '/admin/recentlyAddedTest');
|
var url = createBaseUrl(base, '/admin/recentlyAddedTest');
|
||||||
|
$('#spinner').attr("class", "fa fa-spinner fa-spin");
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "post",
|
type: "post",
|
||||||
url: url,
|
url: url,
|
||||||
|
@ -111,14 +111,17 @@
|
||||||
success: function (response) {
|
success: function (response) {
|
||||||
if (response) {
|
if (response) {
|
||||||
generateNotify(response.message, "success");
|
generateNotify(response.message, "success");
|
||||||
|
$('#spinner').attr("class", "fa fa-check");
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
generateNotify(response.message, "danger");
|
generateNotify(response.message, "danger");
|
||||||
|
$('#spinner').attr("class", "fa fa-times");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: function (e) {
|
error: function (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
generateNotify("Something went wrong!", "danger");
|
generateNotify("Something went wrong!", "danger");
|
||||||
|
$('#spinner').attr("class", "fa fa-times");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -223,11 +223,10 @@
|
||||||
{{/if}}
|
{{/if}}
|
||||||
<div>@UI.Requests_RequestedDate: {{requestedDate}}</div>
|
<div>@UI.Requests_RequestedDate: {{requestedDate}}</div>
|
||||||
<div>
|
<div>
|
||||||
@UI.Issues_Issue:
|
|
||||||
{{#if_eq issueId 0}}
|
{{#if_eq issueId 0}}
|
||||||
<i class="fa fa-times"></i>
|
@*Nothing*@
|
||||||
{{else}}
|
{{else}}
|
||||||
<a href="@formAction/issues/{{issueId}}"><i class="fa fa-check"></i></a>
|
@UI.Issues_Issue: <a href="@formAction/issues/{{issueId}}"><i class="fa fa-check"></i></a>
|
||||||
{{/if_eq}}
|
{{/if_eq}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue