mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-16 11:37:58 +02:00
Fixed: Removed Animezb indexer
This commit is contained in:
parent
8b6ecca8c9
commit
090ba3bb86
@ -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<Animezb>
|
||||
{
|
||||
[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<IHttpClient>()
|
||||
.Setup(o => o.Execute(It.Is<HttpRequest>(v => v.Method == HttpMethod.GET)))
|
||||
.Returns<HttpRequest>(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);
|
||||
}
|
||||
}
|
||||
}
|
@ -192,7 +192,6 @@
|
||||
<Compile Include="IndexerSearchTests\SeriesSearchServiceFixture.cs" />
|
||||
<Compile Include="IndexerSearchTests\NzbSearchServiceFixture.cs" />
|
||||
<Compile Include="IndexerSearchTests\SearchDefinitionFixture.cs" />
|
||||
<Compile Include="IndexerTests\AnimezbTests\AnimezbFixture.cs" />
|
||||
<Compile Include="IndexerTests\BasicRssParserFixture.cs" />
|
||||
<Compile Include="IndexerTests\BitMeTvTests\BitMeTvFixture.cs" />
|
||||
<Compile Include="IndexerTests\BroadcastheNetTests\BroadcastheNetFixture.cs" />
|
||||
|
@ -26,6 +26,8 @@ public class DailyEpisodeParserFixture : CoreTest
|
||||
[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);
|
||||
|
@ -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(); }
|
||||
}
|
||||
|
@ -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<NullConfig>
|
||||
{
|
||||
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 };
|
||||
}
|
||||
}
|
||||
}
|
@ -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<IEnumerable<IndexerRequest>> GetRecentRequests()
|
||||
{
|
||||
var pageableRequests = new List<IEnumerable<IndexerRequest>>();
|
||||
|
||||
pageableRequests.AddIfNotNull(GetPagedRequests(null));
|
||||
|
||||
return pageableRequests;
|
||||
}
|
||||
|
||||
public virtual IList<IEnumerable<IndexerRequest>> GetSearchRequests(SingleEpisodeSearchCriteria searchCriteria)
|
||||
{
|
||||
return new List<IEnumerable<IndexerRequest>>();
|
||||
}
|
||||
|
||||
public virtual IList<IEnumerable<IndexerRequest>> GetSearchRequests(SeasonSearchCriteria searchCriteria)
|
||||
{
|
||||
return new List<IEnumerable<IndexerRequest>>();
|
||||
}
|
||||
|
||||
public virtual IList<IEnumerable<IndexerRequest>> GetSearchRequests(DailyEpisodeSearchCriteria searchCriteria)
|
||||
{
|
||||
return new List<IEnumerable<IndexerRequest>>();
|
||||
}
|
||||
|
||||
public virtual IList<IEnumerable<IndexerRequest>> GetSearchRequests(AnimeEpisodeSearchCriteria searchCriteria)
|
||||
{
|
||||
var pageableRequests = new List<IEnumerable<IndexerRequest>>();
|
||||
|
||||
foreach (var queryTitle in searchCriteria.QueryTitles)
|
||||
{
|
||||
var searchQuery = GetSearchQuery(queryTitle, searchCriteria.AbsoluteEpisodeNumber);
|
||||
|
||||
pageableRequests.Add(GetPagedRequests(searchQuery));
|
||||
}
|
||||
|
||||
return pageableRequests;
|
||||
}
|
||||
|
||||
public virtual IList<IEnumerable<IndexerRequest>> GetSearchRequests(SpecialEpisodeSearchCriteria searchCriteria)
|
||||
{
|
||||
return new List<IEnumerable<IndexerRequest>>();
|
||||
}
|
||||
|
||||
private IEnumerable<IndexerRequest> 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, "+");
|
||||
}
|
||||
}
|
||||
}
|
@ -15,6 +15,8 @@ public interface IIndexerFactory : IProviderFactory<IIndexer, IndexerDefinition>
|
||||
|
||||
public class IndexerFactory : ProviderFactory<IIndexer, IndexerDefinition>, IIndexerFactory
|
||||
{
|
||||
private readonly IIndexerRepository _providerRepository;
|
||||
|
||||
public IndexerFactory(IIndexerRepository providerRepository,
|
||||
IEnumerable<IIndexer> providers,
|
||||
IContainer container,
|
||||
@ -22,11 +24,12 @@ public IndexerFactory(IIndexerRepository providerRepository,
|
||||
Logger logger)
|
||||
: base(providerRepository, providers, container, eventAggregator, logger)
|
||||
{
|
||||
_providerRepository = providerRepository;
|
||||
}
|
||||
|
||||
protected override void InitializeProviders()
|
||||
{
|
||||
|
||||
//_providerRepository.DeleteImplementations("Animezb");
|
||||
}
|
||||
|
||||
protected override List<IndexerDefinition> Active()
|
||||
|
@ -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<IndexerDefinition>
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public class IndexerRepository : ProviderRepository<IndexerDefinition>, IIndexerRepository
|
||||
|
@ -423,8 +423,6 @@
|
||||
<Compile Include="Housekeeping\HousekeepingCommand.cs" />
|
||||
<Compile Include="Housekeeping\HousekeepingService.cs" />
|
||||
<Compile Include="Housekeeping\IHousekeepingTask.cs" />
|
||||
<Compile Include="Indexers\Animezb\Animezb.cs" />
|
||||
<Compile Include="Indexers\Animezb\AnimezbRequestGenerator.cs" />
|
||||
<Compile Include="Indexers\BitMeTv\BitMeTv.cs" />
|
||||
<Compile Include="Indexers\BitMeTv\BitMeTvSettings.cs" />
|
||||
<Compile Include="Indexers\BitMeTv\BitMeTvRequestGenerator.cs" />
|
||||
|
@ -4,5 +4,6 @@ namespace NzbDrone.Core.ThingiProvider
|
||||
{
|
||||
public interface IProviderRepository<TProvider> : IBasicRepository<TProvider> where TProvider : ModelBase, new()
|
||||
{
|
||||
// void DeleteImplementations(string implementation);
|
||||
}
|
||||
}
|
@ -143,6 +143,7 @@ public virtual TProviderDefinition GetProviderCharacteristics(TProvider provider
|
||||
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();
|
||||
|
@ -11,5 +11,10 @@ protected ProviderRepository(IDatabase database, IEventAggregator eventAggregato
|
||||
: base(database, eventAggregator)
|
||||
{
|
||||
}
|
||||
|
||||
// public void DeleteImplementations(string implementation)
|
||||
// {
|
||||
// DataMapper.Delete<TProviderDefinition>(c => c.Implementation == implementation);
|
||||
// }
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user