fixed nzbclub size parsing. Http timeout reduced from 100 to 20 seconds

pull/4/head
kay.one 12 years ago
parent 10cc388600
commit 5dc7e03b8d

@ -80,6 +80,7 @@ namespace NzbDrone.Common
{
var request = (HttpWebRequest)WebRequest.Create(url);
request.UserAgent = _userAgent;
request.Timeout = 20 * 1000;
request.Credentials = credential;
var response = request.GetResponse();

@ -1,39 +1,52 @@
using FluentAssertions;
using System.Collections.Generic;
using FluentAssertions;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Indexers.Newznab;
using NzbDrone.Core.Indexers.NzbClub;
using NzbDrone.Core.Indexers.Nzbx;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Test.Framework;
using NUnit.Framework;
using NzbDrone.Test.Common.Categories;
namespace NzbDrone.Core.Test.IndexerTests.IntegrationTests
{
[IntegrationTest]
public class IndexerIntegrationTests : CoreTest<FetchFeedService>
{
[Test]
public void nzbclub_rss()
[SetUp]
public void SetUp()
{
UseRealHttp();
}
[Test]
public void nzbclub_rss()
{
var indexer = new NzbClub();
var result = Subject.FetchRss(indexer);
result.Should().NotBeEmpty();
result.Should().OnlyContain(c => !string.IsNullOrWhiteSpace(c.Title));
result.Should().OnlyContain(c => !string.IsNullOrWhiteSpace(c.NzbUrl));
ValidateResult(result);
}
//TODO: uncomment these after moving to restsharp for rss
//result.Should().OnlyContain(c => !string.IsNullOrWhiteSpace(c.NzbInfoUrl));
//result.Should().OnlyContain(c => c.Size > 0);
[Test]
public void nzbx_rss()
{
var indexer = new Nzbx();
var result = Subject.FetchRss(indexer);
ValidateResult(result);
}
[Test]
[Explicit("needs newznab api key")]
public void nzbsorg_rss()
{
UseRealHttp();
var indexer = new Newznab();
indexer.Settings = new NewznabSettings
{
@ -55,5 +68,16 @@ namespace NzbDrone.Core.Test.IndexerTests.IntegrationTests
}
private void ValidateResult(IList<ReportInfo> reports)
{
reports.Should().NotBeEmpty();
reports.Should().OnlyContain(c => !string.IsNullOrWhiteSpace(c.Title));
reports.Should().OnlyContain(c => !string.IsNullOrWhiteSpace(c.NzbInfoUrl));
reports.Should().OnlyContain(c => !string.IsNullOrWhiteSpace(c.NzbUrl));
reports.Should().OnlyContain(c => c.Size > 0);
}
}
}

@ -1,28 +0,0 @@
using FluentAssertions;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Indexers.Nzbx;
using NzbDrone.Core.Test.Framework;
using NUnit.Framework;
namespace NzbDrone.Core.Test.IndexerTests.IntegrationTests
{
public class NzbxIntegrationTests : CoreTest<FetchFeedService>
{
[Test]
public void should_be_able_to_fetch_rss()
{
UseRealHttp();
var indexer = new Nzbx();
var result = Subject.FetchRss(indexer);
result.Should().NotBeEmpty();
result.Should().OnlyContain(c => !string.IsNullOrWhiteSpace(c.Title));
result.Should().OnlyContain(c => !string.IsNullOrWhiteSpace(c.NzbInfoUrl));
result.Should().OnlyContain(c => !string.IsNullOrWhiteSpace(c.NzbUrl));
result.Should().OnlyContain(c => c.Size > 0);
}
}
}

@ -137,7 +137,6 @@
<Compile Include="IndexerSearchTests\SearchDefinitionFixture.cs" />
<Compile Include="IndexerTests\BasicRssParserFixture.cs" />
<Compile Include="IndexerTests\IndexerServiceFixture.cs" />
<Compile Include="IndexerTests\IntegrationTests\NzbxIntegrationTests.cs" />
<Compile Include="IndexerTests\IntegrationTests\IndexerIntegrationTests.cs" />
<Compile Include="IndexerTests\ParserTests\NzbxParserFixture.cs" />
<Compile Include="JobTests\JobRepositoryFixture.cs" />

@ -1,18 +1,37 @@
using System;
using System.ServiceModel.Syndication;
using System.Text.RegularExpressions;
using NLog;
using NzbDrone.Core.Parser.Model;
namespace NzbDrone.Core.Indexers.NzbClub
{
public class NzbClubParser : BasicRssParser
{
private static readonly Regex SizeRegex = new Regex(@"(?:Size:)\s(?<size>\d+.\d+\s[g|m]i?[b])", RegexOptions.Compiled | RegexOptions.IgnoreCase);
private readonly Logger logger;
public NzbClubParser()
{
logger = LogManager.GetCurrentClassLogger();
}
protected override ReportInfo PostProcessor(SyndicationItem item, ReportInfo currentResult)
{
if (currentResult != null)
{
var sizeString = Regex.Match(item.Summary.Text, @"Size:\s\d+\s+\w+", RegexOptions.IgnoreCase | RegexOptions.Compiled).Value;
currentResult.Size = GetReportSize(sizeString);
var match = SizeRegex.Match(item.Summary.Text);
if (match.Success && match.Groups["size"].Success)
{
currentResult.Size = GetReportSize(match.Groups["size"].Value);
}
else
{
logger.Warn("Couldn't parse size from {0}", item.Summary.Text);
}
}
return currentResult;

@ -3,22 +3,22 @@
<JSRemoteDebuggerConfigurationSettings>
<option name="engineId" value="chrome" />
<option name="fileUrl" value="http://localhost:8989" />
<mapping local-file="$PROJECT_DIR$/Calendar" url="http://localhost:8989/Calendar" />
<mapping local-file="$PROJECT_DIR$/MainMenuView.js" url="http://localhost:8989/MainMenuView.js" />
<mapping local-file="$PROJECT_DIR$/Settings" url="http://localhost:8989/Settings" />
<mapping local-file="$PROJECT_DIR$/Upcoming" url="http://localhost:8989/Upcoming" />
<mapping local-file="$PROJECT_DIR$/app.js" url="http://localhost:8989/app.js" />
<mapping local-file="$PROJECT_DIR$/Mixins" url="http://localhost:8989/Mixins" />
<mapping local-file="$PROJECT_DIR$/Missing" url="http://localhost:8989/Missing" />
<mapping local-file="$PROJECT_DIR$/Quality" url="http://localhost:8989/Quality" />
<mapping local-file="$PROJECT_DIR$/Config.js" url="http://localhost:8989/Config.js" />
<mapping local-file="$PROJECT_DIR$/Shared" url="http://localhost:8989/Shared" />
<mapping local-file="$PROJECT_DIR$/AddSeries" url="http://localhost:8989/AddSeries" />
<mapping local-file="$PROJECT_DIR$/HeaderView.js" url="http://localhost:8989/HeaderView.js" />
<mapping local-file="$PROJECT_DIR$" url="http://localhost:8989" />
<mapping local-file="$PROJECT_DIR$/Routing.js" url="http://localhost:8989/Routing.js" />
<mapping local-file="$PROJECT_DIR$/Controller.js" url="http://localhost:8989/Controller.js" />
<mapping local-file="$PROJECT_DIR$/Series" url="http://localhost:8989/Series" />
<mapping url="http://localhost:8989/Calendar" local-file="$PROJECT_DIR$/Calendar" />
<mapping url="http://localhost:8989/MainMenuView.js" local-file="$PROJECT_DIR$/MainMenuView.js" />
<mapping url="http://localhost:8989/Settings" local-file="$PROJECT_DIR$/Settings" />
<mapping url="http://localhost:8989/Upcoming" local-file="$PROJECT_DIR$/Upcoming" />
<mapping url="http://localhost:8989/app.js" local-file="$PROJECT_DIR$/app.js" />
<mapping url="http://localhost:8989/Mixins" local-file="$PROJECT_DIR$/Mixins" />
<mapping url="http://localhost:8989/Missing" local-file="$PROJECT_DIR$/Missing" />
<mapping url="http://localhost:8989/Quality" local-file="$PROJECT_DIR$/Quality" />
<mapping url="http://localhost:8989/Config.js" local-file="$PROJECT_DIR$/Config.js" />
<mapping url="http://localhost:8989/Shared" local-file="$PROJECT_DIR$/Shared" />
<mapping url="http://localhost:8989/AddSeries" local-file="$PROJECT_DIR$/AddSeries" />
<mapping url="http://localhost:8989/HeaderView.js" local-file="$PROJECT_DIR$/HeaderView.js" />
<mapping url="http://localhost:8989" local-file="$PROJECT_DIR$" />
<mapping url="http://localhost:8989/Routing.js" local-file="$PROJECT_DIR$/Routing.js" />
<mapping url="http://localhost:8989/Controller.js" local-file="$PROJECT_DIR$/Controller.js" />
<mapping url="http://localhost:8989/Series" local-file="$PROJECT_DIR$/Series" />
</JSRemoteDebuggerConfigurationSettings>
<RunnerSettings RunnerId="JavascriptDebugRunner" />
<ConfigurationWrapper RunnerId="JavascriptDebugRunner" />

@ -3,22 +3,22 @@
<JSRemoteDebuggerConfigurationSettings>
<option name="engineId" value="firefox" />
<option name="fileUrl" value="http://localhost:8989" />
<mapping local-file="$PROJECT_DIR$/Calendar" url="http://localhost:8989/Calendar" />
<mapping local-file="$PROJECT_DIR$/MainMenuView.js" url="http://localhost:8989/MainMenuView.js" />
<mapping local-file="$PROJECT_DIR$/Settings" url="http://localhost:8989/Settings" />
<mapping local-file="$PROJECT_DIR$/Upcoming" url="http://localhost:8989/Upcoming" />
<mapping local-file="$PROJECT_DIR$/app.js" url="http://localhost:8989/app.js" />
<mapping local-file="$PROJECT_DIR$/Mixins" url="http://localhost:8989/Mixins" />
<mapping local-file="$PROJECT_DIR$/Missing" url="http://localhost:8989/Missing" />
<mapping local-file="$PROJECT_DIR$/Config.js" url="http://localhost:8989/Config.js" />
<mapping local-file="$PROJECT_DIR$/Quality" url="http://localhost:8989/Quality" />
<mapping local-file="$PROJECT_DIR$/AddSeries" url="http://localhost:8989/AddSeries" />
<mapping local-file="$PROJECT_DIR$/Shared" url="http://localhost:8989/Shared" />
<mapping local-file="$PROJECT_DIR$/HeaderView.js" url="http://localhost:8989/HeaderView.js" />
<mapping local-file="$PROJECT_DIR$" url="http://localhost:8989" />
<mapping local-file="$PROJECT_DIR$/Routing.js" url="http://localhost:8989/Routing.js" />
<mapping local-file="$PROJECT_DIR$/Controller.js" url="http://localhost:8989/Controller.js" />
<mapping local-file="$PROJECT_DIR$/Series" url="http://localhost:8989/Series" />
<mapping url="http://localhost:8989/Calendar" local-file="$PROJECT_DIR$/Calendar" />
<mapping url="http://localhost:8989/MainMenuView.js" local-file="$PROJECT_DIR$/MainMenuView.js" />
<mapping url="http://localhost:8989/Settings" local-file="$PROJECT_DIR$/Settings" />
<mapping url="http://localhost:8989/Upcoming" local-file="$PROJECT_DIR$/Upcoming" />
<mapping url="http://localhost:8989/app.js" local-file="$PROJECT_DIR$/app.js" />
<mapping url="http://localhost:8989/Mixins" local-file="$PROJECT_DIR$/Mixins" />
<mapping url="http://localhost:8989/Missing" local-file="$PROJECT_DIR$/Missing" />
<mapping url="http://localhost:8989/Config.js" local-file="$PROJECT_DIR$/Config.js" />
<mapping url="http://localhost:8989/Quality" local-file="$PROJECT_DIR$/Quality" />
<mapping url="http://localhost:8989/AddSeries" local-file="$PROJECT_DIR$/AddSeries" />
<mapping url="http://localhost:8989/Shared" local-file="$PROJECT_DIR$/Shared" />
<mapping url="http://localhost:8989/HeaderView.js" local-file="$PROJECT_DIR$/HeaderView.js" />
<mapping url="http://localhost:8989" local-file="$PROJECT_DIR$" />
<mapping url="http://localhost:8989/Routing.js" local-file="$PROJECT_DIR$/Routing.js" />
<mapping url="http://localhost:8989/Controller.js" local-file="$PROJECT_DIR$/Controller.js" />
<mapping url="http://localhost:8989/Series" local-file="$PROJECT_DIR$/Series" />
</JSRemoteDebuggerConfigurationSettings>
<RunnerSettings RunnerId="JavascriptDebugRunner" />
<ConfigurationWrapper RunnerId="JavascriptDebugRunner" />

@ -19,10 +19,10 @@ define([
columns: [
{
name : 'age',
label : 'Age',
name : 'indexer',
label : 'Indexer',
sortable: true,
cell : Backgrid.IntegerCell
cell : Backgrid.StringCell
},
{
name : 'size',

Loading…
Cancel
Save