mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-14 09:12:57 -07:00
commit
3b5ff9ed34
24 changed files with 465 additions and 71 deletions
|
@ -44,6 +44,7 @@ namespace Ombi.Api.Interfaces
|
||||||
bool searchForMissingEpisodes = false);
|
bool searchForMissingEpisodes = false);
|
||||||
|
|
||||||
SystemStatus SystemStatus(string apiKey, Uri baseUrl);
|
SystemStatus SystemStatus(string apiKey, Uri baseUrl);
|
||||||
|
List<SonarrRootFolder> GetRootFolders(string apiKey, Uri baseUrl);
|
||||||
|
|
||||||
List<Series> GetSeries(string apiKey, Uri baseUrl);
|
List<Series> GetSeries(string apiKey, Uri baseUrl);
|
||||||
Series GetSeries(string seriesId, string apiKey, Uri baseUrl);
|
Series GetSeries(string seriesId, string apiKey, Uri baseUrl);
|
||||||
|
|
|
@ -101,6 +101,7 @@
|
||||||
<Compile Include="Sonarr\SonarrEpisodes.cs" />
|
<Compile Include="Sonarr\SonarrEpisodes.cs" />
|
||||||
<Compile Include="Sonarr\SonarrError.cs" />
|
<Compile Include="Sonarr\SonarrError.cs" />
|
||||||
<Compile Include="Sonarr\SonarrProfile.cs" />
|
<Compile Include="Sonarr\SonarrProfile.cs" />
|
||||||
|
<Compile Include="Sonarr\SonarrRootFolder.cs" />
|
||||||
<Compile Include="Sonarr\SonarrSearchCommand.cs" />
|
<Compile Include="Sonarr\SonarrSearchCommand.cs" />
|
||||||
<Compile Include="Sonarr\SonarrSeasonSearchResult.cs" />
|
<Compile Include="Sonarr\SonarrSeasonSearchResult.cs" />
|
||||||
<Compile Include="Sonarr\SonarrSeriesSearchResult.cs" />
|
<Compile Include="Sonarr\SonarrSeriesSearchResult.cs" />
|
||||||
|
|
35
Ombi.Api.Models/Sonarr/SonarrRootFolder.cs
Normal file
35
Ombi.Api.Models/Sonarr/SonarrRootFolder.cs
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
#region Copyright
|
||||||
|
// /************************************************************************
|
||||||
|
// Copyright (c) 2017 Jamie Rees
|
||||||
|
// File: SonarrRootFolder.cs
|
||||||
|
// Created By: Jamie Rees
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
// a copy of this software and associated documentation files (the
|
||||||
|
// "Software"), to deal in the Software without restriction, including
|
||||||
|
// without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
// permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
// the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be
|
||||||
|
// included in all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
// ************************************************************************/
|
||||||
|
#endregion
|
||||||
|
namespace Ombi.Api.Models.Sonarr
|
||||||
|
{
|
||||||
|
public class SonarrRootFolder
|
||||||
|
{
|
||||||
|
public int id { get; set; }
|
||||||
|
public string path { get; set; }
|
||||||
|
public long freespace { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -62,6 +62,22 @@ namespace Ombi.Api
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<SonarrRootFolder> GetRootFolders(string apiKey, Uri baseUrl)
|
||||||
|
{
|
||||||
|
var request = new RestRequest { Resource = "/api/rootfolder", Method = Method.GET };
|
||||||
|
|
||||||
|
request.AddHeader("X-Api-Key", apiKey);
|
||||||
|
var policy = RetryHandler.RetryAndWaitPolicy((exception, timespan) => Log.Error(exception, "Exception when calling GetRootFolders for Sonarr, Retrying {0}", timespan), new TimeSpan[] {
|
||||||
|
TimeSpan.FromSeconds (2),
|
||||||
|
TimeSpan.FromSeconds(5),
|
||||||
|
TimeSpan.FromSeconds(10)
|
||||||
|
});
|
||||||
|
|
||||||
|
var obj = policy.Execute(() => Api.ExecuteJson<List<SonarrRootFolder>>(request, baseUrl));
|
||||||
|
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
public SonarrAddSeries AddSeries(int tvdbId, string title, int qualityId, bool seasonFolders, string rootPath, int seasonCount, int[] seasons, string apiKey, Uri baseUrl, bool monitor = true, bool searchForMissingEpisodes = false)
|
public SonarrAddSeries AddSeries(int tvdbId, string title, int qualityId, bool seasonFolders, string rootPath, int seasonCount, int[] seasons, string apiKey, Uri baseUrl, bool monitor = true, bool searchForMissingEpisodes = false)
|
||||||
{
|
{
|
||||||
Log.Debug("Adding series {0}", title);
|
Log.Debug("Adding series {0}", title);
|
||||||
|
|
|
@ -47,5 +47,6 @@ namespace Ombi.Core
|
||||||
public const string WatcherQueued = nameof(WatcherQueued);
|
public const string WatcherQueued = nameof(WatcherQueued);
|
||||||
public const string GetPlexRequestSettings = nameof(GetPlexRequestSettings);
|
public const string GetPlexRequestSettings = nameof(GetPlexRequestSettings);
|
||||||
public const string LastestProductVersion = nameof(LastestProductVersion);
|
public const string LastestProductVersion = nameof(LastestProductVersion);
|
||||||
|
public const string SonarrRootFolders = nameof(SonarrRootFolders);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -33,6 +33,5 @@ namespace Ombi.Core.SettingModels
|
||||||
public string QualityProfile { get; set; }
|
public string QualityProfile { get; set; }
|
||||||
public bool SeasonFolders { get; set; }
|
public bool SeasonFolders { get; set; }
|
||||||
public string RootPath { get; set; }
|
public string RootPath { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -34,19 +34,22 @@ using Ombi.Api.Interfaces;
|
||||||
using Ombi.Api.Models.SickRage;
|
using Ombi.Api.Models.SickRage;
|
||||||
using Ombi.Api.Models.Sonarr;
|
using Ombi.Api.Models.Sonarr;
|
||||||
using Ombi.Core.SettingModels;
|
using Ombi.Core.SettingModels;
|
||||||
|
using Ombi.Helpers;
|
||||||
using Ombi.Store;
|
using Ombi.Store;
|
||||||
|
|
||||||
namespace Ombi.Core
|
namespace Ombi.Core
|
||||||
{
|
{
|
||||||
public class TvSender
|
public class TvSender
|
||||||
{
|
{
|
||||||
public TvSender(ISonarrApi sonarrApi, ISickRageApi srApi)
|
public TvSender(ISonarrApi sonarrApi, ISickRageApi srApi, ICacheProvider cache)
|
||||||
{
|
{
|
||||||
SonarrApi = sonarrApi;
|
SonarrApi = sonarrApi;
|
||||||
SickrageApi = srApi;
|
SickrageApi = srApi;
|
||||||
|
Cache = cache;
|
||||||
}
|
}
|
||||||
private ISonarrApi SonarrApi { get; }
|
private ISonarrApi SonarrApi { get; }
|
||||||
private ISickRageApi SickrageApi { get; }
|
private ISickRageApi SickrageApi { get; }
|
||||||
|
private ICacheProvider Cache { get; }
|
||||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
public async Task<SonarrAddSeries> SendToSonarr(SonarrSettings sonarrSettings, RequestedModel model)
|
public async Task<SonarrAddSeries> SendToSonarr(SonarrSettings sonarrSettings, RequestedModel model)
|
||||||
|
@ -82,6 +85,8 @@ namespace Ombi.Core
|
||||||
var latest = model.SeasonsRequested?.Equals("Latest", StringComparison.CurrentCultureIgnoreCase);
|
var latest = model.SeasonsRequested?.Equals("Latest", StringComparison.CurrentCultureIgnoreCase);
|
||||||
var specificSeasonRequest = model.SeasonList?.Any();
|
var specificSeasonRequest = model.SeasonList?.Any();
|
||||||
|
|
||||||
|
var rootFolderPath = model.RootFolderSelected <= 0 ? sonarrSettings.RootPath : await GetRootPath(model.RootFolderSelected, sonarrSettings);
|
||||||
|
|
||||||
if (episodeRequest)
|
if (episodeRequest)
|
||||||
{
|
{
|
||||||
// Does series exist?
|
// Does series exist?
|
||||||
|
@ -96,7 +101,7 @@ namespace Ombi.Core
|
||||||
|
|
||||||
// Series doesn't exist, need to add it as unmonitored.
|
// Series doesn't exist, need to add it as unmonitored.
|
||||||
var addResult = await Task.Run(() => SonarrApi.AddSeries(model.ProviderId, model.Title, qualityProfile,
|
var addResult = await Task.Run(() => SonarrApi.AddSeries(model.ProviderId, model.Title, qualityProfile,
|
||||||
sonarrSettings.SeasonFolders, sonarrSettings.RootPath, 0, new int[0], sonarrSettings.ApiKey,
|
sonarrSettings.SeasonFolders, rootFolderPath, 0, new int[0], sonarrSettings.ApiKey,
|
||||||
sonarrSettings.FullUri, false));
|
sonarrSettings.FullUri, false));
|
||||||
|
|
||||||
|
|
||||||
|
@ -125,7 +130,7 @@ namespace Ombi.Core
|
||||||
{
|
{
|
||||||
// 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.AddSeriesNew(model.ProviderId, model.Title, qualityProfile,
|
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.SeasonFolders, rootFolderPath, 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));
|
||||||
|
@ -372,5 +377,20 @@ namespace Ombi.Core
|
||||||
|
|
||||||
return selectedSeries;
|
return selectedSeries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task<string> GetRootPath(int pathId, SonarrSettings sonarrSettings)
|
||||||
|
{
|
||||||
|
var rootFoldersResult = await Cache.GetOrSetAsync(CacheKeys.SonarrRootFolders, async () =>
|
||||||
|
{
|
||||||
|
return await Task.Run(() => SonarrApi.GetRootFolders(sonarrSettings.ApiKey, sonarrSettings.FullUri));
|
||||||
|
});
|
||||||
|
|
||||||
|
foreach (var r in rootFoldersResult.Where(r => r.id == pathId))
|
||||||
|
{
|
||||||
|
return r.path;
|
||||||
|
}
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -34,19 +34,22 @@ using Ombi.Api.Interfaces;
|
||||||
using Ombi.Api.Models.SickRage;
|
using Ombi.Api.Models.SickRage;
|
||||||
using Ombi.Api.Models.Sonarr;
|
using Ombi.Api.Models.Sonarr;
|
||||||
using Ombi.Core.SettingModels;
|
using Ombi.Core.SettingModels;
|
||||||
|
using Ombi.Helpers;
|
||||||
using Ombi.Store;
|
using Ombi.Store;
|
||||||
|
|
||||||
namespace Ombi.Core
|
namespace Ombi.Core
|
||||||
{
|
{
|
||||||
public class TvSenderOld
|
public class TvSenderOld
|
||||||
{
|
{
|
||||||
public TvSenderOld(ISonarrApi sonarrApi, ISickRageApi srApi)
|
public TvSenderOld(ISonarrApi sonarrApi, ISickRageApi srApi, ICacheProvider cache)
|
||||||
{
|
{
|
||||||
SonarrApi = sonarrApi;
|
SonarrApi = sonarrApi;
|
||||||
SickrageApi = srApi;
|
SickrageApi = srApi;
|
||||||
|
Cache = cache;
|
||||||
}
|
}
|
||||||
private ISonarrApi SonarrApi { get; }
|
private ISonarrApi SonarrApi { get; }
|
||||||
private ISickRageApi SickrageApi { get; }
|
private ISickRageApi SickrageApi { get; }
|
||||||
|
private ICacheProvider Cache { get; }
|
||||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
public async Task<SonarrAddSeries> SendToSonarr(SonarrSettings sonarrSettings, RequestedModel model)
|
public async Task<SonarrAddSeries> SendToSonarr(SonarrSettings sonarrSettings, RequestedModel model)
|
||||||
|
@ -67,6 +70,8 @@ namespace Ombi.Core
|
||||||
{
|
{
|
||||||
int.TryParse(sonarrSettings.QualityProfile, out qualityProfile);
|
int.TryParse(sonarrSettings.QualityProfile, out qualityProfile);
|
||||||
}
|
}
|
||||||
|
var rootFolderPath = model.RootFolderSelected <= 0 ? sonarrSettings.RootPath : await GetRootPath(model.RootFolderSelected, sonarrSettings);
|
||||||
|
|
||||||
|
|
||||||
var series = await GetSonarrSeries(sonarrSettings, model.ProviderId);
|
var series = await GetSonarrSeries(sonarrSettings, model.ProviderId);
|
||||||
|
|
||||||
|
@ -84,7 +89,7 @@ namespace Ombi.Core
|
||||||
|
|
||||||
// Series doesn't exist, need to add it as unmonitored.
|
// Series doesn't exist, need to add it as unmonitored.
|
||||||
var addResult = await Task.Run(() => SonarrApi.AddSeries(model.ProviderId, model.Title, qualityProfile,
|
var addResult = await Task.Run(() => SonarrApi.AddSeries(model.ProviderId, model.Title, qualityProfile,
|
||||||
sonarrSettings.SeasonFolders, sonarrSettings.RootPath, 0, new int[0], sonarrSettings.ApiKey,
|
sonarrSettings.SeasonFolders, rootFolderPath, 0, new int[0], sonarrSettings.ApiKey,
|
||||||
sonarrSettings.FullUri, false));
|
sonarrSettings.FullUri, false));
|
||||||
|
|
||||||
|
|
||||||
|
@ -156,7 +161,7 @@ namespace Ombi.Core
|
||||||
|
|
||||||
|
|
||||||
var result = SonarrApi.AddSeries(model.ProviderId, model.Title, qualityProfile,
|
var result = SonarrApi.AddSeries(model.ProviderId, model.Title, qualityProfile,
|
||||||
sonarrSettings.SeasonFolders, sonarrSettings.RootPath, model.SeasonCount, model.SeasonList, sonarrSettings.ApiKey,
|
sonarrSettings.SeasonFolders, rootFolderPath, model.SeasonCount, model.SeasonList, sonarrSettings.ApiKey,
|
||||||
sonarrSettings.FullUri, true, true);
|
sonarrSettings.FullUri, true, true);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -298,5 +303,20 @@ namespace Ombi.Core
|
||||||
|
|
||||||
return selectedSeries;
|
return selectedSeries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private async Task<string> GetRootPath(int pathId, SonarrSettings sonarrSettings)
|
||||||
|
{
|
||||||
|
var rootFoldersResult = await Cache.GetOrSetAsync(CacheKeys.SonarrRootFolders, async () =>
|
||||||
|
{
|
||||||
|
return await Task.Run(() => SonarrApi.GetRootFolders(sonarrSettings.ApiKey, sonarrSettings.FullUri));
|
||||||
|
});
|
||||||
|
|
||||||
|
foreach (var r in rootFoldersResult.Where(r => r.id == pathId))
|
||||||
|
{
|
||||||
|
return r.path;
|
||||||
|
}
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -53,7 +53,7 @@ namespace Ombi.Services.Jobs
|
||||||
ISickRageApi srApi, ISettingsService<SonarrSettings> sonarrSettings, ISettingsService<SickRageSettings> srSettings,
|
ISickRageApi srApi, ISettingsService<SonarrSettings> sonarrSettings, ISettingsService<SickRageSettings> srSettings,
|
||||||
ICouchPotatoApi cpApi, ISettingsService<CouchPotatoSettings> cpsettings, IRequestService requestService,
|
ICouchPotatoApi cpApi, ISettingsService<CouchPotatoSettings> cpsettings, IRequestService requestService,
|
||||||
ISettingsService<HeadphonesSettings> hpSettings, IHeadphonesApi headphonesApi, ISettingsService<PlexRequestSettings> prSettings,
|
ISettingsService<HeadphonesSettings> hpSettings, IHeadphonesApi headphonesApi, ISettingsService<PlexRequestSettings> prSettings,
|
||||||
ISecurityExtensions security, IMovieSender movieSender)
|
ISecurityExtensions security, IMovieSender movieSender, ICacheProvider cache)
|
||||||
{
|
{
|
||||||
Record = record;
|
Record = record;
|
||||||
Repo = repo;
|
Repo = repo;
|
||||||
|
@ -71,6 +71,8 @@ namespace Ombi.Services.Jobs
|
||||||
Security = security;
|
Security = security;
|
||||||
PrSettings = prSettings.GetSettings();
|
PrSettings = prSettings.GetSettings();
|
||||||
MovieSender = movieSender;
|
MovieSender = movieSender;
|
||||||
|
|
||||||
|
Cache = cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IMovieSender MovieSender { get; }
|
private IMovieSender MovieSender { get; }
|
||||||
|
@ -78,6 +80,7 @@ namespace Ombi.Services.Jobs
|
||||||
private IJobRecord Record { get; }
|
private IJobRecord Record { get; }
|
||||||
private ISonarrApi SonarrApi { get; }
|
private ISonarrApi SonarrApi { get; }
|
||||||
private ISickRageApi SrApi { get; }
|
private ISickRageApi SrApi { get; }
|
||||||
|
private ICacheProvider Cache { get; }
|
||||||
private ICouchPotatoApi CpApi { get; }
|
private ICouchPotatoApi CpApi { get; }
|
||||||
private IHeadphonesApi HpApi { get; }
|
private IHeadphonesApi HpApi { get; }
|
||||||
private IRequestService RequestService { get; }
|
private IRequestService RequestService { get; }
|
||||||
|
@ -163,7 +166,7 @@ namespace Ombi.Services.Jobs
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
var sender = new TvSenderOld(SonarrApi, SrApi);
|
var sender = new TvSenderOld(SonarrApi, SrApi, Cache);
|
||||||
if (sonarr.Enabled)
|
if (sonarr.Enabled)
|
||||||
{
|
{
|
||||||
var task = sender.SendToSonarr(sonarr, tvModel, sonarr.QualityProfile);
|
var task = sender.SendToSonarr(sonarr, tvModel, sonarr.QualityProfile);
|
||||||
|
|
|
@ -79,6 +79,7 @@ namespace Ombi.Services.Jobs
|
||||||
|
|
||||||
public void CheckAndUpdateAll()
|
public void CheckAndUpdateAll()
|
||||||
{
|
{
|
||||||
|
|
||||||
var plexSettings = Plex.GetSettings();
|
var plexSettings = Plex.GetSettings();
|
||||||
|
|
||||||
if (!ValidateSettings(plexSettings))
|
if (!ValidateSettings(plexSettings))
|
||||||
|
|
|
@ -46,6 +46,13 @@ namespace Ombi.Store
|
||||||
public List<EpisodesModel> Episodes { get; set; }
|
public List<EpisodesModel> Episodes { get; set; }
|
||||||
public bool Denied { get; set; }
|
public bool Denied { get; set; }
|
||||||
public string DeniedReason { get; set; }
|
public string DeniedReason { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// For TV Shows with a custom root folder
|
||||||
|
/// </summary>
|
||||||
|
/// <value>
|
||||||
|
/// The root folder selected.
|
||||||
|
/// </value>
|
||||||
|
public int RootFolderSelected { get; set; }
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public List<string> AllUsers
|
public List<string> AllUsers
|
||||||
|
|
|
@ -35,6 +35,7 @@ using Ombi.Api.Interfaces;
|
||||||
using Ombi.Api.Models.Sonarr;
|
using Ombi.Api.Models.Sonarr;
|
||||||
using Ombi.Core;
|
using Ombi.Core;
|
||||||
using Ombi.Core.SettingModels;
|
using Ombi.Core.SettingModels;
|
||||||
|
using Ombi.Helpers;
|
||||||
using Ombi.Store;
|
using Ombi.Store;
|
||||||
using Ploeh.AutoFixture;
|
using Ploeh.AutoFixture;
|
||||||
|
|
||||||
|
@ -49,6 +50,7 @@ namespace Ombi.UI.Tests
|
||||||
|
|
||||||
private TvSender Sender { get; set; }
|
private TvSender Sender { get; set; }
|
||||||
private Fixture F { get; set; }
|
private Fixture F { get; set; }
|
||||||
|
private Mock<ICacheProvider> Cache { get; set; }
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public void Setup()
|
public void Setup()
|
||||||
|
@ -56,7 +58,8 @@ namespace Ombi.UI.Tests
|
||||||
F = new Fixture();
|
F = new Fixture();
|
||||||
SonarrMock = new Mock<ISonarrApi>();
|
SonarrMock = new Mock<ISonarrApi>();
|
||||||
SickrageMock = new Mock<ISickRageApi>();
|
SickrageMock = new Mock<ISickRageApi>();
|
||||||
Sender = new TvSender(SonarrMock.Object, SickrageMock.Object);
|
Cache = new Mock<ICacheProvider>();
|
||||||
|
Sender = new TvSender(SonarrMock.Object, SickrageMock.Object, Cache.Object);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -66,7 +69,7 @@ namespace Ombi.UI.Tests
|
||||||
var seriesResult = new SonarrAddSeries() { title = "ABC"};
|
var seriesResult = new SonarrAddSeries() { title = "ABC"};
|
||||||
SonarrMock.Setup(x => x.GetSeries(It.IsAny<string>(), It.IsAny<Uri>())).Returns(F.Build<Series>().With(x => x.tvdbId, 1).With(x => x.title, "ABC").CreateMany().ToList());
|
SonarrMock.Setup(x => x.GetSeries(It.IsAny<string>(), It.IsAny<Uri>())).Returns(F.Build<Series>().With(x => x.tvdbId, 1).With(x => x.title, "ABC").CreateMany().ToList());
|
||||||
|
|
||||||
Sender = new TvSender(SonarrMock.Object, SickrageMock.Object);
|
Sender = new TvSender(SonarrMock.Object, SickrageMock.Object, Cache.Object);
|
||||||
|
|
||||||
var request = new RequestedModel {SeasonsRequested = "All", ProviderId = 1, Title = "ABC"};
|
var request = new RequestedModel {SeasonsRequested = "All", ProviderId = 1, Title = "ABC"};
|
||||||
|
|
||||||
|
@ -116,7 +119,7 @@ namespace Ombi.UI.Tests
|
||||||
SonarrMock.Setup(x => x.GetEpisodes(It.IsAny<string>(), It.IsAny<string>(),
|
SonarrMock.Setup(x => x.GetEpisodes(It.IsAny<string>(), It.IsAny<string>(),
|
||||||
It.IsAny<Uri>())).Returns(F.CreateMany<SonarrEpisodes>());
|
It.IsAny<Uri>())).Returns(F.CreateMany<SonarrEpisodes>());
|
||||||
|
|
||||||
Sender = new TvSender(SonarrMock.Object, SickrageMock.Object);
|
Sender = new TvSender(SonarrMock.Object, SickrageMock.Object, Cache.Object);
|
||||||
var episodes = new List<EpisodesModel>
|
var episodes = new List<EpisodesModel>
|
||||||
{
|
{
|
||||||
new EpisodesModel
|
new EpisodesModel
|
||||||
|
|
|
@ -559,6 +559,25 @@ $(document).on("click", ".approve-with-quality", function (e) {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Change root folder
|
||||||
|
$(document).on("click", ".change-root-folder", function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
var $this = $(this);
|
||||||
|
var $button = $this.parents('.btn-split').children('.change').first();
|
||||||
|
var rootFolderId = e.target.id
|
||||||
|
var $form = $this.parents('form').first();
|
||||||
|
|
||||||
|
if ($button.text() === " Loading...") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
loadingButton($button.attr('id'), "success");
|
||||||
|
|
||||||
|
changeRootFolder($form, rootFolderId, function () {
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
// Change Availability
|
// Change Availability
|
||||||
$(document).on("click", ".change", function (e) {
|
$(document).on("click", ".change", function (e) {
|
||||||
|
@ -638,6 +657,37 @@ function approveRequest($form, qualityId, successCallback) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function changeRootFolder($form, rootFolderId, successCallback) {
|
||||||
|
|
||||||
|
var formData = $form.serialize();
|
||||||
|
if (rootFolderId) formData += ("&rootFolderId=" + rootFolderId);
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
type: $form.prop('method'),
|
||||||
|
url: $form.prop('action'),
|
||||||
|
data: formData,
|
||||||
|
dataType: "json",
|
||||||
|
success: function (response) {
|
||||||
|
|
||||||
|
if (checkJsonResponse(response)) {
|
||||||
|
if (response.message) {
|
||||||
|
generateNotify(response.message, "success");
|
||||||
|
} else {
|
||||||
|
generateNotify("Success! Changed Root Path.", "success");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (successCallback) {
|
||||||
|
successCallback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function (e) {
|
||||||
|
console.log(e);
|
||||||
|
generateNotify("Something went wrong!", "danger");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function denyRequest($form, successCallback) {
|
function denyRequest($form, successCallback) {
|
||||||
|
|
||||||
var formData = $form.serialize();
|
var formData = $form.serialize();
|
||||||
|
@ -808,6 +858,9 @@ function buildRequestContext(result, type) {
|
||||||
musicBrainzId: result.musicBrainzId,
|
musicBrainzId: result.musicBrainzId,
|
||||||
denied: result.denied,
|
denied: result.denied,
|
||||||
deniedReason: result.deniedReason,
|
deniedReason: result.deniedReason,
|
||||||
|
hasRootFolders: result.hasRootFolders,
|
||||||
|
rootFolders: result.rootFolders,
|
||||||
|
currentRootPath : result.currentRootPath
|
||||||
};
|
};
|
||||||
|
|
||||||
return context;
|
return context;
|
||||||
|
|
|
@ -58,5 +58,8 @@ namespace Ombi.UI.Models
|
||||||
public Store.EpisodesModel[] Episodes { get; set; }
|
public Store.EpisodesModel[] Episodes { get; set; }
|
||||||
public bool Denied { get; set; }
|
public bool Denied { get; set; }
|
||||||
public string DeniedReason { get; set; }
|
public string DeniedReason { get; set; }
|
||||||
|
public RootFolderModel[] RootFolders { get; set; }
|
||||||
|
public bool HasRootFolders { get; set; }
|
||||||
|
public string CurrentRootPath { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
36
Ombi.UI/Models/RootFolderModel.cs
Normal file
36
Ombi.UI/Models/RootFolderModel.cs
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
#region Copyright
|
||||||
|
// /************************************************************************
|
||||||
|
// Copyright (c) 2017 Jamie Rees
|
||||||
|
// File: RootFolderModel.cs
|
||||||
|
// Created By: Jamie Rees
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
// a copy of this software and associated documentation files (the
|
||||||
|
// "Software"), to deal in the Software without restriction, including
|
||||||
|
// without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
// permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
// the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be
|
||||||
|
// included in all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
// ************************************************************************/
|
||||||
|
#endregion
|
||||||
|
namespace Ombi.UI.Models
|
||||||
|
{
|
||||||
|
|
||||||
|
public class RootFolderModel
|
||||||
|
{
|
||||||
|
public string Id { get; set; }
|
||||||
|
public string Path { get; set; }
|
||||||
|
public long FreeSpace { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -54,7 +54,7 @@ namespace Ombi.UI.Modules.Admin
|
||||||
{
|
{
|
||||||
public IntegrationModule(ISettingsService<PlexRequestSettings> settingsService, ISettingsService<WatcherSettings> watcher,
|
public IntegrationModule(ISettingsService<PlexRequestSettings> settingsService, ISettingsService<WatcherSettings> watcher,
|
||||||
ISettingsService<CouchPotatoSettings> cp,ISecurityExtensions security, IAnalytics a, ISettingsService<RadarrSettings> radarrSettings,
|
ISettingsService<CouchPotatoSettings> cp,ISecurityExtensions security, IAnalytics a, ISettingsService<RadarrSettings> radarrSettings,
|
||||||
ICacheProvider cache, IRadarrApi radarrApi) : base("admin", settingsService, security)
|
ICacheProvider cache, IRadarrApi radarrApi, ISonarrApi sonarrApi) : base("admin", settingsService, security)
|
||||||
{
|
{
|
||||||
|
|
||||||
WatcherSettings = watcher;
|
WatcherSettings = watcher;
|
||||||
|
@ -63,9 +63,13 @@ namespace Ombi.UI.Modules.Admin
|
||||||
Cache = cache;
|
Cache = cache;
|
||||||
RadarrApi = radarrApi;
|
RadarrApi = radarrApi;
|
||||||
RadarrSettings = radarrSettings;
|
RadarrSettings = radarrSettings;
|
||||||
|
SonarrApi = sonarrApi;
|
||||||
|
|
||||||
Before += (ctx) => Security.AdminLoginRedirect(Permissions.Administrator, ctx);
|
Before += (ctx) => Security.AdminLoginRedirect(Permissions.Administrator, ctx);
|
||||||
|
|
||||||
|
|
||||||
|
Post["/sonarrrootfolders"] = _ => GetSonarrRootFolders();
|
||||||
|
|
||||||
Get["/watcher", true] = async (x, ct) => await Watcher();
|
Get["/watcher", true] = async (x, ct) => await Watcher();
|
||||||
Post["/watcher", true] = async (x, ct) => await SaveWatcher();
|
Post["/watcher", true] = async (x, ct) => await SaveWatcher();
|
||||||
|
|
||||||
|
@ -82,6 +86,7 @@ namespace Ombi.UI.Modules.Admin
|
||||||
private IRadarrApi RadarrApi { get; }
|
private IRadarrApi RadarrApi { get; }
|
||||||
private ICacheProvider Cache { get; }
|
private ICacheProvider Cache { get; }
|
||||||
private IAnalytics Analytics { get; }
|
private IAnalytics Analytics { get; }
|
||||||
|
private ISonarrApi SonarrApi { get; }
|
||||||
|
|
||||||
private async Task<Negotiator> Watcher()
|
private async Task<Negotiator> Watcher()
|
||||||
{
|
{
|
||||||
|
@ -182,5 +187,20 @@ namespace Ombi.UI.Modules.Admin
|
||||||
return Response.AsJson(profiles);
|
return Response.AsJson(profiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Response GetSonarrRootFolders()
|
||||||
|
{
|
||||||
|
var settings = this.Bind<SonarrSettings>();
|
||||||
|
|
||||||
|
var rootFolders = SonarrApi.GetRootFolders(settings.ApiKey, settings.FullUri);
|
||||||
|
|
||||||
|
// set the cache
|
||||||
|
if (rootFolders != null)
|
||||||
|
{
|
||||||
|
Cache.Set(CacheKeys.SonarrRootFolders, rootFolders);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Response.AsJson(rootFolders);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -50,7 +50,7 @@ namespace Ombi.UI.Modules
|
||||||
public ApprovalModule(IRequestService service, ISonarrApi sonarrApi,
|
public ApprovalModule(IRequestService service, ISonarrApi sonarrApi,
|
||||||
ISettingsService<SonarrSettings> sonarrSettings, ISickRageApi srApi, ISettingsService<SickRageSettings> srSettings,
|
ISettingsService<SonarrSettings> sonarrSettings, ISickRageApi srApi, ISettingsService<SickRageSettings> srSettings,
|
||||||
ISettingsService<HeadphonesSettings> hpSettings, IHeadphonesApi hpApi, ISettingsService<PlexRequestSettings> pr, ITransientFaultQueue faultQueue
|
ISettingsService<HeadphonesSettings> hpSettings, IHeadphonesApi hpApi, ISettingsService<PlexRequestSettings> pr, ITransientFaultQueue faultQueue
|
||||||
, ISecurityExtensions security, IMovieSender movieSender) : base("approval", pr, security)
|
, ISecurityExtensions security, IMovieSender movieSender, ICacheProvider cache) : base("approval", pr, security)
|
||||||
{
|
{
|
||||||
|
|
||||||
Before += (ctx) => Security.AdminLoginRedirect(ctx, Permissions.Administrator,Permissions.ManageRequests);
|
Before += (ctx) => Security.AdminLoginRedirect(ctx, Permissions.Administrator,Permissions.ManageRequests);
|
||||||
|
@ -64,6 +64,7 @@ namespace Ombi.UI.Modules
|
||||||
HeadphoneApi = hpApi;
|
HeadphoneApi = hpApi;
|
||||||
FaultQueue = faultQueue;
|
FaultQueue = faultQueue;
|
||||||
MovieSender = movieSender;
|
MovieSender = movieSender;
|
||||||
|
Cache = cache;
|
||||||
|
|
||||||
Post["/approve", true] = async (x, ct) => await Approve((int)Request.Form.requestid, (string)Request.Form.qualityId);
|
Post["/approve", true] = async (x, ct) => await Approve((int)Request.Form.requestid, (string)Request.Form.qualityId);
|
||||||
Post["/deny", true] = async (x, ct) => await DenyRequest((int)Request.Form.requestid, (string)Request.Form.reason);
|
Post["/deny", true] = async (x, ct) => await DenyRequest((int)Request.Form.requestid, (string)Request.Form.reason);
|
||||||
|
@ -86,6 +87,7 @@ namespace Ombi.UI.Modules
|
||||||
private ISickRageApi SickRageApi { get; }
|
private ISickRageApi SickRageApi { get; }
|
||||||
private IHeadphonesApi HeadphoneApi { get; }
|
private IHeadphonesApi HeadphoneApi { get; }
|
||||||
private ITransientFaultQueue FaultQueue { get; }
|
private ITransientFaultQueue FaultQueue { get; }
|
||||||
|
private ICacheProvider Cache { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Approves the specified request identifier.
|
/// Approves the specified request identifier.
|
||||||
|
@ -120,7 +122,7 @@ namespace Ombi.UI.Modules
|
||||||
|
|
||||||
private async Task<Response> RequestTvAndUpdateStatus(RequestedModel request, string qualityId)
|
private async Task<Response> RequestTvAndUpdateStatus(RequestedModel request, string qualityId)
|
||||||
{
|
{
|
||||||
var sender = new TvSenderOld(SonarrApi, SickRageApi); // TODO put back
|
var sender = new TvSenderOld(SonarrApi, SickRageApi, Cache); // TODO put back
|
||||||
|
|
||||||
var sonarrSettings = await SonarrSettings.GetSettingsAsync();
|
var sonarrSettings = await SonarrSettings.GetSettingsAsync();
|
||||||
if (sonarrSettings.Enabled)
|
if (sonarrSettings.Enabled)
|
||||||
|
@ -435,7 +437,7 @@ namespace Ombi.UI.Modules
|
||||||
}
|
}
|
||||||
if (r.Type == RequestType.TvShow)
|
if (r.Type == RequestType.TvShow)
|
||||||
{
|
{
|
||||||
var sender = new TvSenderOld(SonarrApi, SickRageApi); // TODO put back
|
var sender = new TvSenderOld(SonarrApi, SickRageApi, Cache); // TODO put back
|
||||||
var sr = await SickRageSettings.GetSettingsAsync();
|
var sr = await SickRageSettings.GetSettingsAsync();
|
||||||
var sonarr = await SonarrSettings.GetSettingsAsync();
|
var sonarr = await SonarrSettings.GetSettingsAsync();
|
||||||
if (sr.Enabled)
|
if (sr.Enabled)
|
||||||
|
|
|
@ -96,6 +96,8 @@ namespace Ombi.UI.Modules
|
||||||
|
|
||||||
Post["/changeavailability", true] = async (x, ct) => await ChangeRequestAvailability((int)Request.Form.Id, (bool)Request.Form.Available);
|
Post["/changeavailability", true] = async (x, ct) => await ChangeRequestAvailability((int)Request.Form.Id, (bool)Request.Form.Available);
|
||||||
|
|
||||||
|
Post["/changeRootFolder", true] = async (x, ct) => await ChangeRootFolder((int) Request.Form.requestId, (int) Request.Form.rootFolderId);
|
||||||
|
|
||||||
Get["/UpdateFilters", true] = async (x, ct) => await GetFilterAndSortSettings();
|
Get["/UpdateFilters", true] = async (x, ct) => await GetFilterAndSortSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,7 +187,7 @@ namespace Ombi.UI.Modules
|
||||||
IssueId = movie.IssueId,
|
IssueId = movie.IssueId,
|
||||||
Denied = movie.Denied,
|
Denied = movie.Denied,
|
||||||
DeniedReason = movie.DeniedReason,
|
DeniedReason = movie.DeniedReason,
|
||||||
Qualities = qualities.ToArray()
|
Qualities = qualities.ToArray(),
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
return Response.AsJson(viewModel);
|
return Response.AsJson(viewModel);
|
||||||
|
@ -193,31 +195,38 @@ namespace Ombi.UI.Modules
|
||||||
|
|
||||||
private async Task<Response> GetTvShows()
|
private async Task<Response> GetTvShows()
|
||||||
{
|
{
|
||||||
var settingsTask = PrSettings.GetSettingsAsync();
|
|
||||||
|
|
||||||
var requests = await Service.GetAllAsync();
|
var requests = await Service.GetAllAsync();
|
||||||
requests = requests.Where(x => x.Type == RequestType.TvShow);
|
requests = requests.Where(x => x.Type == RequestType.TvShow);
|
||||||
|
|
||||||
var dbTv = requests;
|
var dbTv = requests;
|
||||||
var settings = await settingsTask;
|
|
||||||
if (Security.HasPermissions(User, Permissions.UsersCanViewOnlyOwnRequests) && !IsAdmin)
|
if (Security.HasPermissions(User, Permissions.UsersCanViewOnlyOwnRequests) && !IsAdmin)
|
||||||
{
|
{
|
||||||
dbTv = dbTv.Where(x => x.UserHasRequested(Username)).ToList();
|
dbTv = dbTv.Where(x => x.UserHasRequested(Username)).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
IEnumerable<QualityModel> qualities = new List<QualityModel>();
|
IEnumerable<QualityModel> qualities = new List<QualityModel>();
|
||||||
|
IEnumerable<RootFolderModel> rootFolders = new List<RootFolderModel>();
|
||||||
|
|
||||||
|
var sonarrSettings = await SonarrSettings.GetSettingsAsync();
|
||||||
if (IsAdmin)
|
if (IsAdmin)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var sonarrSettings = await SonarrSettings.GetSettingsAsync();
|
|
||||||
if (sonarrSettings.Enabled)
|
if (sonarrSettings.Enabled)
|
||||||
{
|
{
|
||||||
var result = Cache.GetOrSetAsync(CacheKeys.SonarrQualityProfiles, async () =>
|
var result = await Cache.GetOrSetAsync(CacheKeys.SonarrQualityProfiles, async () =>
|
||||||
{
|
{
|
||||||
return await Task.Run(() => SonarrApi.GetProfiles(sonarrSettings.ApiKey, sonarrSettings.FullUri));
|
return await Task.Run(() => SonarrApi.GetProfiles(sonarrSettings.ApiKey, sonarrSettings.FullUri));
|
||||||
});
|
});
|
||||||
qualities = result.Result.Select(x => new QualityModel { Id = x.id.ToString(), Name = x.name }).ToList();
|
qualities = result.Select(x => new QualityModel { Id = x.id.ToString(), Name = x.name }).ToList();
|
||||||
|
|
||||||
|
|
||||||
|
var rootFoldersResult =await Cache.GetOrSetAsync(CacheKeys.SonarrRootFolders, async () =>
|
||||||
|
{
|
||||||
|
return await Task.Run(() => SonarrApi.GetRootFolders(sonarrSettings.ApiKey, sonarrSettings.FullUri));
|
||||||
|
});
|
||||||
|
|
||||||
|
rootFolders = rootFoldersResult.Select(x => new RootFolderModel { Id = x.id.ToString(), Path = x.path, FreeSpace = x.freespace}).ToList();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -264,11 +273,28 @@ namespace Ombi.UI.Modules
|
||||||
TvSeriesRequestType = tv.SeasonsRequested,
|
TvSeriesRequestType = tv.SeasonsRequested,
|
||||||
Qualities = qualities.ToArray(),
|
Qualities = qualities.ToArray(),
|
||||||
Episodes = tv.Episodes.ToArray(),
|
Episodes = tv.Episodes.ToArray(),
|
||||||
|
RootFolders = rootFolders.ToArray(),
|
||||||
|
HasRootFolders = rootFolders.Any(),
|
||||||
|
CurrentRootPath = GetRootPath(tv.RootFolderSelected, sonarrSettings).Result
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
return Response.AsJson(viewModel);
|
return Response.AsJson(viewModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task<string> GetRootPath(int pathId, SonarrSettings sonarrSettings)
|
||||||
|
{
|
||||||
|
var rootFoldersResult = await Cache.GetOrSetAsync(CacheKeys.SonarrRootFolders, async () =>
|
||||||
|
{
|
||||||
|
return await Task.Run(() => SonarrApi.GetRootFolders(sonarrSettings.ApiKey, sonarrSettings.FullUri));
|
||||||
|
});
|
||||||
|
|
||||||
|
foreach (var r in rootFoldersResult.Where(r => r.id == pathId))
|
||||||
|
{
|
||||||
|
return r.path;
|
||||||
|
}
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
private async Task<Response> GetAlbumRequests()
|
private async Task<Response> GetAlbumRequests()
|
||||||
{
|
{
|
||||||
var settings = PrSettings.GetSettings();
|
var settings = PrSettings.GetSettings();
|
||||||
|
@ -432,5 +458,34 @@ namespace Ombi.UI.Modules
|
||||||
|
|
||||||
return Response.AsJson(vm);
|
return Response.AsJson(vm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task<Response> ChangeRootFolder(int id, int rootFolderId)
|
||||||
|
{
|
||||||
|
// Get all root folders
|
||||||
|
var settings = await SonarrSettings.GetSettingsAsync();
|
||||||
|
var rootFolders = SonarrApi.GetRootFolders(settings.ApiKey, settings.FullUri);
|
||||||
|
|
||||||
|
// Get Request
|
||||||
|
var allRequests = await Service.GetAllAsync();
|
||||||
|
var request = allRequests.FirstOrDefault(x => x.Id == id);
|
||||||
|
|
||||||
|
if (request == null)
|
||||||
|
{
|
||||||
|
return Response.AsJson(new JsonResponseModel {Result = false});
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var folder in rootFolders)
|
||||||
|
{
|
||||||
|
if (folder.id.Equals(rootFolderId))
|
||||||
|
{
|
||||||
|
request.RootFolderSelected = folder.id;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await Service.UpdateRequestAsync(request);
|
||||||
|
|
||||||
|
return Response.AsJson(new JsonResponseModel {Result = true});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1107,7 +1107,7 @@ namespace Ombi.UI.Modules
|
||||||
{
|
{
|
||||||
model.Approved = true;
|
model.Approved = true;
|
||||||
var s = await sonarrSettings;
|
var s = await sonarrSettings;
|
||||||
var sender = new TvSenderOld(SonarrApi, SickrageApi); // TODO put back
|
var sender = new TvSenderOld(SonarrApi, SickrageApi, Cache); // TODO put back
|
||||||
if (s.Enabled)
|
if (s.Enabled)
|
||||||
{
|
{
|
||||||
var result = await sender.SendToSonarr(s, model);
|
var result = await sender.SendToSonarr(s, model);
|
||||||
|
|
|
@ -250,6 +250,7 @@
|
||||||
<Compile Include="Models\MovieSearchType.cs" />
|
<Compile Include="Models\MovieSearchType.cs" />
|
||||||
<Compile Include="Models\QualityModel.cs" />
|
<Compile Include="Models\QualityModel.cs" />
|
||||||
<Compile Include="Models\Requests\RequestsIndexViewModel.cs" />
|
<Compile Include="Models\Requests\RequestsIndexViewModel.cs" />
|
||||||
|
<Compile Include="Models\RootFolderModel.cs" />
|
||||||
<Compile Include="Models\ScheduledJobsViewModel.cs" />
|
<Compile Include="Models\ScheduledJobsViewModel.cs" />
|
||||||
<Compile Include="Models\SearchViewModel.cs" />
|
<Compile Include="Models\SearchViewModel.cs" />
|
||||||
<Compile Include="Models\SearchMusicViewModel.cs" />
|
<Compile Include="Models\SearchMusicViewModel.cs" />
|
||||||
|
@ -797,7 +798,7 @@
|
||||||
<Content Include="Views\Admin\DiscordNotification.cshtml">
|
<Content Include="Views\Admin\DiscordNotification.cshtml">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
<Content Include="Views\Admin\Radarr.cshtml">
|
<Content Include="Views\Integration\Radarr.cshtml">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
<None Include="Web.Debug.config">
|
<None Include="Web.Debug.config">
|
||||||
|
|
|
@ -80,12 +80,27 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
<div>
|
||||||
|
<button type="submit" id="getRootFolders" class="btn btn-primary-outline">Get Root Folders <div id="getRootFolderSpinner" /></button>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="selectRootFolder" class="control-label">Default Root Folders</label>
|
||||||
|
<div id="rootFolders">
|
||||||
|
<select class="form-control form-control-custom" id="selectRootFolder"></select>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@*<div class="form-group">
|
||||||
<label for="RootPath" class="control-label">Root save directory for TV shows</label>
|
<label for="RootPath" class="control-label">Root save directory for TV shows</label>
|
||||||
<div>
|
<div>
|
||||||
<input type="text" class="form-control form-control-custom " placeholder="C:\Media\Tv" id="RootPath" name="RootPath" value="@Model.RootPath">
|
<input type="text" class="form-control form-control-custom " placeholder="C:\Media\Tv" id="RootPath" name="RootPath" value="@Model.RootPath">
|
||||||
<label>Enter the root folder where tv shows are saved. For example <strong>C:\Media\TV</strong>.</label>
|
<label>Enter the root folder where tv shows are saved. For example <strong>C:\Media\TV</strong>.</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>*@
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="checkbox">
|
<div class="checkbox">
|
||||||
|
@ -161,6 +176,40 @@
|
||||||
</text>
|
</text>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@if (!string.IsNullOrEmpty(Model.RootPath))
|
||||||
|
{
|
||||||
|
<text>
|
||||||
|
|
||||||
|
console.log('Hit root folders..');
|
||||||
|
|
||||||
|
var rootFolderSelected = @Model.RootPath;
|
||||||
|
if (!rootFolderSelected) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var $form = $("#mainForm");
|
||||||
|
$.ajax({
|
||||||
|
type: $form.prop("method"),
|
||||||
|
data: $form.serialize(),
|
||||||
|
url: "sonarrrootfolders",
|
||||||
|
dataType: "json",
|
||||||
|
success: function(response) {
|
||||||
|
response.forEach(function(result) {
|
||||||
|
$('#selectedRootFolder').html("");
|
||||||
|
if (result.id == rootFolderSelected) {
|
||||||
|
$("#selectRootFolder").append("<option selected='selected' value='" + result.id + "'>" + result.path + "</option>");
|
||||||
|
} else {
|
||||||
|
$("#selectRootFolder").append("<option value='" + result.id + "'>" + result.path + "</option>");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
error: function(e) {
|
||||||
|
console.log(e);
|
||||||
|
generateNotify("Something went wrong!", "danger");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</text>
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$('#save').click(function(e) {
|
$('#save').click(function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
@ -170,11 +219,12 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var qualityProfile = $("#profiles option:selected").val();
|
var qualityProfile = $("#profiles option:selected").val();
|
||||||
|
var rootFolder = $("#rootFolders 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 + "&rootPath=" + rootFolder;
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: $form.prop("method"),
|
type: $form.prop("method"),
|
||||||
|
@ -234,6 +284,46 @@
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#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");
|
||||||
|
$('#getRootFolderSpinner').attr("class", "fa fa-times");
|
||||||
|
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");
|
||||||
|
$('#getRootFolderSpinner').attr("class", "fa fa-times");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var $form = $("#mainForm");
|
||||||
|
$.ajax({
|
||||||
|
type: $form.prop("method"),
|
||||||
|
data: $form.serialize(),
|
||||||
|
url: "sonarrrootfolders",
|
||||||
|
dataType: "json",
|
||||||
|
success: function (response) {
|
||||||
|
response.forEach(function (result) {
|
||||||
|
$('#getRootFolderSpinner').attr("class", "fa fa-check");
|
||||||
|
$("#selectRootFolder").append("<option value='" + result.id + "'>" + result.path + "</option>");
|
||||||
|
});
|
||||||
|
},
|
||||||
|
error: function (e) {
|
||||||
|
console.log(e);
|
||||||
|
$('#getRootFolderSpinner').attr("class", "fa fa-times");
|
||||||
|
generateNotify("Something went wrong!", "danger");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
var base = '@Html.GetBaseUrl()';
|
var base = '@Html.GetBaseUrl()';
|
||||||
$('#testSonarr').click(function (e) {
|
$('#testSonarr').click(function (e) {
|
||||||
|
|
||||||
|
|
|
@ -244,6 +244,11 @@
|
||||||
<div>@UI.Requests_RequestedBy: {{requestedUsers}}</div>
|
<div>@UI.Requests_RequestedBy: {{requestedUsers}}</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
<div>@UI.Requests_RequestedDate: {{requestedDate}}</div>
|
<div>@UI.Requests_RequestedDate: {{requestedDate}}</div>
|
||||||
|
{{#if admin}}
|
||||||
|
{{#if currentRootPath}}
|
||||||
|
<div>Root Path: {{currentRootPath}}</div>
|
||||||
|
{{/if}}
|
||||||
|
{{/if}}
|
||||||
<div>
|
<div>
|
||||||
{{#if_eq issueId 0}}
|
{{#if_eq issueId 0}}
|
||||||
@*Nothing*@
|
@*Nothing*@
|
||||||
|
@ -275,6 +280,28 @@
|
||||||
<button id="{{requestId}}" custom-button="{{requestId}}" style="text-align: right" class="btn btn-sm btn-success-outline approve" type="submit"><i class="fa fa-plus"></i> @UI.Common_Approve</button>
|
<button id="{{requestId}}" custom-button="{{requestId}}" style="text-align: right" class="btn btn-sm btn-success-outline approve" type="submit"><i class="fa fa-plus"></i> @UI.Common_Approve</button>
|
||||||
{{/if_eq}}
|
{{/if_eq}}
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|
||||||
|
<form method="POST" action="@formAction/requests/changeRootFolder" id="changeFolder{{requestId}}">
|
||||||
|
<input name="requestId" type="text" value="{{requestId}}" hidden="hidden" />
|
||||||
|
{{#if_eq hasRootFolders true}}
|
||||||
|
<div class="btn-group btn-split">
|
||||||
|
<button type="button" class="btn btn-sm btn-success-outline approve" id="{{requestId}}" custom-button="{{requestId}}">@*<i class="fa fa-plus"></i>*@ Change Root Folder</button>
|
||||||
|
<button type="button" class="btn btn-success-outline dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||||
|
<span class="caret"></span>
|
||||||
|
<span class="sr-only">@UI.Requests_ToggleDropdown</span>
|
||||||
|
</button>
|
||||||
|
<ul class="dropdown-menu">
|
||||||
|
{{#each rootFolders}}
|
||||||
|
<li><a href="#" class="change-root-folder" id="{{id}}">{{path}}</a></li>
|
||||||
|
{{/each}}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
{{/if_eq}}
|
||||||
|
</form>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{{#unless denied}}
|
{{#unless denied}}
|
||||||
<form method="POST" action="@formAction/approval/deny" id="deny{{requestId}}">
|
<form method="POST" action="@formAction/approval/deny" id="deny{{requestId}}">
|
||||||
<input name="requestId" type="text" value="{{requestId}}" hidden="hidden" />
|
<input name="requestId" type="text" value="{{requestId}}" hidden="hidden" />
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue