mirror of https://github.com/Sonarr/Sonarr
removed nzbsrus
This commit is contained in:
parent
6b0a24e28e
commit
64df2229d6
|
@ -1,13 +1,13 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Indexers;
|
||||
using NzbDrone.Core.Indexers.Newznab;
|
||||
using NzbDrone.Core.Indexers.NzbClub;
|
||||
using NzbDrone.Core.Indexers.NzbsRUs;
|
||||
using NzbDrone.Core.Indexers.Omgwtfnzbs;
|
||||
using NzbDrone.Core.Indexers.Wombles;
|
||||
using NzbDrone.Core.Lifecycle;
|
||||
|
@ -25,7 +25,6 @@ namespace NzbDrone.Core.Test.IndexerTests
|
|||
_indexers = new List<IIndexer>();
|
||||
|
||||
_indexers.Add(new Newznab());
|
||||
_indexers.Add(new Nzbsrus());
|
||||
_indexers.Add(new NzbClub());
|
||||
_indexers.Add(new Omgwtfnzbs());
|
||||
_indexers.Add(new Wombles());
|
||||
|
@ -67,5 +66,23 @@ namespace NzbDrone.Core.Test.IndexerTests
|
|||
indexers.Select(c => c.Instance).Should().OnlyHaveUniqueItems();
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void should_remove_missing_indexers_on_startup()
|
||||
{
|
||||
var repo = Mocker.Resolve<IndexerRepository>();
|
||||
|
||||
Mocker.SetConstant<IIndexerRepository>(repo);
|
||||
|
||||
|
||||
var existingIndexers = Builder<IndexerDefinition>.CreateNew().BuildNew();
|
||||
|
||||
repo.Insert(existingIndexers);
|
||||
|
||||
|
||||
Subject.Handle(new ApplicationStartedEvent());
|
||||
|
||||
AllStoredModels.Should().NotContain(c => c.Id == existingIndexers.Id);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -136,23 +136,39 @@ namespace NzbDrone.Core.Indexers
|
|||
|
||||
private IIndexer GetInstance(IndexerDefinition indexerDefinition)
|
||||
{
|
||||
var type = _indexers.Single(c => c.GetType().Name.Equals(indexerDefinition.Implementation, StringComparison.InvariantCultureIgnoreCase)).GetType();
|
||||
|
||||
var type = GetImplementation(indexerDefinition);
|
||||
var instance = (IIndexer)Activator.CreateInstance(type);
|
||||
|
||||
instance.InstanceDefinition = indexerDefinition;
|
||||
return instance;
|
||||
}
|
||||
|
||||
private Type GetImplementation(IndexerDefinition indexerDefinition)
|
||||
{
|
||||
return _indexers.Select(c => c.GetType()).SingleOrDefault(c => c.Name.Equals(indexerDefinition.Implementation, StringComparison.InvariantCultureIgnoreCase));
|
||||
}
|
||||
|
||||
public void Handle(ApplicationStartedEvent message)
|
||||
{
|
||||
_logger.Debug("Initializing indexers. Count {0}", _indexers.Count);
|
||||
|
||||
RemoveMissingImplementations();
|
||||
|
||||
if (!All().Any())
|
||||
{
|
||||
var definitions = _indexers.SelectMany(indexer => indexer.DefaultDefinitions);
|
||||
_indexerRepository.InsertMany(definitions.ToList());
|
||||
}
|
||||
}
|
||||
|
||||
private void RemoveMissingImplementations()
|
||||
{
|
||||
var storedIndexers = _indexerRepository.All();
|
||||
|
||||
foreach (var indexerDefinition in storedIndexers.Where(i => GetImplementation(i) == null))
|
||||
{
|
||||
_logger.Debug("Removing Indexer {0} ", indexerDefinition.Name);
|
||||
_indexerRepository.Delete(indexerDefinition);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NzbDrone.Core.Indexers.NzbsRUs
|
||||
{
|
||||
public class Nzbsrus : IndexerWithSetting<NzbsrusSetting>
|
||||
{
|
||||
public override IEnumerable<string> RecentFeed
|
||||
{
|
||||
get
|
||||
{
|
||||
yield return string.Format("https://www.nzbsrus.com/rssfeed.php?cat=91,75&i={0}&h={1}",
|
||||
Settings.Uid,
|
||||
Settings.Hash);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public override string Name
|
||||
{
|
||||
get { return "NzbsRUs"; }
|
||||
}
|
||||
|
||||
public override IEnumerable<string> GetEpisodeSearchUrls(string seriesTitle, int seasonNumber, int episodeNumber)
|
||||
{
|
||||
return new List<string>();
|
||||
}
|
||||
|
||||
public override IEnumerable<string> GetSeasonSearchUrls(string seriesTitle, int seasonNumber)
|
||||
{
|
||||
return new List<string>();
|
||||
}
|
||||
|
||||
public override IEnumerable<string> GetDailyEpisodeSearchUrls(string seriesTitle, DateTime date)
|
||||
{
|
||||
return new List<string>();
|
||||
}
|
||||
|
||||
public override IEnumerable<string> GetPartialSeasonSearchUrls(string seriesTitle, int seasonNumber, int episodeWildcard)
|
||||
{
|
||||
return new List<string>();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
using System.ServiceModel.Syndication;
|
||||
using System.Text.RegularExpressions;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Parser;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
|
||||
namespace NzbDrone.Core.Indexers.NzbsRUs
|
||||
{
|
||||
public class NzbsrusParser : BasicRssParser
|
||||
{
|
||||
protected override ReportInfo PostProcessor(SyndicationItem item, ReportInfo currentResult)
|
||||
{
|
||||
if (currentResult != null)
|
||||
{
|
||||
var sizeString = Regex.Match(item.Summary.Text, @"\d+\.\d{1,2} \w{3}", RegexOptions.IgnoreCase).Value;
|
||||
currentResult.Size = GetReportSize(sizeString);
|
||||
}
|
||||
|
||||
return currentResult;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
using System;
|
||||
using NzbDrone.Core.Annotations;
|
||||
|
||||
namespace NzbDrone.Core.Indexers.NzbsRUs
|
||||
{
|
||||
public class NzbsrusSetting : IIndexerSetting
|
||||
{
|
||||
[FieldDefinition(0, Label = "UID")]
|
||||
public String Uid { get; set; }
|
||||
|
||||
[FieldDefinition(1, Label = "Hash")]
|
||||
public String Hash { get; set; }
|
||||
|
||||
public bool IsValid
|
||||
{
|
||||
get
|
||||
{
|
||||
return !string.IsNullOrWhiteSpace(Uid) && !string.IsNullOrWhiteSpace(Hash);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -298,14 +298,11 @@
|
|||
<Compile Include="Indexers\Newznab\NewznabParser.cs" />
|
||||
<Compile Include="Indexers\NzbClub\NzbClub.cs" />
|
||||
<Compile Include="Indexers\NzbClub\NzbClubParser.cs" />
|
||||
<Compile Include="Indexers\NzbsRUs\NzbsRUs.cs" />
|
||||
<Compile Include="Indexers\NzbsRUs\NzbsrusParser.cs" />
|
||||
<Compile Include="Indexers\Nzbx\Nzbx.cs" />
|
||||
<Compile Include="Indexers\Nzbx\NzbxParser.cs" />
|
||||
<Compile Include="Indexers\Omgwtfnzbs\Omgwtfnzbs.cs" />
|
||||
<Compile Include="Indexers\Omgwtfnzbs\OmgwtfnzbsParser.cs" />
|
||||
<Compile Include="Indexers\IIndexerSetting.cs" />
|
||||
<Compile Include="Indexers\NzbsRUs\NzbsrusSettings.cs" />
|
||||
<Compile Include="Indexers\Omgwtfnzbs\OmgwtfnzbsSettings.cs" />
|
||||
<Compile Include="Indexers\Wombles\Wombles.cs" />
|
||||
<Compile Include="Indexers\Wombles\WomblesParser.cs" />
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
<FileVersion>1</FileVersion>
|
||||
<AutoEnableOnStartup>False</AutoEnableOnStartup>
|
||||
<AllowParallelTestExecution>true</AllowParallelTestExecution>
|
||||
<AllowTestsToRunInParallelWithThemselves>true</AllowTestsToRunInParallelWithThemselves>
|
||||
<FrameworkUtilisationTypeForNUnit>UseDynamicAnalysis</FrameworkUtilisationTypeForNUnit>
|
||||
<FrameworkUtilisationTypeForGallio>Disabled</FrameworkUtilisationTypeForGallio>
|
||||
<FrameworkUtilisationTypeForMSpec>Disabled</FrameworkUtilisationTypeForMSpec>
|
||||
|
|
Loading…
Reference in New Issue