New: Fanzub url can now be modified (to be used only with alternative sites implementing the same api)

pull/6/head
Taloth Saldono 10 years ago
parent 8b1e0f68dd
commit 4036654f3f

@ -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'");
}
}
}

@ -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()

@ -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())
{

@ -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);
}
}
}

@ -248,6 +248,7 @@
<Compile Include="Datastore\Migration\077_add_add_options_to_series.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" />
@ -455,6 +456,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" />

Loading…
Cancel
Save