From 090ba3bb86b1d4cf93369ac6b72bcf0c74ba41f0 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Fri, 16 Jan 2015 07:32:22 -0800 Subject: [PATCH] Fixed: Removed Animezb indexer --- .../AnimezbTests/AnimezbFixture.cs | 54 --------- .../NzbDrone.Core.Test.csproj | 1 - .../ParserTests/DailyEpisodeParserFixture.cs | 2 + .../Datastore/BasicRepository.cs | 2 +- src/NzbDrone.Core/Indexers/Animezb/Animezb.cs | 29 ----- .../Animezb/AnimezbRequestGenerator.cs | 104 ------------------ src/NzbDrone.Core/Indexers/IndexerFactory.cs | 5 +- .../Indexers/IndexerRepository.cs | 5 +- src/NzbDrone.Core/NzbDrone.Core.csproj | 2 - .../ThingiProvider/IProviderRepository.cs | 1 + .../ThingiProvider/ProviderFactory.cs | 1 + .../ThingiProvider/ProviderRepository.cs | 5 + 12 files changed, 17 insertions(+), 194 deletions(-) delete mode 100644 src/NzbDrone.Core.Test/IndexerTests/AnimezbTests/AnimezbFixture.cs delete mode 100644 src/NzbDrone.Core/Indexers/Animezb/Animezb.cs delete mode 100644 src/NzbDrone.Core/Indexers/Animezb/AnimezbRequestGenerator.cs diff --git a/src/NzbDrone.Core.Test/IndexerTests/AnimezbTests/AnimezbFixture.cs b/src/NzbDrone.Core.Test/IndexerTests/AnimezbTests/AnimezbFixture.cs deleted file mode 100644 index 68fd5481d..000000000 --- a/src/NzbDrone.Core.Test/IndexerTests/AnimezbTests/AnimezbFixture.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System.Linq; -using FluentAssertions; -using Moq; -using NUnit.Framework; -using NzbDrone.Common.Http; -using NzbDrone.Core.Indexers; -using NzbDrone.Core.Indexers.Animezb; -using NzbDrone.Core.Test.Framework; -using NzbDrone.Core.ThingiProvider; - -namespace NzbDrone.Core.Test.IndexerTests.AnimezbTests -{ - [TestFixture] - public class AnimezbFixture : CoreTest - { - [SetUp] - public void Setup() - { - Subject.Definition = new IndexerDefinition() - { - Name = "Animezb", - Settings = new NullConfig() - }; - - } - - [Test] - public void should_parse_recent_feed_from_Animezb() - { - Assert.Inconclusive("Waiting for animezb to get back up."); - - var recentFeed = ReadAllText(@"Files/RSS/Animezb.xml"); - - Mocker.GetMock() - .Setup(o => o.Execute(It.Is(v => v.Method == HttpMethod.GET))) - .Returns(r => new HttpResponse(r, new HttpHeader(), recentFeed)); - - var releases = Subject.FetchRecent(); - - releases.Should().HaveCount(3); - - var releaseInfo = releases.First(); - - //releaseInfo.Title.Should().Be("[Vivid] Hanayamata - 10 [A33D6606]"); - releaseInfo.DownloadProtocol.Should().Be(DownloadProtocol.Usenet); - //releaseInfo.DownloadUrl.Should().Be("http://fanzub.com/nzb/296464/Vivid%20Hanayamata%20-%2010.nzb"); - releaseInfo.InfoUrl.Should().BeNullOrEmpty(); - releaseInfo.CommentUrl.Should().BeNullOrEmpty(); - releaseInfo.Indexer.Should().Be(Subject.Definition.Name); - //releaseInfo.PublishDate.Should().Be(DateTime.Parse("2014/09/13 12:56:53")); - //releaseInfo.Size.Should().Be(556246858); - } - } -} diff --git a/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj index 948ea9b6a..84f43fbcf 100644 --- a/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj +++ b/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj @@ -192,7 +192,6 @@ - diff --git a/src/NzbDrone.Core.Test/ParserTests/DailyEpisodeParserFixture.cs b/src/NzbDrone.Core.Test/ParserTests/DailyEpisodeParserFixture.cs index 8fc348dd4..e51ee8503 100644 --- a/src/NzbDrone.Core.Test/ParserTests/DailyEpisodeParserFixture.cs +++ b/src/NzbDrone.Core.Test/ParserTests/DailyEpisodeParserFixture.cs @@ -26,6 +26,8 @@ namespace NzbDrone.Core.Test.ParserTests [TestCase("The_Voice_US_04.28.2014_hdtv.x264.Poke.mp4", "The Voice US", 2014, 4, 28)] [TestCase("At.Midnight.140722.720p.HDTV.x264-YesTV", "At Midnight", 2014, 07, 22)] [TestCase("At_Midnight_140722_720p_HDTV_x264-YesTV", "At Midnight", 2014, 07, 22)] + //[TestCase("Corrie.07.01.15", "Corrie", 2015, 1, 7)] + //[TestCase("", "", 0, 0, 0)] public void should_parse_daily_episode(string postTitle, string title, int year, int month, int day) { var result = Parser.Parser.ParseTitle(postTitle); diff --git a/src/NzbDrone.Core/Datastore/BasicRepository.cs b/src/NzbDrone.Core/Datastore/BasicRepository.cs index f9691266c..809ef3d28 100644 --- a/src/NzbDrone.Core/Datastore/BasicRepository.cs +++ b/src/NzbDrone.Core/Datastore/BasicRepository.cs @@ -40,7 +40,7 @@ namespace NzbDrone.Core.Datastore private readonly IDatabase _database; private readonly IEventAggregator _eventAggregator; - private IDataMapper DataMapper + protected IDataMapper DataMapper { get { return _database.GetDataMapper(); } } diff --git a/src/NzbDrone.Core/Indexers/Animezb/Animezb.cs b/src/NzbDrone.Core/Indexers/Animezb/Animezb.cs deleted file mode 100644 index 639d53e59..000000000 --- a/src/NzbDrone.Core/Indexers/Animezb/Animezb.cs +++ /dev/null @@ -1,29 +0,0 @@ -using NLog; -using NzbDrone.Common.Http; -using NzbDrone.Core.Configuration; -using NzbDrone.Core.Parser; -using NzbDrone.Core.ThingiProvider; - -namespace NzbDrone.Core.Indexers.Animezb -{ - public class Animezb : HttpIndexerBase - { - public override DownloadProtocol Protocol { get { return DownloadProtocol.Usenet; } } - - public Animezb(IHttpClient httpClient, IConfigService configService, IParsingService parsingService, Logger logger) - : base(httpClient, configService, parsingService, logger) - { - - } - - public override IIndexerRequestGenerator GetRequestGenerator() - { - return new AnimezbRequestGenerator(); - } - - public override IParseIndexerResponse GetParser() - { - return new RssParser() { UseEnclosureLength = true }; - } - } -} diff --git a/src/NzbDrone.Core/Indexers/Animezb/AnimezbRequestGenerator.cs b/src/NzbDrone.Core/Indexers/Animezb/AnimezbRequestGenerator.cs deleted file mode 100644 index 2fac28d07..000000000 --- a/src/NzbDrone.Core/Indexers/Animezb/AnimezbRequestGenerator.cs +++ /dev/null @@ -1,104 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Text.RegularExpressions; -using NzbDrone.Common.Extensions; -using NzbDrone.Common.Http; -using NzbDrone.Core.IndexerSearch.Definitions; - -namespace NzbDrone.Core.Indexers.Animezb -{ - public class AnimezbRequestGenerator : IIndexerRequestGenerator - { - private static readonly Regex RemoveCharactersRegex = new Regex(@"[!?`]", RegexOptions.Compiled); - private static readonly Regex RemoveSingleCharacterRegex = new Regex(@"\b[a-z0-9]\b", RegexOptions.Compiled | RegexOptions.IgnoreCase); - private static readonly Regex DuplicateCharacterRegex = new Regex(@"[ +]{2,}", RegexOptions.Compiled | RegexOptions.IgnoreCase); - - public String BaseUrl { get; set; } - public Int32 PageSize { get; set; } - - public AnimezbRequestGenerator() - { - BaseUrl = "https://animezb.com/rss?cat=anime"; - PageSize = 100; - } - - public virtual IList> GetRecentRequests() - { - var pageableRequests = new List>(); - - pageableRequests.AddIfNotNull(GetPagedRequests(null)); - - return pageableRequests; - } - - public virtual IList> GetSearchRequests(SingleEpisodeSearchCriteria searchCriteria) - { - return new List>(); - } - - public virtual IList> GetSearchRequests(SeasonSearchCriteria searchCriteria) - { - return new List>(); - } - - public virtual IList> GetSearchRequests(DailyEpisodeSearchCriteria searchCriteria) - { - return new List>(); - } - - public virtual IList> GetSearchRequests(AnimeEpisodeSearchCriteria searchCriteria) - { - var pageableRequests = new List>(); - - foreach (var queryTitle in searchCriteria.QueryTitles) - { - var searchQuery = GetSearchQuery(queryTitle, searchCriteria.AbsoluteEpisodeNumber); - - pageableRequests.Add(GetPagedRequests(searchQuery)); - } - - return pageableRequests; - } - - public virtual IList> GetSearchRequests(SpecialEpisodeSearchCriteria searchCriteria) - { - return new List>(); - } - - private IEnumerable GetPagedRequests(String query) - { - var url = new StringBuilder(); - url.AppendFormat("{0}&max={1}", BaseUrl, PageSize); - - if (query.IsNotNullOrWhiteSpace()) - { - url.AppendFormat("&q={0}", query); - } - - yield return new IndexerRequest(url.ToString(), HttpAccept.Rss); - } - - private String GetSearchQuery(String title, Int32 absoluteEpisodeNumber) - { - var match = RemoveSingleCharacterRegex.Match(title); - - if (match.Success) - { - title = RemoveSingleCharacterRegex.Replace(title, ""); - - //Since we removed a character we need to not wrap it in quotes and hope animedb doesn't give us a million results - return CleanTitle(String.Format("{0}+{1:00}", title, absoluteEpisodeNumber)); - } - - //Wrap the query in quotes and search! - return CleanTitle(String.Format("\"{0}+{1:00}\"", title, absoluteEpisodeNumber)); - } - - private String CleanTitle(String title) - { - title = RemoveCharactersRegex.Replace(title, ""); - return DuplicateCharacterRegex.Replace(title, "+"); - } - } -} diff --git a/src/NzbDrone.Core/Indexers/IndexerFactory.cs b/src/NzbDrone.Core/Indexers/IndexerFactory.cs index eab2e8cb8..775e08374 100644 --- a/src/NzbDrone.Core/Indexers/IndexerFactory.cs +++ b/src/NzbDrone.Core/Indexers/IndexerFactory.cs @@ -15,6 +15,8 @@ namespace NzbDrone.Core.Indexers public class IndexerFactory : ProviderFactory, IIndexerFactory { + private readonly IIndexerRepository _providerRepository; + public IndexerFactory(IIndexerRepository providerRepository, IEnumerable providers, IContainer container, @@ -22,11 +24,12 @@ namespace NzbDrone.Core.Indexers Logger logger) : base(providerRepository, providers, container, eventAggregator, logger) { + _providerRepository = providerRepository; } protected override void InitializeProviders() { - + //_providerRepository.DeleteImplementations("Animezb"); } protected override List Active() diff --git a/src/NzbDrone.Core/Indexers/IndexerRepository.cs b/src/NzbDrone.Core/Indexers/IndexerRepository.cs index 269bb5507..6e1f18f02 100644 --- a/src/NzbDrone.Core/Indexers/IndexerRepository.cs +++ b/src/NzbDrone.Core/Indexers/IndexerRepository.cs @@ -1,4 +1,6 @@ -using NzbDrone.Core.Datastore; +using System.Data; +using Marr.Data; +using NzbDrone.Core.Datastore; using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.ThingiProvider; @@ -7,7 +9,6 @@ namespace NzbDrone.Core.Indexers { public interface IIndexerRepository : IProviderRepository { - } public class IndexerRepository : ProviderRepository, IIndexerRepository diff --git a/src/NzbDrone.Core/NzbDrone.Core.csproj b/src/NzbDrone.Core/NzbDrone.Core.csproj index d02981902..67d2e3cda 100644 --- a/src/NzbDrone.Core/NzbDrone.Core.csproj +++ b/src/NzbDrone.Core/NzbDrone.Core.csproj @@ -423,8 +423,6 @@ - - diff --git a/src/NzbDrone.Core/ThingiProvider/IProviderRepository.cs b/src/NzbDrone.Core/ThingiProvider/IProviderRepository.cs index 13043b64d..8e7087344 100644 --- a/src/NzbDrone.Core/ThingiProvider/IProviderRepository.cs +++ b/src/NzbDrone.Core/ThingiProvider/IProviderRepository.cs @@ -4,5 +4,6 @@ namespace NzbDrone.Core.ThingiProvider { public interface IProviderRepository : IBasicRepository where TProvider : ModelBase, new() { +// void DeleteImplementations(string implementation); } } \ No newline at end of file diff --git a/src/NzbDrone.Core/ThingiProvider/ProviderFactory.cs b/src/NzbDrone.Core/ThingiProvider/ProviderFactory.cs index 7ba72778f..656d1347f 100644 --- a/src/NzbDrone.Core/ThingiProvider/ProviderFactory.cs +++ b/src/NzbDrone.Core/ThingiProvider/ProviderFactory.cs @@ -143,6 +143,7 @@ namespace NzbDrone.Core.ThingiProvider return definition; } + //TODO: Remove providers even if the ConfigContract can't be deserialized (this will fail to remove providers if the settings can't be deserialized). private void RemoveMissingImplementations() { var storedProvider = _providerRepository.All(); diff --git a/src/NzbDrone.Core/ThingiProvider/ProviderRepository.cs b/src/NzbDrone.Core/ThingiProvider/ProviderRepository.cs index 9019ac0ff..f0f54650a 100644 --- a/src/NzbDrone.Core/ThingiProvider/ProviderRepository.cs +++ b/src/NzbDrone.Core/ThingiProvider/ProviderRepository.cs @@ -11,5 +11,10 @@ namespace NzbDrone.Core.ThingiProvider : base(database, eventAggregator) { } + +// public void DeleteImplementations(string implementation) +// { +// DataMapper.Delete(c => c.Implementation == implementation); +// } } } \ No newline at end of file