mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-14 10:36:54 -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,
|
||||
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);
|
||||
|
||||
List<Series> GetSeries(string apiKey, Uri baseUrl);
|
||||
|
|
|
@ -135,6 +135,75 @@ namespace PlexRequests.Api
|
|||
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)
|
||||
{
|
||||
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%">
|
||||
<tr>
|
||||
<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>
|
||||
</tr>
|
||||
<tr>
|
||||
|
|
|
@ -144,7 +144,7 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Notification\Templates\BasicRequestTemplate.html">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<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%">
|
||||
<tr>
|
||||
<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>
|
||||
</tr>
|
||||
<tr>
|
||||
|
|
|
@ -119,43 +119,19 @@ namespace PlexRequests.UI.Helpers
|
|||
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
|
||||
if (series == null)
|
||||
{
|
||||
// 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,
|
||||
sonarrSettings.SeasonFolders, sonarrSettings.RootPath, 0, model.SeasonList, sonarrSettings.ApiKey,
|
||||
SonarrApi.AddSeriesNew(model.ProviderId, model.Title, qualityProfile,
|
||||
sonarrSettings.SeasonFolders, sonarrSettings.RootPath, new int[] {1,2,3,4,5,6,7,8,9,10,11,12,13}, sonarrSettings.ApiKey,
|
||||
sonarrSettings.FullUri);
|
||||
|
||||
await Task.Delay(TimeSpan.FromSeconds(1));
|
||||
|
||||
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)
|
||||
{
|
||||
s.monitored = false;
|
||||
|
@ -164,6 +140,29 @@ namespace PlexRequests.UI.Helpers
|
|||
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)
|
||||
{
|
||||
var firstSeries = (series?.seasons?.OrderBy(x => x.seasonNumber)).FirstOrDefault(x => x.seasonNumber > 0) ?? new Season();
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
|
||||
<div class="form-group">
|
||||
<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>
|
||||
|
||||
|
@ -103,7 +103,7 @@
|
|||
e.preventDefault();
|
||||
var base = '@Html.GetBaseUrl()';
|
||||
var url = createBaseUrl(base, '/admin/recentlyAddedTest');
|
||||
|
||||
$('#spinner').attr("class", "fa fa-spinner fa-spin");
|
||||
$.ajax({
|
||||
type: "post",
|
||||
url: url,
|
||||
|
@ -111,14 +111,17 @@
|
|||
success: function (response) {
|
||||
if (response) {
|
||||
generateNotify(response.message, "success");
|
||||
$('#spinner').attr("class", "fa fa-check");
|
||||
} else {
|
||||
|
||||
generateNotify(response.message, "danger");
|
||||
$('#spinner').attr("class", "fa fa-times");
|
||||
}
|
||||
},
|
||||
error: function (e) {
|
||||
console.log(e);
|
||||
generateNotify("Something went wrong!", "danger");
|
||||
$('#spinner').attr("class", "fa fa-times");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -223,11 +223,10 @@
|
|||
{{/if}}
|
||||
<div>@UI.Requests_RequestedDate: {{requestedDate}}</div>
|
||||
<div>
|
||||
@UI.Issues_Issue:
|
||||
{{#if_eq issueId 0}}
|
||||
<i class="fa fa-times"></i>
|
||||
@*Nothing*@
|
||||
{{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}}
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue