Merge pull request #218 from Sonarr/fanzub-url

Fanzub url can now be modified [migration 82]
This commit is contained in:
Taloth 2015-03-09 20:54:41 +01:00
commit aa7aa3ce61
5 changed files with 61 additions and 5 deletions

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using FluentMigrator;
using NzbDrone.Common.Extensions;
using NzbDrone.Common.Serializer;
using NzbDrone.Core.Datastore.Migration.Framework;
namespace NzbDrone.Core.Datastore.Migration
{
[Migration(82)]
public class add_fanzub_settings : NzbDroneMigrationBase
{
protected override void MainDbUpgrade()
{
Execute.Sql("UPDATE Indexers SET ConfigContract = 'FanzubSettings' WHERE Implementation = 'Fanzub' AND ConfigContract = 'NullConfig'");
}
}
}

View File

@ -6,7 +6,7 @@ using NzbDrone.Core.ThingiProvider;
namespace NzbDrone.Core.Indexers.Fanzub
{
public class Fanzub : HttpIndexerBase<NullConfig>
public class Fanzub : HttpIndexerBase<FanzubSettings>
{
public override DownloadProtocol Protocol { get { return DownloadProtocol.Usenet; } }
@ -18,7 +18,7 @@ namespace NzbDrone.Core.Indexers.Fanzub
public override IIndexerRequestGenerator GetRequestGenerator()
{
return new FanzubRequestGenerator();
return new FanzubRequestGenerator() { Settings = Settings };
}
public override IParseIndexerResponse GetParser()

View File

@ -13,12 +13,11 @@ namespace NzbDrone.Core.Indexers.Fanzub
{
private static readonly Regex RemoveCharactersRegex = new Regex(@"[!?`]", RegexOptions.Compiled);
public String BaseUrl { get; set; }
public FanzubSettings Settings { get; set; }
public Int32 PageSize { get; set; }
public FanzubRequestGenerator()
{
BaseUrl = "http://fanzub.com/rss/?cat=anime";
PageSize = 100;
}
@ -65,7 +64,7 @@ namespace NzbDrone.Core.Indexers.Fanzub
private IEnumerable<IndexerRequest> GetPagedRequests(String query)
{
var url = new StringBuilder();
url.AppendFormat("{0}&max={1}", BaseUrl, PageSize);
url.AppendFormat("{0}?cat=anime&max={1}", Settings.BaseUrl, PageSize);
if (query.IsNotNullOrWhiteSpace())
{

View File

@ -0,0 +1,35 @@
using System;
using FluentValidation;
using FluentValidation.Results;
using NzbDrone.Core.Annotations;
using NzbDrone.Core.ThingiProvider;
using NzbDrone.Core.Validation;
namespace NzbDrone.Core.Indexers.Fanzub
{
public class FanzubSettingsValidator : AbstractValidator<FanzubSettings>
{
public FanzubSettingsValidator()
{
RuleFor(c => c.BaseUrl).ValidRootUrl();
}
}
public class FanzubSettings : IProviderConfig
{
private static readonly FanzubSettingsValidator validator = new FanzubSettingsValidator();
public FanzubSettings()
{
BaseUrl = "http://fanzub.com/rss/";
}
[FieldDefinition(0, Label = "Rss URL", HelpText = "Enter to URL to an Fanzub compatible RSS feed")]
public String BaseUrl { get; set; }
public ValidationResult Validate()
{
return validator.Validate(this);
}
}
}

View File

@ -249,6 +249,7 @@
<Compile Include="Datastore\Migration\081_move_dot_prefix_to_transmission_category.cs" />
<Compile Include="Datastore\Migration\079_dedupe_tags.cs" />
<Compile Include="Datastore\Migration\070_delay_profile.cs" />
<Compile Include="Datastore\Migration\082_add_fanzub_settings.cs" />
<Compile Include="Datastore\Migration\Framework\MigrationContext.cs" />
<Compile Include="Datastore\Migration\Framework\MigrationController.cs" />
<Compile Include="Datastore\Migration\Framework\MigrationDbFactory.cs" />
@ -456,6 +457,7 @@
<Compile Include="Indexers\Eztv\EztvRequestGenerator.cs" />
<Compile Include="Indexers\Fanzub\Fanzub.cs" />
<Compile Include="Indexers\Fanzub\FanzubRequestGenerator.cs" />
<Compile Include="Indexers\Fanzub\FanzubSettings.cs" />
<Compile Include="Indexers\FetchAndParseRssService.cs" />
<Compile Include="Indexers\IIndexer.cs" />
<Compile Include="Indexers\IIndexerRequestGenerator.cs" />