diff --git a/Ombi.Api.Interfaces/IRadarrApi.cs b/Ombi.Api.Interfaces/IRadarrApi.cs index f1b015d31..ac8ca558b 100644 --- a/Ombi.Api.Interfaces/IRadarrApi.cs +++ b/Ombi.Api.Interfaces/IRadarrApi.cs @@ -7,7 +7,7 @@ namespace Ombi.Api.Interfaces { 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 GetMovies(string apiKey, Uri baseUrl); List GetProfiles(string apiKey, Uri baseUrl); SystemStatus SystemStatus(string apiKey, Uri baseUrl); diff --git a/Ombi.Api.Models/Radarr/RadarrAddMovie.cs b/Ombi.Api.Models/Radarr/RadarrAddMovie.cs index 4b8aeb452..98c1875f8 100644 --- a/Ombi.Api.Models/Radarr/RadarrAddMovie.cs +++ b/Ombi.Api.Models/Radarr/RadarrAddMovie.cs @@ -51,6 +51,7 @@ namespace Ombi.Api.Models.Radarr public string titleSlug { get; set; } public int id { get; set; } public int year { get; set; } + public string minimumAvailability { get; set; } } } \ No newline at end of file diff --git a/Ombi.Api.Models/Radarr/RadarrMovieResponse.cs b/Ombi.Api.Models/Radarr/RadarrMovieResponse.cs index 9b5bf0c2b..19eac8306 100644 --- a/Ombi.Api.Models/Radarr/RadarrMovieResponse.cs +++ b/Ombi.Api.Models/Radarr/RadarrMovieResponse.cs @@ -46,6 +46,7 @@ namespace Ombi.Api.Models.Radarr public class RadarrMovieResponse { public string title { get; set; } + public string minimumAvailability { get; set; } public string sortTitle { get; set; } public double sizeOnDisk { get; set; } public string status { get; set; } diff --git a/Ombi.Api/RadarrApi.cs b/Ombi.Api/RadarrApi.cs index 1840f40a0..5b55079b1 100644 --- a/Ombi.Api/RadarrApi.cs +++ b/Ombi.Api/RadarrApi.cs @@ -77,7 +77,7 @@ namespace Ombi.Api 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 { @@ -95,6 +95,10 @@ namespace Ombi.Api monitored = true, year = year }; + if(!string.IsNullOrEmpty(minimumAvailability)) + { + options.minimumAvailability = minimumAvailability; + } if (searchNow) { diff --git a/Ombi.Core/MovieSender.cs b/Ombi.Core/MovieSender.cs index c7636ba83..0da56b3c1 100644 --- a/Ombi.Core/MovieSender.cs +++ b/Ombi.Core/MovieSender.cs @@ -121,7 +121,7 @@ namespace Ombi.Core } 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)) { diff --git a/Ombi.Core/SettingModels/RadarrSettings.cs b/Ombi.Core/SettingModels/RadarrSettings.cs index f5d994535..3864c3f34 100644 --- a/Ombi.Core/SettingModels/RadarrSettings.cs +++ b/Ombi.Core/SettingModels/RadarrSettings.cs @@ -33,5 +33,6 @@ namespace Ombi.Core.SettingModels public string QualityProfile { get; set; } public string RootPath { get; set; } public string FullRootPath { get; set; } + public string MinimumAvailability { get; set; } } } \ No newline at end of file diff --git a/Ombi.UI/Views/Integration/Radarr.cshtml b/Ombi.UI/Views/Integration/Radarr.cshtml index 05e653ad2..363808cfc 100644 --- a/Ombi.UI/Views/Integration/Radarr.cshtml +++ b/Ombi.UI/Views/Integration/Radarr.cshtml @@ -63,7 +63,7 @@
- +
@@ -88,9 +88,25 @@
+
+ +
+ +
+ +
+ +
- +
@@ -110,225 +126,225 @@ $(function () { @if (!string.IsNullOrEmpty(Model.QualityProfile)) - { + { preLoad(); - function preLoad() { - var qualitySelected = @Model.QualityProfile; - if (!qualitySelected) { - 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(""); - } else { - $("#select").append(""); - } - }); - }, - error: function(e) { - console.log(e); - generateNotify("Something went wrong!", "danger"); + function preLoad() { + var qualitySelected = @Model.QualityProfile; + if (!qualitySelected) { + 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(""); + } else { + $("#select").append(""); + } + }); + }, + error: function (e) { + console.log(e); + generateNotify("Something went wrong!", "danger"); + } + }); } } @if (!string.IsNullOrEmpty(Model.RootPath)) - { + { console.log('Hit root folders..'); - var rootFolderSelected = '@rootFolder'; - if (!rootFolderSelected) { - return; - } - var $form = $("#mainForm"); + var rootFolderSelected = '@rootFolder'; + if (!rootFolderSelected) { + return; + } + var $form = $("#mainForm"); $.ajax({ - type: $form.prop("method"), + type: $form.prop("method"), data: $form.serialize(), url: "sonarrrootfolders", dataType: "json", success: function(response) { - response.forEach(function(result) { + response.forEach(function(result) { $('#selectedRootFolder').html(""); - if (result.id == rootFolderSelected) { + if (result.id == rootFolderSelected) { $("#selectRootFolder").append(""); - } else { + } else { $("#selectRootFolder").append(""); - } - }); - }, + } + }); + }, error: function(e) { - console.log(e); - generateNotify("Something went wrong!", "danger"); - } - }); + console.log(e); + generateNotify("Something went wrong!", "danger"); + } + }); } $('#save').click(function(e) { - e.preventDefault(); - var port = $('#portNumber').val(); - if (isNaN(port)) { - generateNotify("You must specify a Port.", "warning"); - return; - } - var qualityProfile = $("#profiles option:selected").val(); - var rootFolder = $("#rootFolders option:selected").val(); - var rootFolderPath = $('#rootFolders option:selected').text(); - $('#fullRootPath').val(rootFolderPath); + e.preventDefault(); + var port = $('#portNumber').val(); + if (isNaN(port)) { + generateNotify("You must specify a Port.", "warning"); + return; + } + var qualityProfile = $("#profiles option:selected").val(); + var rootFolder = $("#rootFolders option:selected").val(); + var rootFolderPath = $('#rootFolders option:selected').text(); + $('#fullRootPath').val(rootFolderPath); + var minAvailability = $('#minimumAvailability option:selected').val(); - var $form = $("#mainForm"); + var $form = $("#mainForm"); - var data = $form.serialize(); - data = data + "&qualityProfile=" + qualityProfile + "&rootPath=" + rootFolder; + var data = $form.serialize(); + data = data + "&qualityProfile=" + qualityProfile + "&rootPath=" + rootFolder + "&minimumAvailability=" + minAvailability; $.ajax({ - type: $form.prop("method"), + type: $form.prop("method"), data: data, url: $form.prop("action"), dataType: "json", success: function (response) { - if (response.result === true) { - generateNotify("Success!", "success"); - } else { - generateNotify(response.message, "warning"); - } - }, + if (response.result === true) { + generateNotify("Success!", "success"); + } else { + generateNotify(response.message, "warning"); + } + }, error: function (e) { - console.log(e); - generateNotify("Something went wrong!", "danger"); - } - }); - }); + console.log(e); + generateNotify("Something went wrong!", "danger"); + } + }); + }); $('#getProfiles').click(function (e) { $('#getSpinner').attr("class", "fa fa-spinner fa-spin"); - e.preventDefault(); - if (!$('#Ip').val()) { - generateNotify("Please enter a valid IP/Hostname.", "warning"); + e.preventDefault(); + if (!$('#Ip').val()) { + generateNotify("Please enter a valid IP/Hostname.", "warning"); $('#getSpinner').attr("class", "fa fa-times"); - return; - } - if (!$('#portNumber').val()) { - generateNotify("Please enter a valid Port Number.", "warning"); + return; + } + if (!$('#portNumber').val()) { + generateNotify("Please enter a valid Port Number.", "warning"); $('#getSpinner').attr("class", "fa fa-times"); - return; - } - if (!$('#ApiKey').val()) { - generateNotify("Please enter a valid ApiKey.", "warning"); + return; + } + if (!$('#ApiKey').val()) { + generateNotify("Please enter a valid ApiKey.", "warning"); $('#getSpinner').attr("class", "fa fa-times"); - return; - } - var $form = $("#mainForm"); + return; + } + var $form = $("#mainForm"); $.ajax({ - type: $form.prop("method"), + type: $form.prop("method"), data: $form.serialize(), url: "radarrprofiles", dataType: "json", success: function (response) { - response.forEach(function (result) { + response.forEach(function (result) { $('#getSpinner').attr("class", "fa fa-check"); $("#select").append(""); - }); - }, + }); + }, error: function (e) { - console.log(e); + console.log(e); $('#getSpinner').attr("class", "fa fa-times"); - generateNotify("Something went wrong!", "danger"); - } - }); - }); + generateNotify("Something went wrong!", "danger"); + } + }); + }); $('#getRootFolders').click(function (e) { $('#getRootFolderSpinner').attr("class", "fa fa-spinner fa-spin"); - e.preventDefault(); - if (!$('#Ip').val()) { - generateNotify("Please enter a valid IP/Hostname.", "warning"); + e.preventDefault(); + if (!$('#Ip').val()) { + generateNotify("Please enter a valid IP/Hostname.", "warning"); $('#getRootFolderSpinner').attr("class", "fa fa-times"); - return; - } - if (!$('#portNumber').val()) { - generateNotify("Please enter a valid Port Number.", "warning"); + return; + } + if (!$('#portNumber').val()) { + generateNotify("Please enter a valid Port Number.", "warning"); $('#getRootFolderSpinner').attr("class", "fa fa-times"); - return; - } - if (!$('#ApiKey').val()) { - generateNotify("Please enter a valid ApiKey.", "warning"); + return; + } + if (!$('#ApiKey').val()) { + generateNotify("Please enter a valid ApiKey.", "warning"); $('#getRootFolderSpinner').attr("class", "fa fa-times"); - return; - } - var $form = $("#mainForm"); + return; + } + var $form = $("#mainForm"); $.ajax({ - type: $form.prop("method"), + type: $form.prop("method"), data: $form.serialize(), url: "radarrrootfolders", dataType: "json", success: function (response) { - response.forEach(function (result) { + response.forEach(function (result) { $('#getRootFolderSpinner').attr("class", "fa fa-check"); $("#selectRootFolder").append(""); - }); - }, + }); + }, error: function (e) { - console.log(e); + console.log(e); $('#getRootFolderSpinner').attr("class", "fa fa-times"); - generateNotify("Something went wrong!", "danger"); - } - }); - }); + generateNotify("Something went wrong!", "danger"); + } + }); + }); var base = '@Html.GetBaseUrl()'; $('#testRadarr').click(function (e) { $('#spinner').attr("class", "fa fa-spinner fa-spin"); - e.preventDefault(); - var qualityProfile = $("#profiles option:selected").val(); + e.preventDefault(); + var qualityProfile = $("#profiles option:selected").val(); - var $form = $("#mainForm"); + var $form = $("#mainForm"); - var data = $form.serialize(); - data = data + "&qualityProfile=" + qualityProfile; + var data = $form.serialize(); + data = data + "&qualityProfile=" + qualityProfile; - var url = createBaseUrl(base, '/test/radarr'); + var url = createBaseUrl(base, '/test/radarr'); $.ajax({ - type: $form.prop("method"), + type: $form.prop("method"), url: url, data: data, dataType: "json", success: function (response) { - console.log(response); - if (response.result === true) { - generateNotify(response.message, "success"); + console.log(response); + if (response.result === true) { + generateNotify(response.message, "success"); $('#spinner').attr("class", "fa fa-check"); - } else { - generateNotify(response.message, "warning"); + } else { + generateNotify(response.message, "warning"); $('#spinner').attr("class", "fa fa-times"); - } - }, + } + }, error: function (e) { - console.log(e); - generateNotify("Something went wrong!", "danger"); + console.log(e); + generateNotify("Something went wrong!", "danger"); $('#spinner').attr("class", "fa fa-times"); - } - }); - }); + } + }); + });