Added support for a new TV and Movie provider. DogNZB

pull/1614/head
tidusjar 7 years ago
parent c00a0d1f2f
commit d6b3c7ac2c

@ -0,0 +1,84 @@
using System;
using System.IO;
using System.Net.Http;
using System.Threading.Tasks;
using System.Xml.Serialization;
using Microsoft.Extensions.Logging;
using Ombi.Api.DogNzb.Models;
namespace Ombi.Api.DogNzb
{
public class DogNzbApi : IDogNzbApi
{
public DogNzbApi(IApi api, ILogger<DogNzbApi> log)
{
_api = api;
_log = log;
}
private readonly IApi _api;
private readonly ILogger<DogNzbApi> _log;
private const string BaseUrl = "https://api.dognzb.cr/";
public async Task<DogNzbMovies> ListMovies(string apiKey)
{
var request = new Request("watchlist", BaseUrl, HttpMethod.Get, ContentType.Xml);
request.AddQueryString("t", "list");
request.AddQueryString("imdbid", string.Empty);
request.AddQueryString("apikey", apiKey);
return await _api.Request<DogNzbMovies>(request);
}
public async Task<DogNzbTvShows> ListTvShows(string apiKey)
{
var request = new Request("watchlist", BaseUrl, HttpMethod.Get, ContentType.Xml);
request.AddQueryString("t", "list");
request.AddQueryString("tvdbid", string.Empty);
request.AddQueryString("apikey", apiKey);
return await _api.Request<DogNzbTvShows>(request);
}
public async Task<DogNzbAddResult> AddTvShow(string apiKey, string tvdbId)
{
var request = new Request("watchlist", BaseUrl, HttpMethod.Get, ContentType.Xml);
request.AddQueryString("t", "add");
request.AddQueryString("tvdbid", tvdbId);
request.AddQueryString("apikey", apiKey);
var result = await _api.RequestContent(request);
try
{
XmlSerializer serializer = new XmlSerializer(typeof(DogNzbAddResult));
StringReader reader = new StringReader(result);
return (DogNzbAddResult)serializer.Deserialize(reader);
}
catch (Exception e)
{
_log.LogError(e, "Error when adding TV Shows to DogNzb");
XmlSerializer serializer = new XmlSerializer(typeof(DogNzbError));
StringReader reader = new StringReader(result);
var error = (DogNzbError)serializer.Deserialize(reader);
return new DogNzbAddResult
{
Failure = true,
ErrorMessage = error.Description
};
}
}
public async Task<DogNzbMovieAddResult> AddMovie(string apiKey, string imdbid)
{
var request = new Request("watchlist", BaseUrl, HttpMethod.Get, ContentType.Xml);
request.AddQueryString("t", "add");
request.AddQueryString("imdbid", imdbid);
request.AddQueryString("apikey", apiKey);
return await _api.Request<DogNzbMovieAddResult>(request);
}
}
}

@ -0,0 +1,13 @@
using System.Threading.Tasks;
using Ombi.Api.DogNzb.Models;
namespace Ombi.Api.DogNzb
{
public interface IDogNzbApi
{
Task<DogNzbMovieAddResult> AddMovie(string apiKey, string imdbid);
Task<DogNzbAddResult> AddTvShow(string apiKey, string tvdbId);
Task<DogNzbMovies> ListMovies(string apiKey);
Task<DogNzbTvShows> ListTvShows(string apiKey);
}
}

@ -0,0 +1,45 @@
#region Copyright
// /************************************************************************
// Copyright (c) 2017 Jamie Rees
// File: DogNzbAddResult.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
using System.Xml.Serialization;
namespace Ombi.Api.DogNzb.Models
{
[XmlRoot(ElementName = "uuid")]
public class DogNzbAddResult
{
[XmlAttribute(AttributeName = "code")]
public string Code { get; set; }
[XmlAttribute(AttributeName = "description")]
public string Description { get; set; }
// We set the below
public bool Failure { get; set; }
public string ErrorMessage { get; set; }
}
}

@ -0,0 +1,41 @@
#region Copyright
// /************************************************************************
// Copyright (c) 2017 Jamie Rees
// File: DogNzbError.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
using System.Xml.Serialization;
namespace Ombi.Api.DogNzb.Models
{
[XmlRoot(ElementName = "error")]
public class DogNzbError
{
[XmlAttribute(AttributeName = "code")]
public string Code { get; set; }
[XmlAttribute(AttributeName = "description")]
public string Description { get; set; }
}
}

@ -0,0 +1,55 @@
#region Copyright
// /************************************************************************
// Copyright (c) 2017 Jamie Rees
// File: DogNzbMovieAddResult.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
using System.Xml.Serialization;
namespace Ombi.Api.DogNzb.Models
{
[XmlRoot(ElementName = "channel")]
public class MovieAddResultChannel
{
[XmlElement(ElementName = "title")]
public string Title { get; set; }
[XmlElement(ElementName = "link")]
public string Link { get; set; }
[XmlElement(ElementName = "description")]
public string Description { get; set; }
[XmlElement(ElementName = "language")]
public string Language { get; set; }
}
[XmlRoot(ElementName = "rss")]
public class DogNzbMovieAddResult
{
[XmlElement(ElementName = "channel")]
public MovieAddResultChannel Channel { get; set; }
[XmlAttribute(AttributeName = "version")]
public string Version { get; set; }
[XmlAttribute(AttributeName = "atom", Namespace = "http://www.w3.org/2000/xmlns/")]
public string Atom { get; set; }
}
}

@ -0,0 +1,93 @@
#region Copyright
// /************************************************************************
// Copyright (c) 2017 Jamie Rees
// File: DogNzbMovies.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
using System.Collections.Generic;
using System.Xml.Serialization;
namespace Ombi.Api.DogNzb.Models
{
[XmlRoot(ElementName = "response", Namespace = "http://www.newznab.com/DTD/2010/feeds/attributes/")]
public class Response
{
[XmlAttribute(AttributeName = "total")]
public string Total { get; set; }
}
[XmlRoot(ElementName = "item")]
public class Item
{
[XmlElement(ElementName = "title")]
public string Title { get; set; }
[XmlElement(ElementName = "imdbid")]
public string Imdbid { get; set; }
[XmlElement(ElementName = "plot")]
public string Plot { get; set; }
[XmlElement(ElementName = "actors")]
public string Actors { get; set; }
[XmlElement(ElementName = "genres")]
public string Genres { get; set; }
[XmlElement(ElementName = "year")]
public string Year { get; set; }
[XmlElement(ElementName = "runtime")]
public string Runtime { get; set; }
[XmlElement(ElementName = "certification")]
public string Certification { get; set; }
[XmlElement(ElementName = "trailer")]
public string Trailer { get; set; }
[XmlElement(ElementName = "poster")]
public string Poster { get; set; }
}
[XmlRoot(ElementName = "channel")]
public class Channel
{
[XmlElement(ElementName = "title")]
public string Title { get; set; }
[XmlElement(ElementName = "description")]
public string Description { get; set; }
[XmlElement(ElementName = "uuid")]
public string Uuid { get; set; }
[XmlElement(ElementName = "response", Namespace = "http://www.newznab.com/DTD/2010/feeds/attributes/")]
public Response Response { get; set; }
[XmlElement(ElementName = "item")]
public List<Item> Item { get; set; }
}
[XmlRoot(ElementName = "rss")]
public class DogNzbMovies
{
[XmlElement(ElementName = "channel")]
public Channel Channel { get; set; }
[XmlAttribute(AttributeName = "version")]
public string Version { get; set; }
[XmlAttribute(AttributeName = "atom", Namespace = "http://www.w3.org/2000/xmlns/")]
public string Atom { get; set; }
[XmlAttribute(AttributeName = "newznab", Namespace = "http://www.w3.org/2000/xmlns/")]
public string Newznab { get; set; }
}
}

@ -0,0 +1,84 @@
#region Copyright
// /************************************************************************
// Copyright (c) 2017 Jamie Rees
// File: DogNzbTvShows.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
using System.Xml.Serialization;
namespace Ombi.Api.DogNzb.Models
{
[XmlRoot(ElementName = "item")]
public class TvItem
{
[XmlElement(ElementName = "title")]
public string Title { get; set; }
[XmlElement(ElementName = "tvdbid")]
public string Tvdbid { get; set; }
[XmlElement(ElementName = "plot")]
public string Plot { get; set; }
[XmlElement(ElementName = "actors")]
public string Actors { get; set; }
[XmlElement(ElementName = "genres")]
public string Genres { get; set; }
[XmlElement(ElementName = "network")]
public string Network { get; set; }
[XmlElement(ElementName = "status")]
public string Status { get; set; }
[XmlElement(ElementName = "trailer")]
public string Trailer { get; set; }
[XmlElement(ElementName = "poster")]
public string Poster { get; set; }
}
[XmlRoot(ElementName = "channel")]
public class TvChannel
{
[XmlElement(ElementName = "title")]
public string Title { get; set; }
[XmlElement(ElementName = "description")]
public string Description { get; set; }
[XmlElement(ElementName = "uuid")]
public string Uuid { get; set; }
[XmlElement(ElementName = "response", Namespace = "http://www.newznab.com/DTD/2010/feeds/attributes/")]
public Response Response { get; set; }
[XmlElement(ElementName = "item")]
public TvItem Item { get; set; }
}
[XmlRoot(ElementName = "rss")]
public class DogNzbTvShows
{
[XmlElement(ElementName = "channel")]
public TvChannel Channel { get; set; }
[XmlAttribute(AttributeName = "version")]
public string Version { get; set; }
[XmlAttribute(AttributeName = "atom", Namespace = "http://www.w3.org/2000/xmlns/")]
public string Atom { get; set; }
[XmlAttribute(AttributeName = "newznab", Namespace = "http://www.w3.org/2000/xmlns/")]
public string Newznab { get; set; }
}
}

@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Ombi.Api\Ombi.Api.csproj" />
</ItemGroup>
</Project>

@ -87,7 +87,7 @@ namespace Ombi.Core.Engine
if (requestModel.Approved) // The rules have auto approved this
{
var result = await Sender.Send(requestModel);
if (result.Success && result.MovieSent)
if (result.Success && result.Sent)
{
return await AddMovieRequest(requestModel, fullMovieName);
}
@ -153,7 +153,7 @@ namespace Ombi.Core.Engine
if (request.Approved)
{
var result = await Sender.Send(request);
if (result.Success && result.MovieSent)
if (result.Success && result.Sent)
{
return new RequestEngineResult
{

@ -16,6 +16,7 @@ using Ombi.Core.Engine.Interfaces;
using Ombi.Core.Helpers;
using Ombi.Core.Rule;
using Ombi.Core.Rule.Interfaces;
using Ombi.Core.Senders;
using Ombi.Store.Entities.Requests;
using Ombi.Store.Repository;
@ -188,7 +189,7 @@ namespace Ombi.Core.Engine
{
await Audit.Record(AuditType.Approved, AuditArea.TvRequest, $"Approved Request {request.Title}", Username);
// Autosend
await TvSender.SendToSonarr(request);
await TvSender.Send(request);
}
return new RequestEngineResult
{
@ -292,7 +293,15 @@ namespace Ombi.Core.Engine
if (model.Approved)
{
// Autosend
await TvSender.SendToSonarr(model);
var result = await TvSender.Send(model);
if (result.Success)
{
return new RequestEngineResult { RequestAdded = true };
}
return new RequestEngineResult
{
ErrorMessage = result.Message
};
}
return new RequestEngineResult { RequestAdded = true };

@ -21,6 +21,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Ombi.Api.DogNzb\Ombi.Api.DogNzb.csproj" />
<ProjectReference Include="..\Ombi.Api.Plex\Ombi.Api.Plex.csproj" />
<ProjectReference Include="..\Ombi.Api.Sonarr\Ombi.Api.Sonarr.csproj" />
<ProjectReference Include="..\Ombi.Api.Trakt\Ombi.Api.Trakt.csproj" />

@ -1,10 +1,11 @@
using System.Threading.Tasks;
using Ombi.Core.Senders;
using Ombi.Store.Entities.Requests;
namespace Ombi.Core
{
public interface IMovieSender
{
Task<MovieSenderResult> Send(MovieRequests model);
Task<SenderResult> Send(MovieRequests model);
}
}

@ -1,12 +1,10 @@
using System.Threading.Tasks;
using Ombi.Api.Sonarr.Models;
using Ombi.Core.Settings.Models.External;
using Ombi.Store.Entities.Requests;
namespace Ombi.Core
namespace Ombi.Core.Senders
{
public interface ITvSender
{
Task<NewSeries> SendToSonarr(ChildRequests model, string qualityId = null);
Task<SenderResult> Send(ChildRequests model);
}
}

@ -1,32 +1,54 @@
using System.Linq;
using Ombi.Core.Settings;
using Ombi.Settings.Settings.Models.External;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Ombi.Api.DogNzb.Models;
using Ombi.Api.Radarr;
using Ombi.Core.Settings;
using Ombi.Helpers;
using Ombi.Settings.Settings.Models.External;
using Ombi.Store.Entities.Requests;
using Ombi.Api.DogNzb;
namespace Ombi.Core
namespace Ombi.Core.Senders
{
public class MovieSender : IMovieSender
{
public MovieSender(ISettingsService<RadarrSettings> radarrSettings, IRadarrApi api, ILogger<MovieSender> log)
public MovieSender(ISettingsService<RadarrSettings> radarrSettings, IRadarrApi api, ILogger<MovieSender> log,
ISettingsService<DogNzbSettings> dogSettings, IDogNzbApi dogApi)
{
RadarrSettings = radarrSettings;
RadarrApi = api;
Log = log;
DogNzbSettings = dogSettings;
DogNzbApi = dogApi;
}
private ISettingsService<RadarrSettings> RadarrSettings { get; }
private IRadarrApi RadarrApi { get; }
private ILogger<MovieSender> Log { get; }
private IDogNzbApi DogNzbApi { get; }
private ISettingsService<DogNzbSettings> DogNzbSettings { get; }
public async Task<MovieSenderResult> Send(MovieRequests model)
public async Task<SenderResult> Send(MovieRequests model)
{
//var cpSettings = await CouchPotatoSettings.GetSettingsAsync();
//var watcherSettings = await WatcherSettings.GetSettingsAsync();
var radarrSettings = await RadarrSettings.GetSettingsAsync();
if (radarrSettings.Enabled)
{
return await SendToRadarr(model, radarrSettings);
}
var dogSettings = await DogNzbSettings.GetSettingsAsync();
if (dogSettings.Enabled)
{
await SendToDogNzb(model,dogSettings);
return new SenderResult
{
Success = true,
Sent = true,
};
}
//if (cpSettings.Enabled)
//{
@ -38,19 +60,21 @@ namespace Ombi.Core
// return SendToWatcher(model, watcherSettings);
//}
if (radarrSettings.Enabled)
{
return await SendToRadarr(model, radarrSettings);
}
return new MovieSenderResult
return new SenderResult
{
Success = true,
MovieSent = false,
Sent = false,
};
}
private async Task<MovieSenderResult> SendToRadarr(MovieRequests model, RadarrSettings settings)
private async Task<DogNzbMovieAddResult> SendToDogNzb(FullBaseRequest model, DogNzbSettings settings)
{
var id = model.ImdbId;
return await DogNzbApi.AddMovie(settings.ApiKey, id);
}
private async Task<SenderResult> SendToRadarr(MovieRequests model, RadarrSettings settings)
{
var qualityToUse = int.Parse(settings.DefaultQualityProfile);
if (model.QualityOverride > 0)
@ -64,13 +88,13 @@ namespace Ombi.Core
if (!string.IsNullOrEmpty(result.Error?.message))
{
Log.LogError(LoggingEvents.RadarrCacher,result.Error.message);
return new MovieSenderResult { Success = false, Message = result.Error.message, MovieSent = false };
return new SenderResult { Success = false, Message = result.Error.message, Sent = false };
}
if (!string.IsNullOrEmpty(result.title))
{
return new MovieSenderResult { Success = true, MovieSent = false };
return new SenderResult { Success = true, Sent = false };
}
return new MovieSenderResult { Success = true, MovieSent = false };
return new SenderResult { Success = true, Sent = false };
}
private async Task<string> RadarrRootPath(int overrideId, RadarrSettings settings)

@ -1,9 +0,0 @@
namespace Ombi.Core
{
public class MovieSenderResult
{
public bool Success { get; set; }
public string Message { get; set; }
public bool MovieSent { get; set; }
}
}

@ -0,0 +1,9 @@
namespace Ombi.Core.Senders
{
public class SenderResult
{
public bool Success { get; set; }
public string Message { get; set; }
public bool Sent { get; set; }
}
}

@ -3,10 +3,11 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Ombi.Api.DogNzb;
using Ombi.Api.DogNzb.Models;
using Ombi.Api.Sonarr;
using Ombi.Api.Sonarr.Models;
using Ombi.Core.Settings;
using Ombi.Core.Settings.Models.External;
using Ombi.Helpers;
using Ombi.Settings.Settings.Models.External;
using Ombi.Store.Entities.Requests;
@ -15,16 +16,65 @@ namespace Ombi.Core.Senders
{
public class TvSender : ITvSender
{
public TvSender(ISonarrApi sonarrApi, ILogger<TvSender> log, ISettingsService<SonarrSettings> settings)
public TvSender(ISonarrApi sonarrApi, ILogger<TvSender> log, ISettingsService<SonarrSettings> sonarrSettings,
ISettingsService<DogNzbSettings> dog, IDogNzbApi dogApi)
{
SonarrApi = sonarrApi;
Logger = log;
Settings = settings;
SonarrSettings = sonarrSettings;
DogNzbSettings = dog;
DogNzbApi = dogApi;
}
private ISonarrApi SonarrApi { get; }
private IDogNzbApi DogNzbApi { get; }
private ILogger<TvSender> Logger { get; }
private ISettingsService<SonarrSettings> Settings { get; }
private ISettingsService<SonarrSettings> SonarrSettings { get; }
private ISettingsService<DogNzbSettings> DogNzbSettings { get; }
public async Task<SenderResult> Send(ChildRequests model)
{
var sonarr = await SonarrSettings.GetSettingsAsync();
if (sonarr.Enabled)
{
var result = await SendToSonarr(model);
if (result != null)
{
return new SenderResult
{
Sent = true,
Success = true
};
}
}
var dog = await DogNzbSettings.GetSettingsAsync();
if (dog.Enabled)
{
var result = await SendToDogNzb(model, dog);
if (!result.Failure)
{
return new SenderResult
{
Sent = true,
Success = true
};
}
return new SenderResult
{
Message = result.ErrorMessage
};
}
return new SenderResult
{
Success = true
};
}
private async Task<DogNzbAddResult> SendToDogNzb(ChildRequests model, DogNzbSettings settings)
{
var id = model.ParentRequest.TvDbId;
return await DogNzbApi.AddTvShow(settings.ApiKey, id.ToString());
}
/// <summary>
/// Send the request to Sonarr to process
@ -35,7 +85,7 @@ namespace Ombi.Core.Senders
/// <returns></returns>
public async Task<NewSeries> SendToSonarr(ChildRequests model, string qualityId = null)
{
var s = await Settings.GetSettingsAsync();
var s = await SonarrSettings.GetSettingsAsync();
if (!s.Enabled)
{
return null;

@ -1,12 +1,7 @@
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Security.Principal;
using Hangfire;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.Extensions.DependencyInjection;
using Ombi.Api.Discord;
@ -34,6 +29,7 @@ using Ombi.Notifications.Agents;
using Ombi.Schedule.Jobs.Radarr;
using Ombi.Api;
using Ombi.Api.CouchPotato;
using Ombi.Api.DogNzb;
using Ombi.Api.FanartTv;
using Ombi.Api.Mattermost;
using Ombi.Api.Pushbullet;
@ -99,6 +95,7 @@ namespace Ombi.DependencyInjection
services.AddTransient<IPushoverApi, PushoverApi>();
services.AddTransient<IMattermostApi, MattermostApi>();
services.AddTransient<ICouchPotatoApi, CouchPotatoApi>();
services.AddTransient<IDogNzbApi, DogNzbApi>();
}
public static void RegisterStore(this IServiceCollection services) {

@ -17,6 +17,7 @@
<ItemGroup>
<ProjectReference Include="..\Ombi.Api.CouchPotato\Ombi.Api.CouchPotato.csproj" />
<ProjectReference Include="..\Ombi.Api.Discord\Ombi.Api.Discord.csproj" />
<ProjectReference Include="..\Ombi.Api.DogNzb\Ombi.Api.DogNzb.csproj" />
<ProjectReference Include="..\Ombi.Api.Emby\Ombi.Api.Emby.csproj" />
<ProjectReference Include="..\Ombi.Api.FanartTv\Ombi.Api.FanartTv.csproj" />
<ProjectReference Include="..\Ombi.Api.Mattermost\Ombi.Api.Mattermost.csproj" />

@ -0,0 +1,10 @@
namespace Ombi.Settings.Settings.Models.External
{
public class DogNzbSettings : Settings
{
public bool Enabled { get; set; }
public string ApiKey { get; set; }
public bool Movies { get; set; }
public bool TvShows { get; set; }
}
}

@ -80,7 +80,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ombi.Api.Pushover", "Ombi.A
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ombi.Schedule.Tests", "Ombi.Schedule.Tests\Ombi.Schedule.Tests.csproj", "{BDD8B924-016E-4CDA-9FFA-50B0A34BCD3C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ombi.Api.CouchPotato", "Ombi.Api.CouchPotato\Ombi.Api.CouchPotato.csproj", "{87D7897D-7C73-4856-A0AA-FF5948F4EA86}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ombi.Api.CouchPotato", "Ombi.Api.CouchPotato\Ombi.Api.CouchPotato.csproj", "{87D7897D-7C73-4856-A0AA-FF5948F4EA86}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ombi.Api.DogNzb", "Ombi.Api.DogNzb\Ombi.Api.DogNzb.csproj", "{4F3BF03A-6AAC-4960-A2CD-1EAD7273115E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -208,6 +210,10 @@ Global
{87D7897D-7C73-4856-A0AA-FF5948F4EA86}.Debug|Any CPU.Build.0 = Debug|Any CPU
{87D7897D-7C73-4856-A0AA-FF5948F4EA86}.Release|Any CPU.ActiveCfg = Release|Any CPU
{87D7897D-7C73-4856-A0AA-FF5948F4EA86}.Release|Any CPU.Build.0 = Release|Any CPU
{4F3BF03A-6AAC-4960-A2CD-1EAD7273115E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4F3BF03A-6AAC-4960-A2CD-1EAD7273115E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4F3BF03A-6AAC-4960-A2CD-1EAD7273115E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4F3BF03A-6AAC-4960-A2CD-1EAD7273115E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -237,6 +243,7 @@ Global
{CA55DD4F-4EFF-4906-A848-35FCC7BD5654} = {9293CA11-360A-4C20-A674-B9E794431BF5}
{BDD8B924-016E-4CDA-9FFA-50B0A34BCD3C} = {6F42AB98-9196-44C4-B888-D5E409F415A1}
{87D7897D-7C73-4856-A0AA-FF5948F4EA86} = {9293CA11-360A-4C20-A674-B9E794431BF5}
{4F3BF03A-6AAC-4960-A2CD-1EAD7273115E} = {9293CA11-360A-4C20-A674-B9E794431BF5}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {192E9BF8-00B4-45E4-BCCC-4C215725C869}

@ -127,3 +127,10 @@ export interface ICouchPotatoSettings extends IExternalSettings {
username: string;
password: string;
}
export interface IDogNzbSettings extends ISettings {
enabled: boolean;
apiKey: string;
movies: boolean;
tvShows: boolean;
}

@ -10,6 +10,7 @@ import {
ICouchPotatoSettings,
ICustomizationSettings,
IDiscordNotifcationSettings,
IDogNzbSettings,
IEmailNotificationSettings,
IEmbySettings,
ILandingPageSettings,
@ -198,12 +199,22 @@ export class SettingsService extends ServiceAuthHelpers {
}
public getCouchPotatoSettings(): Observable<ICouchPotatoSettings> {
return this.httpAuth.get(`${this.url}/UserManagement`).map(this.extractData).catch(this.handleError);
return this.httpAuth.get(`${this.url}/CouchPotato`).map(this.extractData).catch(this.handleError);
}
public saveCouchPotatoSettings(settings: ICouchPotatoSettings): Observable<boolean> {
return this.httpAuth
.post(`${this.url}/UserManagement`, JSON.stringify(settings), { headers: this.headers })
.post(`${this.url}/CouchPotato`, JSON.stringify(settings), { headers: this.headers })
.map(this.extractData).catch(this.handleError);
}
public getDogNzbSettings(): Observable<IDogNzbSettings> {
return this.httpAuth.get(`${this.url}/DogNzb`).map(this.extractData).catch(this.handleError);
}
public saveDogNzbSettings(settings: IDogNzbSettings): Observable<boolean> {
return this.httpAuth
.post(`${this.url}/DogNzb`, JSON.stringify(settings), { headers: this.headers })
.map(this.extractData).catch(this.handleError);
}
}

@ -0,0 +1,54 @@
<settings-menu>
</settings-menu>
<wiki [url]="'https://github.com/tidusjar/Ombi/wiki/DogNzb-Settings'"></wiki>
<div *ngIf="form">
<fieldset>
<legend>DogNzb Settings</legend>
<form novalidate [formGroup]="form" (ngSubmit)="onSubmit(form)" style="padding-top:5%;">
<div class="col-md-6">
<div class="form-group">
<div class="checkbox">
<input type="checkbox" id="enable" formControlName="enabled" ng-checked="form.enabled">
<label for="enable">Enable</label>
</div>
</div>
<div class="form-group">
<label for="ApiKey" class="control-label">API Key</label>
<input type="text" class="form-control form-control-custom" [ngClass]="{'form-error': form.get('apiKey').hasError('required')}" id="ApiKey" name="ApiKey" formControlName="apiKey">
<small *ngIf="form.get('apiKey').hasError('required')" class="error-text">The API Key is required</small>
</div>
<div class="form-group">
<div>
<button type="submit" [disabled]="form.invalid" class="btn btn-primary-outline ">Submit</button>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<div class="checkbox">
<input type="checkbox" id="movies" formControlName="movies" ng-checked="form.movies">
<label for="movies">Enable for Movies</label>
</div>
</div>
<div class="form-group">
<div class="checkbox">
<input type="checkbox" id="tvShows" formControlName="tvShows" ng-checked="form.tvShows">
<label for="tvShows">Enable for Tv Shows</label>
</div>
</div>
</div>
</form>
</fieldset>
</div>

@ -0,0 +1,46 @@
import { Component, OnInit } from "@angular/core";
import { FormBuilder, FormGroup, Validators } from "@angular/forms";
import { NotificationService, SettingsService } from "../../services";
@Component({
templateUrl: "./dognzb.component.html",
})
export class DogNzbComponent implements OnInit {
public form: FormGroup;
public profilesRunning: boolean;
constructor(private readonly settingsService: SettingsService,
private readonly fb: FormBuilder,
private readonly notificationService: NotificationService) { }
public ngOnInit() {
this.settingsService.getDogNzbSettings().subscribe(x => {
this.form = this.fb.group({
enabled: [x.enabled],
apiKey: [x.apiKey, Validators.required],
movies: [x.movies],
tvShows: [x.tvShows],
});
});
}
public onSubmit(form: FormGroup) {
if (form.invalid) {
this.notificationService.error("Validation", "Please check your entered values");
return;
}
const settings = form.value;
this.settingsService.saveDogNzbSettings(settings).subscribe(x => {
if (x) {
this.notificationService.success("Settings Saved", "Successfully saved the DogNzb settings");
} else {
this.notificationService.success("Settings Saved", "There was an error when saving the DogNzb settings");
}
});
}
}

@ -14,6 +14,7 @@ import { PipeModule } from "../pipes/pipe.module";
import { AboutComponent } from "./about/about.component";
import { CouchPotatoComponent } from "./couchpotato/couchpotato.component";
import { CustomizationComponent } from "./customization/customization.component";
import { DogNzbComponent } from "./dognzb/dognzb.component";
import { EmbyComponent } from "./emby/emby.component";
import { LandingPageComponent } from "./landingpage/landingpage.component";
import { DiscordComponent } from "./notifications/discord.component";
@ -53,6 +54,7 @@ const routes: Routes = [
{ path: "Settings/UserManagement", component: UserManagementComponent, canActivate: [AuthGuard] },
{ path: "Settings/Update", component: UpdateComponent, canActivate: [AuthGuard] },
{ path: "Settings/CouchPotato", component: CouchPotatoComponent, canActivate: [AuthGuard] },
{ path: "Settings/DogNzb", component: DogNzbComponent, canActivate: [AuthGuard] },
];
@NgModule({
@ -94,6 +96,7 @@ const routes: Routes = [
AboutComponent,
WikiComponent,
CouchPotatoComponent,
DogNzbComponent,
],
exports: [
RouterModule,

@ -29,6 +29,7 @@
</a>
<ul class="dropdown-menu">
<li [routerLinkActive]="['active']"><a [routerLink]="['/Settings/Sonarr']">Sonarr</a></li>
<li [routerLinkActive]="['active']"><a [routerLink]="['/Settings/DogNzb']">DogNzb</a></li>
<li [routerLinkActive]="['active']"><a>More Coming Soon...</a></li>
<!--<li [routerLinkActive]="['active']"><a [routerLink]="['/Settings/SickRage']">SickRage</a></li>-->
</ul>
@ -40,6 +41,7 @@
</a>
<ul class="dropdown-menu">
<li [routerLinkActive]="['active']"><a [routerLink]="['/Settings/CouchPotato']">CouchPotato (NOT YET READY)</a></li>
<li [routerLinkActive]="['active']"><a [routerLink]="['/Settings/DogNzb']">DogNzb</a></li>
<li [routerLinkActive]="['active']"><a [routerLink]="['/Settings/Radarr']">Radarr</a></li>
<!--<li [routerLinkActive]="['active']"><a [routerLink]="['/Settings/Watcher']">Watcher</a></li>-->
<li [routerLinkActive]="['active']"><a>More Coming Soon...</a></li>

@ -364,6 +364,27 @@ namespace Ombi.Controllers
return await Save(settings);
}
/// <summary>
/// Gets the DogNzbSettings Settings.
/// </summary>
/// <returns></returns>
[HttpGet("DogNzb")]
public async Task<DogNzbSettings> DogNzbSettings()
{
return await Get<DogNzbSettings>();
}
/// <summary>
/// Save the DogNzbSettings settings.
/// </summary>
/// <param name="settings">The settings.</param>
/// <returns></returns>
[HttpPost("DogNzb")]
public async Task<bool> DogNzbSettings([FromBody]DogNzbSettings settings)
{
return await Save(settings);
}
/// <summary>
/// Saves the email notification settings.
/// </summary>

Loading…
Cancel
Save