diff --git a/src/NzbDrone.Core/AutoImport.derp/AutoImportBase.cs b/src/NzbDrone.Core/AutoImport.derp/AutoImportBase.cs deleted file mode 100644 index 9dc51714c..000000000 --- a/src/NzbDrone.Core/AutoImport.derp/AutoImportBase.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -using System.Collections.Generic; -using FluentValidation.Results; -using NzbDrone.Core.ThingiProvider; -using NzbDrone.Core.Tv; - -namespace NzbDrone.Core.AutoImport -{ - public abstract class AutoImportBase : IAutoImport where TSettings : IProviderConfig, new() - { - public abstract string Name { get; } - - public Type ConfigContract => typeof(TSettings); - - public virtual ProviderMessage Message => null; - - public IEnumerable DefaultDefinitions => new List(); - - public ProviderDefinition Definition { get; set; } - public abstract ValidationResult Test(); - - public abstract string Link { get; } - - protected TSettings Settings => (TSettings)Definition.Settings; - - public override string ToString() - { - return GetType().Name; - } - - public abstract bool Enabled { get; } - - public virtual object RequestAction(string action, IDictionary query) { return null; } - } -} diff --git a/src/NzbDrone.Core/AutoImport.derp/AutoImportDefinition.cs b/src/NzbDrone.Core/AutoImport.derp/AutoImportDefinition.cs deleted file mode 100644 index f1d53e72e..000000000 --- a/src/NzbDrone.Core/AutoImport.derp/AutoImportDefinition.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System.Collections.Generic; -using NzbDrone.Core.ThingiProvider; - -namespace NzbDrone.Core.AutoImport -{ - public class AutoImportDefinition : ProviderDefinition - { - public AutoImportDefinition() - { - Tags = new HashSet(); - } - - public bool Enabled { get; set; } - public HashSet Tags { get; set; } - - public override bool Enable => Enabled; - } -} diff --git a/src/NzbDrone.Core/AutoImport.derp/AutoImportRepository.cs b/src/NzbDrone.Core/AutoImport.derp/AutoImportRepository.cs deleted file mode 100644 index 398bcaf99..000000000 --- a/src/NzbDrone.Core/AutoImport.derp/AutoImportRepository.cs +++ /dev/null @@ -1,20 +0,0 @@ -using NzbDrone.Core.Datastore; -using NzbDrone.Core.Messaging.Events; -using NzbDrone.Core.ThingiProvider; - - -namespace NzbDrone.Core.AutoImport -{ - public interface IAutoImportRepository : IProviderRepository - { - - } - - public class AutoImportRepository : ProviderRepository, IAutoImportRepository - { - public AutoImportRepository(IMainDatabase database, IEventAggregator eventAggregator) - : base(database, eventAggregator) - { - } - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core/AutoImport.derp/IAutoImport.cs b/src/NzbDrone.Core/AutoImport.derp/IAutoImport.cs deleted file mode 100644 index 5597ddee8..000000000 --- a/src/NzbDrone.Core/AutoImport.derp/IAutoImport.cs +++ /dev/null @@ -1,12 +0,0 @@ -using NzbDrone.Core.ThingiProvider; - -namespace NzbDrone.Core.AutoImport -{ - public interface IAutoImport : IProvider - { - string Link { get; } - bool Enabled { get; } - - // void OnGrab(GrabMessage grabMessage); - } -} diff --git a/src/NzbDrone.Core/AutoImport.derp/IMDbWatchList/IMDbWatchList.cs b/src/NzbDrone.Core/AutoImport.derp/IMDbWatchList/IMDbWatchList.cs deleted file mode 100644 index d060e1362..000000000 --- a/src/NzbDrone.Core/AutoImport.derp/IMDbWatchList/IMDbWatchList.cs +++ /dev/null @@ -1,43 +0,0 @@ - -using System.Collections.Generic; -using FluentValidation.Results; -using NzbDrone.Common.Extensions; -using NzbDrone.Core.Tv; -using NzbDrone.Core.AutoImport; -using NzbDrone.Core.AutoImport.IMDbWatchList; -using System; - -namespace NzbDrone.Core.AutoImpoter.IMDbWatchList -{ - public class IMDbWatchList : AutoImportBase - { - public override bool Enabled - { - get - { - throw new NotImplementedException(); - } - } - - //private readonly INotifyMyAndroidProxy _proxy; - - //public NotifyMyAndroid(INotifyMyAndroidProxy proxy) - //{ - // _proxy = proxy; - //} - - public override string Link => "http://rss.imdb.com/"; - - public override string Name => "IMDb Public Watchlist"; - - - public override ValidationResult Test() - { - var failures = new List(); - - // failures.AddIfNotNull(_proxy.Test(Settings)); - - return new ValidationResult(failures); - } - } -} diff --git a/src/NzbDrone.Core/Datastore/Migration/119_create_netimport_table.cs b/src/NzbDrone.Core/Datastore/Migration/119_create_netimport_table.cs new file mode 100644 index 000000000..7784ad1c4 --- /dev/null +++ b/src/NzbDrone.Core/Datastore/Migration/119_create_netimport_table.cs @@ -0,0 +1,18 @@ +using FluentMigrator; +using NzbDrone.Core.Datastore.Migration.Framework; + +namespace NzbDrone.Core.Datastore.Migration +{ + [Migration(119)] + public class create_netimport_table : NzbDroneMigrationBase + { + protected override void MainDbUpgrade() + { + Create.TableForModel("NetImport") + .WithColumn("Enabled").AsBoolean() + .WithColumn("Name").AsString().Unique() + .WithColumn("Implementation").AsString() + .WithColumn("Settings").AsString().Nullable(); + } + } +} diff --git a/src/NzbDrone.Core/NetImport/Exceptions/NetImportException.cs b/src/NzbDrone.Core/NetImport/Exceptions/NetImportException.cs new file mode 100644 index 000000000..d3444d991 --- /dev/null +++ b/src/NzbDrone.Core/NetImport/Exceptions/NetImportException.cs @@ -0,0 +1,23 @@ +using NzbDrone.Common.Exceptions; + +namespace NzbDrone.Core.NetImport.Exceptions +{ + public class NetImportException : NzbDroneException + { + private readonly NetImportResponse _netImportResponse; + + public NetImportException(NetImportResponse response, string message, params object[] args) + : base(message, args) + { + _netImportResponse = response; + } + + public NetImportException(NetImportResponse response, string message) + : base(message) + { + _netImportResponse = response; + } + + public NetImportResponse Response => _netImportResponse; + } +} diff --git a/src/NzbDrone.Core/NetImport/HttpNetImportBase.cs b/src/NzbDrone.Core/NetImport/HttpNetImportBase.cs new file mode 100644 index 000000000..9d5582a9c --- /dev/null +++ b/src/NzbDrone.Core/NetImport/HttpNetImportBase.cs @@ -0,0 +1,56 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using FluentValidation.Results; +using NLog; +using NzbDrone.Common.Extensions; +using NzbDrone.Common.Http; +using NzbDrone.Core.Configuration; +using NzbDrone.Core.Http.CloudFlare; +using NzbDrone.Core.Indexers.Exceptions; +using NzbDrone.Core.IndexerSearch.Definitions; +using NzbDrone.Core.Parser; +using NzbDrone.Core.Parser.Model; +using NzbDrone.Core.ThingiProvider; +using NzbDrone.Core.Tv; + +namespace NzbDrone.Core.NetImport +{ + public abstract class HttpNetImportBase : NetImportBase + where TSettings : IProviderConfig, new() + { + protected const int MaxNumResultsPerQuery = 1000; + + protected readonly IHttpClient _httpClient; + + public override bool Enabled => true; + + public virtual TimeSpan RateLimit => TimeSpan.FromSeconds(2); + + public abstract INetImportRequestGenerator GetRequestGenerator(); + public abstract IParseNetImportResponse GetParser(); + + public HttpNetImportBase(IHttpClient httpClient, IConfigService configService, IParsingService parsingService, Logger logger) + : base(configService, parsingService, logger) + { + _httpClient = httpClient; + } + + public override IList Fetch() + { + return new List(); + } + + protected override void Test(List failures) + { + throw new NotImplementedException(); + } + + protected virtual ValidationFailure TestConnection() + { + throw new NotImplementedException(); + } + } + +} diff --git a/src/NzbDrone.Core/NetImport/IMDbWatchList/IMDbWatchList.cs b/src/NzbDrone.Core/NetImport/IMDbWatchList/IMDbWatchList.cs new file mode 100644 index 000000000..d97fb99c2 --- /dev/null +++ b/src/NzbDrone.Core/NetImport/IMDbWatchList/IMDbWatchList.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using FluentValidation.Results; +using NLog; +using NzbDrone.Common.Http; +using NzbDrone.Core.Configuration; +using NzbDrone.Core.Indexers; +using NzbDrone.Core.Indexers.PassThePopcorn; +using NzbDrone.Core.Parser; +using NzbDrone.Core.Tv; + +namespace NzbDrone.Core.NetImport.IMDbWatchList +{ + public class IMDbWatchList : HttpNetImportBase + { + public override string Name => "IMDbWatchList"; + public override string Link => "http://rss.imdb.com/list/"; + public override bool Enabled => true; + + + public IMDbWatchList(IHttpClient httpClient, IConfigService configService, IParsingService parsingService, Logger logger) + : base(httpClient, configService, parsingService, logger) + { } + + public override INetImportRequestGenerator GetRequestGenerator() + { + return new IMDbWatchListRequestGenerator() { Settings = Settings }; + } + + public override IParseNetImportResponse GetParser() + { + return new IMDbWatchListParser(Settings); + } + } +} diff --git a/src/NzbDrone.Core/NetImport/IMDbWatchList/IMDbWatchListAPI.cs b/src/NzbDrone.Core/NetImport/IMDbWatchList/IMDbWatchListAPI.cs new file mode 100644 index 000000000..73570c897 --- /dev/null +++ b/src/NzbDrone.Core/NetImport/IMDbWatchList/IMDbWatchListAPI.cs @@ -0,0 +1,40 @@ +using System.Collections.Generic; +using System.Xml.Serialization; + +namespace NzbDrone.Core.NetImport.IMDbWatchList +{ + class IMDbWatchListAPI + { + [XmlRoot(ElementName = "item")] + public class Movie + { + [XmlElement(ElementName = "pubDate")] + public string PublishDate { get; set; } + [XmlElement(ElementName = "title")] + public string Title { get; set; } + [XmlElement(ElementName = "link")] + public string Link { get; set; } + [XmlElement(ElementName = "guid")] + public string Guid { get; set; } + [XmlElement(ElementName = "description")] + public string Description { get; set; } + } + + [XmlRoot(ElementName = "channel")] + public class Channel + { + [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 = "pubDate")] + public string PublishDate { get; set; } + [XmlElement(ElementName = "lastBuildDate")] + public string LastBuildDate { get; set; } + [XmlElement(ElementName = "item")] + public List Movie { get; set; } + } + } +} diff --git a/src/NzbDrone.Core/NetImport/IMDbWatchList/IMDbWatchListParser.cs b/src/NzbDrone.Core/NetImport/IMDbWatchList/IMDbWatchListParser.cs new file mode 100644 index 000000000..7fd666141 --- /dev/null +++ b/src/NzbDrone.Core/NetImport/IMDbWatchList/IMDbWatchListParser.cs @@ -0,0 +1,54 @@ +using Newtonsoft.Json; +using NzbDrone.Core.NetImport.Exceptions; +using NzbDrone.Core.Tv; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Text; + +namespace NzbDrone.Core.NetImport.IMDbWatchList +{ + public class IMDbWatchListParser : IParseNetImportResponse + { + private readonly IMDbWatchListSettings _settings; + + public IMDbWatchListParser(IMDbWatchListSettings settings) + { + _settings = settings; + } + + public IList ParseResponse(NetImportResponse netImportResponse) + { + var torrentInfos = new List(); + + if (netImportResponse.HttpResponse.StatusCode != HttpStatusCode.OK) + { + throw new NetImportException(netImportResponse, + "Unexpected response status {0} code from API request", + netImportResponse.HttpResponse.StatusCode); + } + + var jsonResponse = JsonConvert.DeserializeObject(netImportResponse.Content); + + var responseData = jsonResponse.Movie; + if (responseData == null) + { + throw new NetImportException(netImportResponse, + "This list has no movies"); + } + + foreach (var result in responseData) + { + torrentInfos.Add(new Movie() + { + Title = Parser.Parser.ParseMovieTitle(result.Title, false).MovieTitle, + Year = Parser.Parser.ParseMovieTitle(result.Title, false).Year, + ImdbId = Parser.Parser.ParseImdbId(result.Link).ToString() + }); + } + + return torrentInfos.ToArray(); + } + } +} diff --git a/src/NzbDrone.Core/AutoImport.derp/IMDbWatchList/IMDbWatchListProxy.cs b/src/NzbDrone.Core/NetImport/IMDbWatchList/IMDbWatchListProxy.cs similarity index 93% rename from src/NzbDrone.Core/AutoImport.derp/IMDbWatchList/IMDbWatchListProxy.cs rename to src/NzbDrone.Core/NetImport/IMDbWatchList/IMDbWatchListProxy.cs index 28561ef66..664919c52 100644 --- a/src/NzbDrone.Core/AutoImport.derp/IMDbWatchList/IMDbWatchListProxy.cs +++ b/src/NzbDrone.Core/NetImport/IMDbWatchList/IMDbWatchListProxy.cs @@ -8,7 +8,7 @@ using NzbDrone.Core.Exceptions; using RestSharp; using NzbDrone.Core.Rest; -namespace NzbDrone.Core.AutoImport.IMDbWatchList +namespace NzbDrone.Core.NetImport.IMDbWatchList { public interface IIMDbWatchListProxy { @@ -64,8 +64,8 @@ namespace NzbDrone.Core.AutoImport.IMDbWatchList { try { - Verify(settings.IMDbWatchListId); - ImportMovies(settings.IMDbWatchListId); + Verify(settings.Link); + ImportMovies(settings.Link); } catch (Exception ex) { diff --git a/src/NzbDrone.Core/NetImport/IMDbWatchList/IMDbWatchListRequestGenerator.cs b/src/NzbDrone.Core/NetImport/IMDbWatchList/IMDbWatchListRequestGenerator.cs new file mode 100644 index 000000000..cfd92810b --- /dev/null +++ b/src/NzbDrone.Core/NetImport/IMDbWatchList/IMDbWatchListRequestGenerator.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using NzbDrone.Common.Http; +using NzbDrone.Common.Serializer; +using NzbDrone.Core.IndexerSearch.Definitions; + +namespace NzbDrone.Core.NetImport.IMDbWatchList +{ + public class IMDbWatchListRequestGenerator : INetImportRequestGenerator + { + public IMDbWatchListSettings Settings { get; set; } + + public virtual NetImportPageableRequestChain GetMovies() + { + var pageableRequests = new NetImportPageableRequestChain(); + + pageableRequests.Add(GetMovies(null)); + + return pageableRequests; + } + + public NetImportPageableRequestChain GetSearchRequests(MovieSearchCriteria searchCriteria) + { + return new NetImportPageableRequestChain(); + } + + private IEnumerable GetMovies(string searchParameters) + { + var request = new NetImportRequest($"{Settings.Link.Trim()}", HttpAccept.Rss); + yield return request; + } + } +} diff --git a/src/NzbDrone.Core/AutoImport.derp/IMDbWatchList/IMDbWatchListSettings.cs b/src/NzbDrone.Core/NetImport/IMDbWatchList/IMDbWatchListSettings.cs similarity index 60% rename from src/NzbDrone.Core/AutoImport.derp/IMDbWatchList/IMDbWatchListSettings.cs rename to src/NzbDrone.Core/NetImport/IMDbWatchList/IMDbWatchListSettings.cs index 4ecd75c72..f63e7206f 100644 --- a/src/NzbDrone.Core/AutoImport.derp/IMDbWatchList/IMDbWatchListSettings.cs +++ b/src/NzbDrone.Core/NetImport/IMDbWatchList/IMDbWatchListSettings.cs @@ -3,13 +3,13 @@ using NzbDrone.Core.Annotations; using NzbDrone.Core.ThingiProvider; using NzbDrone.Core.Validation; -namespace NzbDrone.Core.AutoImport.IMDbWatchList +namespace NzbDrone.Core.NetImport.IMDbWatchList { public class IMDbWatchListSettingsValidator : AbstractValidator { public IMDbWatchListSettingsValidator() { - RuleFor(c => c.IMDbWatchListId).NotEmpty(); + RuleFor(c => c.Link).NotEmpty(); } } @@ -17,10 +17,15 @@ namespace NzbDrone.Core.AutoImport.IMDbWatchList { private static readonly IMDbWatchListSettingsValidator Validator = new IMDbWatchListSettingsValidator(); - [FieldDefinition(0, Label = "Watch List Id", HelpLink = "http://rss.imdb.com/list/")] - public string IMDbWatchListId { get; set; } + public IMDbWatchListSettings() + { + Link = "http://rss.imdb.com/list/"; + } + + [FieldDefinition(0, Label = "Watch List RSS link", HelpLink = "http://rss.imdb.com/list/")] + public string Link { get; set; } - public bool IsValid => !string.IsNullOrWhiteSpace(IMDbWatchListId); + public bool IsValid => !string.IsNullOrWhiteSpace(Link); public NzbDroneValidationResult Validate() { diff --git a/src/NzbDrone.Core/AutoImporter/IAutoImporter.cs b/src/NzbDrone.Core/NetImport/INetImport.cs similarity index 77% rename from src/NzbDrone.Core/AutoImporter/IAutoImporter.cs rename to src/NzbDrone.Core/NetImport/INetImport.cs index f78f90141..82ec79629 100644 --- a/src/NzbDrone.Core/AutoImporter/IAutoImporter.cs +++ b/src/NzbDrone.Core/NetImport/INetImport.cs @@ -4,9 +4,9 @@ using NzbDrone.Core.Parser.Model; using NzbDrone.Core.ThingiProvider; using NzbDrone.Core.Tv; -namespace NzbDrone.Core.AutoImporter +namespace NzbDrone.Core.NetImport { - public interface IAutoImporter : IProvider + public interface INetImport : IProvider { string Link { get; } bool Enabled { get; } diff --git a/src/NzbDrone.Core/NetImport/INetImportRequestGenerator.cs b/src/NzbDrone.Core/NetImport/INetImportRequestGenerator.cs new file mode 100644 index 000000000..d2c8107a4 --- /dev/null +++ b/src/NzbDrone.Core/NetImport/INetImportRequestGenerator.cs @@ -0,0 +1,9 @@ +using NzbDrone.Core.IndexerSearch.Definitions; + +namespace NzbDrone.Core.NetImport +{ + public interface INetImportRequestGenerator + { + NetImportPageableRequestChain GetMovies(); + } +} \ No newline at end of file diff --git a/src/NzbDrone.Core/NetImport/IProcessNetImportResponse.cs b/src/NzbDrone.Core/NetImport/IProcessNetImportResponse.cs new file mode 100644 index 000000000..4776f551e --- /dev/null +++ b/src/NzbDrone.Core/NetImport/IProcessNetImportResponse.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; +using NzbDrone.Core.Parser.Model; +using NzbDrone.Core.Tv; + +namespace NzbDrone.Core.NetImport +{ + public interface IParseNetImportResponse + { + IList ParseResponse(NetImportResponse netMovieImporterResponse); + } +} diff --git a/src/NzbDrone.Core/AutoImporter/AutoImporterBase.cs b/src/NzbDrone.Core/NetImport/NetImportBase.cs similarity index 89% rename from src/NzbDrone.Core/AutoImporter/AutoImporterBase.cs rename to src/NzbDrone.Core/NetImport/NetImportBase.cs index 7d95bdfe8..a3d2723e2 100644 --- a/src/NzbDrone.Core/AutoImporter/AutoImporterBase.cs +++ b/src/NzbDrone.Core/NetImport/NetImportBase.cs @@ -11,9 +11,9 @@ using NzbDrone.Core.Parser.Model; using NzbDrone.Core.ThingiProvider; using NzbDrone.Core.Tv; -namespace NzbDrone.Core.AutoImporter +namespace NzbDrone.Core.NetImport { - public abstract class AutoImporterBase : IAutoImporter + public abstract class NetImportBase : INetImport where TSettings : IProviderConfig, new() { protected readonly IConfigService _configService; @@ -25,7 +25,7 @@ namespace NzbDrone.Core.AutoImporter public abstract bool Enabled { get; } - public AutoImporterBase(IConfigService configService, IParsingService parsingService, Logger logger) + public NetImportBase(IConfigService configService, IParsingService parsingService, Logger logger) { _configService = configService; _parsingService = parsingService; @@ -42,7 +42,7 @@ namespace NzbDrone.Core.AutoImporter { var config = (IProviderConfig)new TSettings(); - yield return new AutoImporterDefinition + yield return new NetImportDefinition { Name = GetType().Name, Link = Link, diff --git a/src/NzbDrone.Core/AutoImporter/AutoImporterDefinition.cs b/src/NzbDrone.Core/NetImport/NetImportDefinition.cs similarity index 65% rename from src/NzbDrone.Core/AutoImporter/AutoImporterDefinition.cs rename to src/NzbDrone.Core/NetImport/NetImportDefinition.cs index b3fad1178..6d2442eb7 100644 --- a/src/NzbDrone.Core/AutoImporter/AutoImporterDefinition.cs +++ b/src/NzbDrone.Core/NetImport/NetImportDefinition.cs @@ -1,8 +1,8 @@ using NzbDrone.Core.ThingiProvider; -namespace NzbDrone.Core.AutoImporter +namespace NzbDrone.Core.NetImport { - public class AutoImporterDefinition : ProviderDefinition + public class NetImportDefinition : ProviderDefinition { public bool Enabled { get; set; } public string Link { get; set; } diff --git a/src/NzbDrone.Core/NetImport/NetImportPageableRequest.cs b/src/NzbDrone.Core/NetImport/NetImportPageableRequest.cs new file mode 100644 index 000000000..50a43fce9 --- /dev/null +++ b/src/NzbDrone.Core/NetImport/NetImportPageableRequest.cs @@ -0,0 +1,25 @@ +using System.Collections; +using System.Collections.Generic; + +namespace NzbDrone.Core.NetImport +{ + public class NetImportPageableRequest : IEnumerable + { + private readonly IEnumerable _enumerable; + + public NetImportPageableRequest(IEnumerable enumerable) + { + _enumerable = enumerable; + } + + public IEnumerator GetEnumerator() + { + return _enumerable.GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return _enumerable.GetEnumerator(); + } + } +} diff --git a/src/NzbDrone.Core/NetImport/NetImportPageableRequestChain.cs b/src/NzbDrone.Core/NetImport/NetImportPageableRequestChain.cs new file mode 100644 index 000000000..080b8727a --- /dev/null +++ b/src/NzbDrone.Core/NetImport/NetImportPageableRequestChain.cs @@ -0,0 +1,48 @@ +using System.Collections.Generic; +using System.Linq; + +namespace NzbDrone.Core.NetImport +{ + public class NetImportPageableRequestChain + { + private List> _chains; + + public NetImportPageableRequestChain() + { + _chains = new List>(); + _chains.Add(new List()); + } + + public int Tiers => _chains.Count; + + public IEnumerable GetAllTiers() + { + return _chains.SelectMany(v => v); + } + + public IEnumerable GetTier(int index) + { + return _chains[index]; + } + + public void Add(IEnumerable request) + { + if (request == null) return; + + _chains.Last().Add(new NetImportPageableRequest(request)); + } + + public void AddTier(IEnumerable request) + { + AddTier(); + Add(request); + } + + public void AddTier() + { + if (_chains.Last().Count == 0) return; + + _chains.Add(new List()); + } + } +} \ No newline at end of file diff --git a/src/NzbDrone.Core/NetImport/NetImportRepository.cs b/src/NzbDrone.Core/NetImport/NetImportRepository.cs new file mode 100644 index 000000000..8efa8a4a8 --- /dev/null +++ b/src/NzbDrone.Core/NetImport/NetImportRepository.cs @@ -0,0 +1,20 @@ +using NzbDrone.Core.Datastore; +using NzbDrone.Core.Messaging.Events; +using NzbDrone.Core.ThingiProvider; + + +namespace NzbDrone.Core.NetImport +{ + public interface INetImportRepository : IProviderRepository + { + + } + + public class NetImportRepository : ProviderRepository, INetImportRepository + { + public NetImportRepository(IMainDatabase database, IEventAggregator eventAggregator) + : base(database, eventAggregator) + { + } + } +} \ No newline at end of file diff --git a/src/NzbDrone.Core/NetImport/NetImportRequest.cs b/src/NzbDrone.Core/NetImport/NetImportRequest.cs new file mode 100644 index 000000000..e00fe316f --- /dev/null +++ b/src/NzbDrone.Core/NetImport/NetImportRequest.cs @@ -0,0 +1,21 @@ +using NzbDrone.Common.Http; + +namespace NzbDrone.Core.NetImport +{ + public class NetImportRequest + { + public HttpRequest HttpRequest { get; private set; } + + public NetImportRequest(string url, HttpAccept httpAccept) + { + HttpRequest = new HttpRequest(url, httpAccept); + } + + public NetImportRequest(HttpRequest httpRequest) + { + HttpRequest = httpRequest; + } + + public HttpUri Url => HttpRequest.Url; + } +} diff --git a/src/NzbDrone.Core/NetImport/NetImportResponse.cs b/src/NzbDrone.Core/NetImport/NetImportResponse.cs new file mode 100644 index 000000000..3174b0775 --- /dev/null +++ b/src/NzbDrone.Core/NetImport/NetImportResponse.cs @@ -0,0 +1,24 @@ +using NzbDrone.Common.Http; + +namespace NzbDrone.Core.NetImport +{ + public class NetImportResponse + { + private readonly NetImportRequest _netImport; + private readonly HttpResponse _httpResponse; + + public NetImportResponse(NetImportRequest netImport, HttpResponse httpResponse) + { + _netImport = netImport; + _httpResponse = httpResponse; + } + + public NetImportRequest Request => _netImport; + + public HttpRequest HttpRequest => _httpResponse.Request; + + public HttpResponse HttpResponse => _httpResponse; + + public string Content => _httpResponse.Content; + } +} diff --git a/src/NzbDrone.Core/NzbDrone.Core.csproj b/src/NzbDrone.Core/NzbDrone.Core.csproj index 563e08c8e..ebbf9c761 100644 --- a/src/NzbDrone.Core/NzbDrone.Core.csproj +++ b/src/NzbDrone.Core/NzbDrone.Core.csproj @@ -122,16 +122,24 @@ - - - - - - - - - - + + + + + + + + + + + + + + + + + +