mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-07 13:41:13 -07:00
Fixed #1445
This commit is contained in:
parent
b8d3a88409
commit
d1d65b24de
7 changed files with 161 additions and 138 deletions
|
@ -7,7 +7,7 @@ namespace Ombi.Api.Interfaces
|
||||||
{
|
{
|
||||||
public interface IRadarrApi
|
public interface IRadarrApi
|
||||||
{
|
{
|
||||||
RadarrAddMovie AddMovie(int tmdbId, string title, int year, int qualityId, string rootPath, string apiKey, Uri baseUrl, bool searchNow = false);
|
RadarrAddMovie AddMovie(int tmdbId, string title, int year, int qualityId, string rootPath, string apiKey, Uri baseUrl, bool searchNow = false, string minimumAvailability = null);
|
||||||
List<RadarrMovieResponse> GetMovies(string apiKey, Uri baseUrl);
|
List<RadarrMovieResponse> GetMovies(string apiKey, Uri baseUrl);
|
||||||
List<SonarrProfile> GetProfiles(string apiKey, Uri baseUrl);
|
List<SonarrProfile> GetProfiles(string apiKey, Uri baseUrl);
|
||||||
SystemStatus SystemStatus(string apiKey, Uri baseUrl);
|
SystemStatus SystemStatus(string apiKey, Uri baseUrl);
|
||||||
|
|
|
@ -51,6 +51,7 @@ namespace Ombi.Api.Models.Radarr
|
||||||
public string titleSlug { get; set; }
|
public string titleSlug { get; set; }
|
||||||
public int id { get; set; }
|
public int id { get; set; }
|
||||||
public int year { get; set; }
|
public int year { get; set; }
|
||||||
|
public string minimumAvailability { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -46,6 +46,7 @@ namespace Ombi.Api.Models.Radarr
|
||||||
public class RadarrMovieResponse
|
public class RadarrMovieResponse
|
||||||
{
|
{
|
||||||
public string title { get; set; }
|
public string title { get; set; }
|
||||||
|
public string minimumAvailability { get; set; }
|
||||||
public string sortTitle { get; set; }
|
public string sortTitle { get; set; }
|
||||||
public double sizeOnDisk { get; set; }
|
public double sizeOnDisk { get; set; }
|
||||||
public string status { get; set; }
|
public string status { get; set; }
|
||||||
|
|
|
@ -77,7 +77,7 @@ namespace Ombi.Api
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RadarrAddMovie AddMovie(int tmdbId, string title, int year, int qualityId, string rootPath, string apiKey, Uri baseUrl, bool searchNow = false)
|
public RadarrAddMovie AddMovie(int tmdbId, string title, int year, int qualityId, string rootPath, string apiKey, Uri baseUrl, bool searchNow = false, string minimumAvailability = null)
|
||||||
{
|
{
|
||||||
var request = new RestRequest
|
var request = new RestRequest
|
||||||
{
|
{
|
||||||
|
@ -95,6 +95,10 @@ namespace Ombi.Api
|
||||||
monitored = true,
|
monitored = true,
|
||||||
year = year
|
year = year
|
||||||
};
|
};
|
||||||
|
if(!string.IsNullOrEmpty(minimumAvailability))
|
||||||
|
{
|
||||||
|
options.minimumAvailability = minimumAvailability;
|
||||||
|
}
|
||||||
|
|
||||||
if (searchNow)
|
if (searchNow)
|
||||||
{
|
{
|
||||||
|
|
|
@ -121,7 +121,7 @@ namespace Ombi.Core
|
||||||
}
|
}
|
||||||
|
|
||||||
var rootFolderPath = model.RootFolderSelected <= 0 ? settings.FullRootPath : GetRootPath(model.RootFolderSelected, settings);
|
var rootFolderPath = model.RootFolderSelected <= 0 ? settings.FullRootPath : GetRootPath(model.RootFolderSelected, settings);
|
||||||
var result = RadarrApi.AddMovie(model.ProviderId, model.Title, model.ReleaseDate.Year, qualityProfile, rootFolderPath, settings.ApiKey, settings.FullUri, true);
|
var result = RadarrApi.AddMovie(model.ProviderId, model.Title, model.ReleaseDate.Year, qualityProfile, rootFolderPath, settings.ApiKey, settings.FullUri, true, settings.MinimumAvailability);
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(result.Error?.message))
|
if (!string.IsNullOrEmpty(result.Error?.message))
|
||||||
{
|
{
|
||||||
|
|
|
@ -33,5 +33,6 @@ namespace Ombi.Core.SettingModels
|
||||||
public string QualityProfile { get; set; }
|
public string QualityProfile { get; set; }
|
||||||
public string RootPath { get; set; }
|
public string RootPath { get; set; }
|
||||||
public string FullRootPath { get; set; }
|
public string FullRootPath { get; set; }
|
||||||
|
public string MinimumAvailability { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -63,7 +63,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div>
|
<div>
|
||||||
<button type="submit" id="getProfiles" class="btn btn-primary-outline">Get Quality Profiles <div id="getSpinner"/></button>
|
<button type="submit" id="getProfiles" class="btn btn-primary-outline">Get Quality Profiles <div id="getSpinner" /></button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
@ -88,9 +88,25 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="selectRootFolder" class="control-label">Default Minimum Availability</label>
|
||||||
|
<div id="rootFolders">
|
||||||
|
<select class="form-control form-control-custom" id="minimumAvailability">
|
||||||
|
<option @if (Model.MinimumAvailability == "Announced") { <text> selected='selected' </text> } value='Announced'>Announced</option>
|
||||||
|
<option @if (Model.MinimumAvailability == "InCinemas") { <text> selected='selected' </text> } value='InCinemas'>In Cinemas</option>
|
||||||
|
<option @if (Model.MinimumAvailability == "Released") { <text> selected='selected' </text> } value='Released'>Physical/Web</option>
|
||||||
|
<option @if (Model.MinimumAvailability == "PreDb") { <text> selected='selected' </text> } value='PreDb'>
|
||||||
|
PreDb
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div>
|
<div>
|
||||||
<button id="testRadarr" type="button" class="btn btn-primary-outline">Test Connectivity <div id="spinner"/></button>
|
<button id="testRadarr" type="button" class="btn btn-primary-outline">Test Connectivity <div id="spinner" /></button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -110,225 +126,225 @@
|
||||||
$(function () {
|
$(function () {
|
||||||
|
|
||||||
@if (!string.IsNullOrEmpty(Model.QualityProfile))
|
@if (!string.IsNullOrEmpty(Model.QualityProfile))
|
||||||
{
|
{
|
||||||
|
|
||||||
<text>
|
<text>
|
||||||
|
|
||||||
preLoad();
|
preLoad();
|
||||||
|
|
||||||
function preLoad() {
|
function preLoad() {
|
||||||
var qualitySelected = @Model.QualityProfile;
|
var qualitySelected = @Model.QualityProfile;
|
||||||
if (!qualitySelected) {
|
if (!qualitySelected) {
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
var $form = $("#mainForm");
|
|
||||||
$.ajax({
|
|
||||||
type: $form.prop("method"),
|
|
||||||
data: $form.serialize(),
|
|
||||||
url: "radarrprofiles",
|
|
||||||
dataType: "json",
|
|
||||||
success: function(response) {
|
|
||||||
response.forEach(function(result) {
|
|
||||||
if (result.id == qualitySelected) {
|
|
||||||
|
|
||||||
$("#select").append("<option selected='selected' value='" + result.id + "'>" + result.name + "</option>");
|
|
||||||
} else {
|
|
||||||
$("#select").append("<option value='" + result.id + "'>" + result.name + "</option>");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
error: function(e) {
|
|
||||||
console.log(e);
|
|
||||||
generateNotify("Something went wrong!", "danger");
|
|
||||||
}
|
}
|
||||||
});
|
var $form = $("#mainForm");
|
||||||
|
$.ajax({
|
||||||
|
type: $form.prop("method"),
|
||||||
|
data: $form.serialize(),
|
||||||
|
url: "radarrprofiles",
|
||||||
|
dataType: "json",
|
||||||
|
success: function (response) {
|
||||||
|
response.forEach(function (result) {
|
||||||
|
if (result.id == qualitySelected) {
|
||||||
|
$("#select").append("<option selected='selected' value='" + result.id + "'>" + result.name + "</option>");
|
||||||
|
} else {
|
||||||
|
$("#select").append("<option value='" + result.id + "'>" + result.name + "</option>");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
error: function (e) {
|
||||||
|
console.log(e);
|
||||||
|
generateNotify("Something went wrong!", "danger");
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
</text>
|
</text>
|
||||||
}
|
}
|
||||||
@if (!string.IsNullOrEmpty(Model.RootPath))
|
@if (!string.IsNullOrEmpty(Model.RootPath))
|
||||||
{
|
{
|
||||||
<text>
|
<text>
|
||||||
|
|
||||||
console.log('Hit root folders..');
|
console.log('Hit root folders..');
|
||||||
|
|
||||||
var rootFolderSelected = '@rootFolder';
|
var rootFolderSelected = '@rootFolder';
|
||||||
if (!rootFolderSelected) {
|
if (!rootFolderSelected) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var $form = $("#mainForm");
|
var $form = $("#mainForm");
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: $form.prop("method"),
|
type: $form.prop("method"),
|
||||||
data: $form.serialize(),
|
data: $form.serialize(),
|
||||||
url: "sonarrrootfolders",
|
url: "sonarrrootfolders",
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
response.forEach(function(result) {
|
response.forEach(function(result) {
|
||||||
$('#selectedRootFolder').html("");
|
$('#selectedRootFolder').html("");
|
||||||
if (result.id == rootFolderSelected) {
|
if (result.id == rootFolderSelected) {
|
||||||
$("#selectRootFolder").append("<option selected='selected' value='" + result.id + "'>" + result.path + "</option>");
|
$("#selectRootFolder").append("<option selected='selected' value='" + result.id + "'>" + result.path + "</option>");
|
||||||
} else {
|
} else {
|
||||||
$("#selectRootFolder").append("<option value='" + result.id + "'>" + result.path + "</option>");
|
$("#selectRootFolder").append("<option value='" + result.id + "'>" + result.path + "</option>");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
error: function(e) {
|
error: function(e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
generateNotify("Something went wrong!", "danger");
|
generateNotify("Something went wrong!", "danger");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</text>
|
</text>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$('#save').click(function(e) {
|
$('#save').click(function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var port = $('#portNumber').val();
|
var port = $('#portNumber').val();
|
||||||
if (isNaN(port)) {
|
if (isNaN(port)) {
|
||||||
generateNotify("You must specify a Port.", "warning");
|
generateNotify("You must specify a Port.", "warning");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var qualityProfile = $("#profiles option:selected").val();
|
var qualityProfile = $("#profiles option:selected").val();
|
||||||
var rootFolder = $("#rootFolders option:selected").val();
|
var rootFolder = $("#rootFolders option:selected").val();
|
||||||
var rootFolderPath = $('#rootFolders option:selected').text();
|
var rootFolderPath = $('#rootFolders option:selected').text();
|
||||||
$('#fullRootPath').val(rootFolderPath);
|
$('#fullRootPath').val(rootFolderPath);
|
||||||
|
var minAvailability = $('#minimumAvailability option:selected').val();
|
||||||
|
|
||||||
var $form = $("#mainForm");
|
var $form = $("#mainForm");
|
||||||
|
|
||||||
var data = $form.serialize();
|
var data = $form.serialize();
|
||||||
data = data + "&qualityProfile=" + qualityProfile + "&rootPath=" + rootFolder;
|
data = data + "&qualityProfile=" + qualityProfile + "&rootPath=" + rootFolder + "&minimumAvailability=" + minAvailability;
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: $form.prop("method"),
|
type: $form.prop("method"),
|
||||||
data: data,
|
data: data,
|
||||||
url: $form.prop("action"),
|
url: $form.prop("action"),
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
success: function (response) {
|
success: function (response) {
|
||||||
if (response.result === true) {
|
if (response.result === true) {
|
||||||
generateNotify("Success!", "success");
|
generateNotify("Success!", "success");
|
||||||
} else {
|
} else {
|
||||||
generateNotify(response.message, "warning");
|
generateNotify(response.message, "warning");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: function (e) {
|
error: function (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
generateNotify("Something went wrong!", "danger");
|
generateNotify("Something went wrong!", "danger");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#getProfiles').click(function (e) {
|
$('#getProfiles').click(function (e) {
|
||||||
|
|
||||||
$('#getSpinner').attr("class", "fa fa-spinner fa-spin");
|
$('#getSpinner').attr("class", "fa fa-spinner fa-spin");
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (!$('#Ip').val()) {
|
if (!$('#Ip').val()) {
|
||||||
generateNotify("Please enter a valid IP/Hostname.", "warning");
|
generateNotify("Please enter a valid IP/Hostname.", "warning");
|
||||||
$('#getSpinner').attr("class", "fa fa-times");
|
$('#getSpinner').attr("class", "fa fa-times");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!$('#portNumber').val()) {
|
if (!$('#portNumber').val()) {
|
||||||
generateNotify("Please enter a valid Port Number.", "warning");
|
generateNotify("Please enter a valid Port Number.", "warning");
|
||||||
$('#getSpinner').attr("class", "fa fa-times");
|
$('#getSpinner').attr("class", "fa fa-times");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!$('#ApiKey').val()) {
|
if (!$('#ApiKey').val()) {
|
||||||
generateNotify("Please enter a valid ApiKey.", "warning");
|
generateNotify("Please enter a valid ApiKey.", "warning");
|
||||||
$('#getSpinner').attr("class", "fa fa-times");
|
$('#getSpinner').attr("class", "fa fa-times");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var $form = $("#mainForm");
|
var $form = $("#mainForm");
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: $form.prop("method"),
|
type: $form.prop("method"),
|
||||||
data: $form.serialize(),
|
data: $form.serialize(),
|
||||||
url: "radarrprofiles",
|
url: "radarrprofiles",
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
success: function (response) {
|
success: function (response) {
|
||||||
response.forEach(function (result) {
|
response.forEach(function (result) {
|
||||||
$('#getSpinner').attr("class", "fa fa-check");
|
$('#getSpinner').attr("class", "fa fa-check");
|
||||||
$("#select").append("<option value='" + result.id + "'>" + result.name + "</option>");
|
$("#select").append("<option value='" + result.id + "'>" + result.name + "</option>");
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
error: function (e) {
|
error: function (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
$('#getSpinner').attr("class", "fa fa-times");
|
$('#getSpinner').attr("class", "fa fa-times");
|
||||||
generateNotify("Something went wrong!", "danger");
|
generateNotify("Something went wrong!", "danger");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#getRootFolders').click(function (e) {
|
$('#getRootFolders').click(function (e) {
|
||||||
|
|
||||||
$('#getRootFolderSpinner').attr("class", "fa fa-spinner fa-spin");
|
$('#getRootFolderSpinner').attr("class", "fa fa-spinner fa-spin");
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (!$('#Ip').val()) {
|
if (!$('#Ip').val()) {
|
||||||
generateNotify("Please enter a valid IP/Hostname.", "warning");
|
generateNotify("Please enter a valid IP/Hostname.", "warning");
|
||||||
$('#getRootFolderSpinner').attr("class", "fa fa-times");
|
$('#getRootFolderSpinner').attr("class", "fa fa-times");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!$('#portNumber').val()) {
|
if (!$('#portNumber').val()) {
|
||||||
generateNotify("Please enter a valid Port Number.", "warning");
|
generateNotify("Please enter a valid Port Number.", "warning");
|
||||||
$('#getRootFolderSpinner').attr("class", "fa fa-times");
|
$('#getRootFolderSpinner').attr("class", "fa fa-times");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!$('#ApiKey').val()) {
|
if (!$('#ApiKey').val()) {
|
||||||
generateNotify("Please enter a valid ApiKey.", "warning");
|
generateNotify("Please enter a valid ApiKey.", "warning");
|
||||||
$('#getRootFolderSpinner').attr("class", "fa fa-times");
|
$('#getRootFolderSpinner').attr("class", "fa fa-times");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var $form = $("#mainForm");
|
var $form = $("#mainForm");
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: $form.prop("method"),
|
type: $form.prop("method"),
|
||||||
data: $form.serialize(),
|
data: $form.serialize(),
|
||||||
url: "radarrrootfolders",
|
url: "radarrrootfolders",
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
success: function (response) {
|
success: function (response) {
|
||||||
response.forEach(function (result) {
|
response.forEach(function (result) {
|
||||||
$('#getRootFolderSpinner').attr("class", "fa fa-check");
|
$('#getRootFolderSpinner').attr("class", "fa fa-check");
|
||||||
$("#selectRootFolder").append("<option value='" + result.id + "'>" + result.path + "</option>");
|
$("#selectRootFolder").append("<option value='" + result.id + "'>" + result.path + "</option>");
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
error: function (e) {
|
error: function (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
$('#getRootFolderSpinner').attr("class", "fa fa-times");
|
$('#getRootFolderSpinner').attr("class", "fa fa-times");
|
||||||
generateNotify("Something went wrong!", "danger");
|
generateNotify("Something went wrong!", "danger");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
var base = '@Html.GetBaseUrl()';
|
var base = '@Html.GetBaseUrl()';
|
||||||
$('#testRadarr').click(function (e) {
|
$('#testRadarr').click(function (e) {
|
||||||
|
|
||||||
$('#spinner').attr("class", "fa fa-spinner fa-spin");
|
$('#spinner').attr("class", "fa fa-spinner fa-spin");
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var qualityProfile = $("#profiles option:selected").val();
|
var qualityProfile = $("#profiles option:selected").val();
|
||||||
|
|
||||||
var $form = $("#mainForm");
|
var $form = $("#mainForm");
|
||||||
|
|
||||||
var data = $form.serialize();
|
var data = $form.serialize();
|
||||||
data = data + "&qualityProfile=" + qualityProfile;
|
data = data + "&qualityProfile=" + qualityProfile;
|
||||||
|
|
||||||
var url = createBaseUrl(base, '/test/radarr');
|
var url = createBaseUrl(base, '/test/radarr');
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: $form.prop("method"),
|
type: $form.prop("method"),
|
||||||
url: url,
|
url: url,
|
||||||
data: data,
|
data: data,
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
success: function (response) {
|
success: function (response) {
|
||||||
console.log(response);
|
console.log(response);
|
||||||
if (response.result === true) {
|
if (response.result === true) {
|
||||||
generateNotify(response.message, "success");
|
generateNotify(response.message, "success");
|
||||||
$('#spinner').attr("class", "fa fa-check");
|
$('#spinner').attr("class", "fa fa-check");
|
||||||
} else {
|
} else {
|
||||||
generateNotify(response.message, "warning");
|
generateNotify(response.message, "warning");
|
||||||
$('#spinner').attr("class", "fa fa-times");
|
$('#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");
|
$('#spinner').attr("class", "fa fa-times");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue