mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-09 04:22:30 +01:00
New: Added support for newznab indexers using tvdbid for searching.
This commit is contained in:
parent
7af7c2003e
commit
99f452e299
@ -24,7 +24,7 @@ private ParseResource Parse()
|
||||
return null;
|
||||
}
|
||||
|
||||
var remoteEpisode = _parsingService.Map(parsedEpisodeInfo);
|
||||
var remoteEpisode = _parsingService.Map(parsedEpisodeInfo, 0, 0);
|
||||
|
||||
if (remoteEpisode == null)
|
||||
{
|
||||
|
@ -54,7 +54,7 @@ public void Setup()
|
||||
};
|
||||
|
||||
Mocker.GetMock<IParsingService>()
|
||||
.Setup(c => c.Map(It.IsAny<ParsedEpisodeInfo>(), It.IsAny<int>(), It.IsAny<SearchCriteriaBase>()))
|
||||
.Setup(c => c.Map(It.IsAny<ParsedEpisodeInfo>(), It.IsAny<int>(), It.IsAny<int>(), It.IsAny<SearchCriteriaBase>()))
|
||||
.Returns(_remoteEpisode);
|
||||
}
|
||||
|
||||
@ -125,7 +125,7 @@ public void should_not_attempt_to_map_episode_if_not_parsable()
|
||||
|
||||
var results = Subject.GetRssDecision(_reports).ToList();
|
||||
|
||||
Mocker.GetMock<IParsingService>().Verify(c => c.Map(It.IsAny<ParsedEpisodeInfo>(), It.IsAny<int>(), It.IsAny<SearchCriteriaBase>()), Times.Never());
|
||||
Mocker.GetMock<IParsingService>().Verify(c => c.Map(It.IsAny<ParsedEpisodeInfo>(), It.IsAny<int>(), It.IsAny<int>(), It.IsAny<SearchCriteriaBase>()), Times.Never());
|
||||
|
||||
_pass1.Verify(c => c.IsSatisfiedBy(It.IsAny<RemoteEpisode>(), null), Times.Never());
|
||||
_pass2.Verify(c => c.IsSatisfiedBy(It.IsAny<RemoteEpisode>(), null), Times.Never());
|
||||
@ -142,7 +142,7 @@ public void should_not_attempt_to_map_episode_series_title_is_blank()
|
||||
|
||||
var results = Subject.GetRssDecision(_reports).ToList();
|
||||
|
||||
Mocker.GetMock<IParsingService>().Verify(c => c.Map(It.IsAny<ParsedEpisodeInfo>(), It.IsAny<int>(), It.IsAny<SearchCriteriaBase>()), Times.Never());
|
||||
Mocker.GetMock<IParsingService>().Verify(c => c.Map(It.IsAny<ParsedEpisodeInfo>(), It.IsAny<int>(), It.IsAny<int>(), It.IsAny<SearchCriteriaBase>()), Times.Never());
|
||||
|
||||
_pass1.Verify(c => c.IsSatisfiedBy(It.IsAny<RemoteEpisode>(), null), Times.Never());
|
||||
_pass2.Verify(c => c.IsSatisfiedBy(It.IsAny<RemoteEpisode>(), null), Times.Never());
|
||||
@ -170,7 +170,7 @@ public void broken_report_shouldnt_blowup_the_process()
|
||||
{
|
||||
GivenSpecifications(_pass1);
|
||||
|
||||
Mocker.GetMock<IParsingService>().Setup(c => c.Map(It.IsAny<ParsedEpisodeInfo>(), It.IsAny<int>(), It.IsAny<SearchCriteriaBase>()))
|
||||
Mocker.GetMock<IParsingService>().Setup(c => c.Map(It.IsAny<ParsedEpisodeInfo>(), It.IsAny<int>(), It.IsAny<int>(), It.IsAny<SearchCriteriaBase>()))
|
||||
.Throws<TestException>();
|
||||
|
||||
_reports = new List<ReleaseInfo>
|
||||
@ -182,7 +182,7 @@ public void broken_report_shouldnt_blowup_the_process()
|
||||
|
||||
Subject.GetRssDecision(_reports);
|
||||
|
||||
Mocker.GetMock<IParsingService>().Verify(c => c.Map(It.IsAny<ParsedEpisodeInfo>(), It.IsAny<int>(), It.IsAny<SearchCriteriaBase>()), Times.Exactly(_reports.Count));
|
||||
Mocker.GetMock<IParsingService>().Verify(c => c.Map(It.IsAny<ParsedEpisodeInfo>(), It.IsAny<int>(), It.IsAny<int>(), It.IsAny<SearchCriteriaBase>()), Times.Exactly(_reports.Count));
|
||||
|
||||
ExceptionVerification.ExpectedErrors(3);
|
||||
}
|
||||
@ -221,8 +221,8 @@ public void should_only_include_reports_for_requested_episodes()
|
||||
}).ToList();
|
||||
|
||||
Mocker.GetMock<IParsingService>()
|
||||
.Setup(v => v.Map(It.IsAny<ParsedEpisodeInfo>(), It.IsAny<int>(), It.IsAny<SearchCriteriaBase>()))
|
||||
.Returns<ParsedEpisodeInfo, int, SearchCriteriaBase>((p,id,c) =>
|
||||
.Setup(v => v.Map(It.IsAny<ParsedEpisodeInfo>(), It.IsAny<int>(), It.IsAny<int>(), It.IsAny<SearchCriteriaBase>()))
|
||||
.Returns<ParsedEpisodeInfo, int, int, SearchCriteriaBase>((p,tvdbid,tvrageid,c) =>
|
||||
new RemoteEpisode
|
||||
{
|
||||
DownloadAllowed = true,
|
||||
|
@ -30,7 +30,7 @@ public void SetupBase()
|
||||
.Returns(30);
|
||||
|
||||
Mocker.GetMock<IParsingService>()
|
||||
.Setup(s => s.Map(It.IsAny<ParsedEpisodeInfo>(), It.IsAny<int>(), (SearchCriteriaBase)null))
|
||||
.Setup(s => s.Map(It.IsAny<ParsedEpisodeInfo>(), It.IsAny<int>(), It.IsAny<int>(), (SearchCriteriaBase)null))
|
||||
.Returns(() => CreateRemoteEpisode());
|
||||
|
||||
Mocker.GetMock<IHttpClient>()
|
||||
|
@ -51,6 +51,7 @@ public void should_parse_recent_feed_from_BroadcastheNet()
|
||||
torrentInfo.PublishDate.Should().Be(DateTime.Parse("2014/09/16 21:15:33"));
|
||||
torrentInfo.Size.Should().Be(505099926);
|
||||
torrentInfo.InfoHash.Should().Be("123");
|
||||
torrentInfo.TvdbId.Should().Be(71998);
|
||||
torrentInfo.TvRageId.Should().Be(4055);
|
||||
torrentInfo.MagnetUrl.Should().BeNullOrEmpty();
|
||||
torrentInfo.Peers.Should().Be(40+9);
|
||||
|
@ -6,6 +6,7 @@
|
||||
using NzbDrone.Common.Http;
|
||||
using NzbDrone.Core.Indexers;
|
||||
using NzbDrone.Core.Indexers.Newznab;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Test.IndexerTests.NewznabTests
|
||||
@ -26,6 +27,10 @@ public void Setup()
|
||||
Categories = new int[] { 1 }
|
||||
}
|
||||
};
|
||||
|
||||
Mocker.GetMock<INewznabCapabilitiesProvider>()
|
||||
.Setup(v => v.GetCapabilities(It.IsAny<NewznabSettings>()))
|
||||
.Returns(new NewznabCapabilities());
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Indexers.Newznab;
|
||||
using NzbDrone.Core.IndexerSearch.Definitions;
|
||||
@ -11,7 +12,9 @@ namespace NzbDrone.Core.Test.IndexerTests.NewznabTests
|
||||
{
|
||||
public class NewznabRequestGeneratorFixture : CoreTest<NewznabRequestGenerator>
|
||||
{
|
||||
AnimeEpisodeSearchCriteria _animeSearchCriteria;
|
||||
private SingleEpisodeSearchCriteria _singleEpisodeSearchCriteria;
|
||||
private AnimeEpisodeSearchCriteria _animeSearchCriteria;
|
||||
private NewznabCapabilities _capabilities;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
@ -24,11 +27,25 @@ public void SetUp()
|
||||
ApiKey = "abcd",
|
||||
};
|
||||
|
||||
_singleEpisodeSearchCriteria = new SingleEpisodeSearchCriteria
|
||||
{
|
||||
Series = new Tv.Series { TvRageId = 10, TvdbId = 20 },
|
||||
SceneTitles = new List<string> { "Monkey Island" },
|
||||
SeasonNumber = 1,
|
||||
EpisodeNumber = 2
|
||||
};
|
||||
|
||||
_animeSearchCriteria = new AnimeEpisodeSearchCriteria()
|
||||
{
|
||||
SceneTitles = new List<string>() { "Monkey+Island" },
|
||||
AbsoluteEpisodeNumber = 100
|
||||
};
|
||||
|
||||
_capabilities = new NewznabCapabilities();
|
||||
|
||||
Mocker.GetMock<INewznabCapabilitiesProvider>()
|
||||
.Setup(v => v.GetCapabilities(It.IsAny<NewznabSettings>()))
|
||||
.Returns(_capabilities);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -106,5 +123,73 @@ public void should_not_get_unlimited_pages()
|
||||
|
||||
pages.Count.Should().BeLessThan(500);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_search_by_rid_if_not_supported()
|
||||
{
|
||||
_capabilities.SupportedTvSearchParameters = new[] { "q", "season", "ep" };
|
||||
|
||||
var results = Subject.GetSearchRequests(_singleEpisodeSearchCriteria);
|
||||
|
||||
results.Should().HaveCount(1);
|
||||
|
||||
var page = results.First().First();
|
||||
|
||||
page.Url.Query.Should().NotContain("rid=10");
|
||||
page.Url.Query.Should().Contain("q=Monkey");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_search_by_rid_if_supported()
|
||||
{
|
||||
var results = Subject.GetSearchRequests(_singleEpisodeSearchCriteria);
|
||||
results.Should().HaveCount(1);
|
||||
|
||||
var page = results.First().First();
|
||||
|
||||
page.Url.Query.Should().Contain("rid=10");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_search_by_tvdbid_if_not_supported()
|
||||
{
|
||||
_capabilities.SupportedTvSearchParameters = new[] { "q", "season", "ep" };
|
||||
|
||||
var results = Subject.GetSearchRequests(_singleEpisodeSearchCriteria);
|
||||
|
||||
results.Should().HaveCount(1);
|
||||
|
||||
var page = results.First().First();
|
||||
|
||||
page.Url.Query.Should().NotContain("rid=10");
|
||||
page.Url.Query.Should().Contain("q=Monkey");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_search_by_tvdbid_if_supported()
|
||||
{
|
||||
_capabilities.SupportedTvSearchParameters = new[] { "q", "tvdbid", "season", "ep" };
|
||||
|
||||
var results = Subject.GetSearchRequests(_singleEpisodeSearchCriteria);
|
||||
results.Should().HaveCount(1);
|
||||
|
||||
var page = results.First().First();
|
||||
|
||||
page.Url.Query.Should().Contain("tvdbid=20");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_prefer_search_by_tvdbid_if_rid_supported()
|
||||
{
|
||||
_capabilities.SupportedTvSearchParameters = new[] { "q", "tvdbid", "rid", "season", "ep" };
|
||||
|
||||
var results = Subject.GetSearchRequests(_singleEpisodeSearchCriteria);
|
||||
results.Should().HaveCount(1);
|
||||
|
||||
var page = results.First().First();
|
||||
|
||||
page.Url.Query.Should().Contain("tvdbid=20");
|
||||
page.Url.Query.Should().NotContain("rid=10");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -56,6 +56,7 @@ public void should_parse_recent_feed_from_Rarbg()
|
||||
torrentInfo.MagnetUrl.Should().BeNull();
|
||||
torrentInfo.Peers.Should().Be(304 + 200);
|
||||
torrentInfo.Seeders.Should().Be(304);
|
||||
torrentInfo.TvdbId.Should().Be(268156);
|
||||
torrentInfo.TvRageId.Should().Be(35197);
|
||||
}
|
||||
|
||||
|
@ -51,6 +51,7 @@ public void should_parse_recent_feed_from_TitansOfTv()
|
||||
torrentInfo.PublishDate.Should().Be(DateTime.Parse("2015-06-25 04:13:44"));
|
||||
torrentInfo.Size.Should().Be(435402993);
|
||||
torrentInfo.InfoHash.Should().BeNullOrEmpty();
|
||||
torrentInfo.TvdbId.Should().Be(0);
|
||||
torrentInfo.TvRageId.Should().Be(0);
|
||||
torrentInfo.MagnetUrl.Should().BeNullOrEmpty();
|
||||
torrentInfo.Peers.Should().Be(2+5);
|
||||
|
@ -5,6 +5,7 @@
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common.Http;
|
||||
using NzbDrone.Core.Indexers;
|
||||
using NzbDrone.Core.Indexers.Newznab;
|
||||
using NzbDrone.Core.Indexers.Torznab;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
@ -27,9 +28,9 @@ public void Setup()
|
||||
}
|
||||
};
|
||||
|
||||
Mocker.GetMock<ITorznabCapabilitiesProvider>()
|
||||
.Setup(v => v.GetCapabilities(It.IsAny<TorznabSettings>()))
|
||||
.Returns(new TorznabCapabilities());
|
||||
Mocker.GetMock<INewznabCapabilitiesProvider>()
|
||||
.Setup(v => v.GetCapabilities(It.IsAny<NewznabSettings>()))
|
||||
.Returns(new NewznabCapabilities());
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -56,6 +57,7 @@ public void should_parse_recent_feed_from_torznab_hdaccess_net()
|
||||
releaseInfo.Indexer.Should().Be(Subject.Definition.Name);
|
||||
releaseInfo.PublishDate.Should().Be(DateTime.Parse("2015/03/14 21:10:42"));
|
||||
releaseInfo.Size.Should().Be(2538463390);
|
||||
releaseInfo.TvdbId.Should().Be(273181);
|
||||
releaseInfo.TvRageId.Should().Be(37780);
|
||||
releaseInfo.InfoHash.Should().Be("63e07ff523710ca268567dad344ce1e0e6b7e8a3");
|
||||
releaseInfo.Seeders.Should().Be(7);
|
||||
|
@ -1,154 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Indexers.Torznab;
|
||||
using NzbDrone.Core.IndexerSearch.Definitions;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Test.IndexerTests.TorznabTests
|
||||
{
|
||||
public class TorznabRequestGeneratorFixture : CoreTest<TorznabRequestGenerator>
|
||||
{
|
||||
private SingleEpisodeSearchCriteria _singleEpisodeSearchCriteria;
|
||||
private AnimeEpisodeSearchCriteria _animeSearchCriteria;
|
||||
private TorznabCapabilities _capabilities;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
Subject.Settings = new TorznabSettings()
|
||||
{
|
||||
Url = "http://127.0.0.1:1234/",
|
||||
Categories = new [] { 1, 2 },
|
||||
AnimeCategories = new [] { 3, 4 },
|
||||
ApiKey = "abcd",
|
||||
EnableRageIDLookup = true
|
||||
};
|
||||
|
||||
_singleEpisodeSearchCriteria = new SingleEpisodeSearchCriteria
|
||||
{
|
||||
Series = new Tv.Series { TvRageId = 10 },
|
||||
SceneTitles = new List<string> { "Monkey Island" },
|
||||
SeasonNumber = 1,
|
||||
EpisodeNumber = 2
|
||||
};
|
||||
|
||||
_animeSearchCriteria = new AnimeEpisodeSearchCriteria()
|
||||
{
|
||||
SceneTitles = new List<String>() { "Monkey+Island" },
|
||||
AbsoluteEpisodeNumber = 100
|
||||
};
|
||||
|
||||
_capabilities = new TorznabCapabilities();
|
||||
|
||||
Mocker.GetMock<ITorznabCapabilitiesProvider>()
|
||||
.Setup(v => v.GetCapabilities(It.IsAny<TorznabSettings>()))
|
||||
.Returns(_capabilities);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_use_all_categories_for_feed()
|
||||
{
|
||||
var results = Subject.GetRecentRequests();
|
||||
|
||||
results.Should().HaveCount(1);
|
||||
|
||||
var page = results.First().First();
|
||||
|
||||
page.Url.Query.Should().Contain("&cat=1,2,3,4&");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_have_duplicate_categories()
|
||||
{
|
||||
Subject.Settings.Categories = new[] { 1, 2, 3 };
|
||||
|
||||
var results = Subject.GetRecentRequests();
|
||||
|
||||
results.Should().HaveCount(1);
|
||||
|
||||
var page = results.First().First();
|
||||
|
||||
page.Url.Query.Should().Contain("&cat=1,2,3,4&");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_use_only_anime_categories_for_anime_search()
|
||||
{
|
||||
var results = Subject.GetSearchRequests(_animeSearchCriteria);
|
||||
|
||||
results.Should().HaveCount(1);
|
||||
|
||||
var page = results.First().First();
|
||||
|
||||
page.Url.Query.Should().Contain("&cat=3,4&");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_use_mode_search_for_anime()
|
||||
{
|
||||
var results = Subject.GetSearchRequests(_animeSearchCriteria);
|
||||
|
||||
results.Should().HaveCount(1);
|
||||
|
||||
var page = results.First().First();
|
||||
|
||||
page.Url.Query.Should().Contain("?t=search&");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_subsequent_pages()
|
||||
{
|
||||
var results = Subject.GetSearchRequests(_animeSearchCriteria);
|
||||
|
||||
results.Should().HaveCount(1);
|
||||
|
||||
var pages = results.First().Take(3).ToList();
|
||||
|
||||
pages[0].Url.Query.Should().Contain("&offset=0&");
|
||||
pages[1].Url.Query.Should().Contain("&offset=100&");
|
||||
pages[2].Url.Query.Should().Contain("&offset=200&");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_get_unlimited_pages()
|
||||
{
|
||||
var results = Subject.GetSearchRequests(_animeSearchCriteria);
|
||||
|
||||
results.Should().HaveCount(1);
|
||||
|
||||
var pages = results.First().Take(500).ToList();
|
||||
|
||||
pages.Count.Should().BeLessThan(500);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_search_by_rid_if_not_supported()
|
||||
{
|
||||
_capabilities.SupportedTvSearchParameters = new[] { "q", "season", "ep" };
|
||||
|
||||
var results = Subject.GetSearchRequests(_singleEpisodeSearchCriteria);
|
||||
|
||||
results.Should().HaveCount(1);
|
||||
|
||||
var page = results.First().First();
|
||||
|
||||
page.Url.Query.Should().NotContain("rid=10");
|
||||
page.Url.Query.Should().Contain("q=Monkey");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_search_by_rid_if_supported()
|
||||
{
|
||||
var results = Subject.GetSearchRequests(_singleEpisodeSearchCriteria);
|
||||
results.Should().HaveCount(1);
|
||||
|
||||
var page = results.First().First();
|
||||
|
||||
page.Url.Query.Should().Contain("rid=10");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,58 +0,0 @@
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Indexers.Torznab;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Test.IndexerTests.TorznabTests
|
||||
{
|
||||
public class TorznabSettingFixture : CoreTest
|
||||
{
|
||||
|
||||
[TestCase("http://hdaccess.net")]
|
||||
public void requires_apikey(string url)
|
||||
{
|
||||
var setting = new TorznabSettings()
|
||||
{
|
||||
ApiKey = "",
|
||||
Url = url
|
||||
};
|
||||
|
||||
|
||||
setting.Validate().IsValid.Should().BeFalse();
|
||||
setting.Validate().Errors.Should().Contain(c => c.PropertyName == "ApiKey");
|
||||
|
||||
}
|
||||
|
||||
[TestCase("")]
|
||||
[TestCase(" ")]
|
||||
[TestCase(null)]
|
||||
public void invalid_url_should_not_apikey(string url)
|
||||
{
|
||||
var setting = new TorznabSettings
|
||||
{
|
||||
ApiKey = "",
|
||||
Url = url
|
||||
};
|
||||
|
||||
|
||||
setting.Validate().IsValid.Should().BeFalse();
|
||||
setting.Validate().Errors.Should().NotContain(c => c.PropertyName == "ApiKey");
|
||||
setting.Validate().Errors.Should().Contain(c => c.PropertyName == "Url");
|
||||
|
||||
}
|
||||
|
||||
|
||||
[TestCase("http://myfancytracker.net")]
|
||||
public void doesnt_requires_apikey(string url)
|
||||
{
|
||||
var setting = new TorznabSettings()
|
||||
{
|
||||
ApiKey = "",
|
||||
Url = url
|
||||
};
|
||||
|
||||
|
||||
setting.Validate().IsValid.Should().BeTrue();
|
||||
}
|
||||
}
|
||||
}
|
@ -226,8 +226,6 @@
|
||||
<Compile Include="IndexerTests\TorrentRssIndexerTests\TorrentRssParserFactoryFixture.cs" />
|
||||
<Compile Include="IndexerTests\TorrentRssIndexerTests\TorrentRssSettingsDetectorFixture.cs" />
|
||||
<Compile Include="IndexerTests\TorznabTests\TorznabFixture.cs" />
|
||||
<Compile Include="IndexerTests\TorznabTests\TorznabRequestGeneratorFixture.cs" />
|
||||
<Compile Include="IndexerTests\TorznabTests\TorznabSettingFixture.cs" />
|
||||
<Compile Include="IndexerTests\NewznabTests\NewznabFixture.cs" />
|
||||
<Compile Include="IndexerTests\NewznabTests\NewznabRequestGeneratorFixture.cs" />
|
||||
<Compile Include="IndexerTests\NewznabTests\NewznabSettingFixture.cs" />
|
||||
|
@ -82,7 +82,7 @@ public void should_get_daily_episode_episode_when_search_criteria_is_null()
|
||||
GivenDailySeries();
|
||||
GivenDailyParseResult();
|
||||
|
||||
Subject.Map(_parsedEpisodeInfo, _series.TvRageId);
|
||||
Subject.Map(_parsedEpisodeInfo, _series.TvdbId, _series.TvRageId);
|
||||
|
||||
Mocker.GetMock<IEpisodeService>()
|
||||
.Verify(v => v.FindEpisode(It.IsAny<int>(), It.IsAny<string>()), Times.Once());
|
||||
@ -94,7 +94,7 @@ public void should_use_search_criteria_episode_when_it_matches_daily()
|
||||
GivenDailySeries();
|
||||
GivenDailyParseResult();
|
||||
|
||||
Subject.Map(_parsedEpisodeInfo, _series.TvRageId, _singleEpisodeSearchCriteria);
|
||||
Subject.Map(_parsedEpisodeInfo, _series.TvdbId, _series.TvRageId, _singleEpisodeSearchCriteria);
|
||||
|
||||
Mocker.GetMock<IEpisodeService>()
|
||||
.Verify(v => v.FindEpisode(It.IsAny<int>(), It.IsAny<string>()), Times.Never());
|
||||
@ -106,7 +106,7 @@ public void should_fallback_to_daily_episode_lookup_when_search_criteria_episode
|
||||
GivenDailySeries();
|
||||
_parsedEpisodeInfo.AirDate = DateTime.Today.AddDays(-5).ToString(Episode.AIR_DATE_FORMAT); ;
|
||||
|
||||
Subject.Map(_parsedEpisodeInfo, _series.TvRageId, _singleEpisodeSearchCriteria);
|
||||
Subject.Map(_parsedEpisodeInfo, _series.TvdbId, _series.TvRageId, _singleEpisodeSearchCriteria);
|
||||
|
||||
Mocker.GetMock<IEpisodeService>()
|
||||
.Verify(v => v.FindEpisode(It.IsAny<int>(), It.IsAny<string>()), Times.Once());
|
||||
@ -117,7 +117,7 @@ public void should_use_search_criteria_episode_when_it_matches_absolute()
|
||||
{
|
||||
GivenAbsoluteNumberingSeries();
|
||||
|
||||
Subject.Map(_parsedEpisodeInfo, _series.TvRageId, _singleEpisodeSearchCriteria);
|
||||
Subject.Map(_parsedEpisodeInfo, _series.TvdbId, _series.TvRageId, _singleEpisodeSearchCriteria);
|
||||
|
||||
Mocker.GetMock<IEpisodeService>()
|
||||
.Verify(v => v.FindEpisode(It.IsAny<int>(), It.IsAny<string>()), Times.Never());
|
||||
@ -128,7 +128,7 @@ public void should_use_scene_numbering_when_series_uses_scene_numbering()
|
||||
{
|
||||
GivenSceneNumberingSeries();
|
||||
|
||||
Subject.Map(_parsedEpisodeInfo, _series.TvRageId);
|
||||
Subject.Map(_parsedEpisodeInfo, _series.TvdbId, _series.TvRageId);
|
||||
|
||||
Mocker.GetMock<IEpisodeService>()
|
||||
.Verify(v => v.FindEpisodesBySceneNumbering(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()), Times.Once());
|
||||
@ -139,7 +139,7 @@ public void should_match_search_criteria_by_scene_numbering()
|
||||
{
|
||||
GivenSceneNumberingSeries();
|
||||
|
||||
Subject.Map(_parsedEpisodeInfo, _series.TvRageId, _singleEpisodeSearchCriteria);
|
||||
Subject.Map(_parsedEpisodeInfo, _series.TvdbId, _series.TvRageId, _singleEpisodeSearchCriteria);
|
||||
|
||||
Mocker.GetMock<IEpisodeService>()
|
||||
.Verify(v => v.FindEpisodesBySceneNumbering(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()), Times.Never());
|
||||
@ -151,7 +151,7 @@ public void should_fallback_to_findEpisode_when_search_criteria_match_fails_for_
|
||||
GivenSceneNumberingSeries();
|
||||
_episodes.First().SceneEpisodeNumber = 10;
|
||||
|
||||
Subject.Map(_parsedEpisodeInfo, _series.TvRageId, _singleEpisodeSearchCriteria);
|
||||
Subject.Map(_parsedEpisodeInfo, _series.TvdbId, _series.TvRageId, _singleEpisodeSearchCriteria);
|
||||
|
||||
Mocker.GetMock<IEpisodeService>()
|
||||
.Verify(v => v.FindEpisodesBySceneNumbering(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()), Times.Once());
|
||||
@ -160,7 +160,7 @@ public void should_fallback_to_findEpisode_when_search_criteria_match_fails_for_
|
||||
[Test]
|
||||
public void should_find_episode()
|
||||
{
|
||||
Subject.Map(_parsedEpisodeInfo, _series.TvRageId);
|
||||
Subject.Map(_parsedEpisodeInfo, _series.TvdbId, _series.TvRageId);
|
||||
|
||||
Mocker.GetMock<IEpisodeService>()
|
||||
.Verify(v => v.FindEpisode(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()), Times.Once());
|
||||
@ -169,7 +169,7 @@ public void should_find_episode()
|
||||
[Test]
|
||||
public void should_match_episode_with_search_criteria()
|
||||
{
|
||||
Subject.Map(_parsedEpisodeInfo, _series.TvRageId, _singleEpisodeSearchCriteria);
|
||||
Subject.Map(_parsedEpisodeInfo, _series.TvdbId, _series.TvRageId, _singleEpisodeSearchCriteria);
|
||||
|
||||
Mocker.GetMock<IEpisodeService>()
|
||||
.Verify(v => v.FindEpisode(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()), Times.Never());
|
||||
@ -180,7 +180,7 @@ public void should_fallback_to_findEpisode_when_search_criteria_match_fails()
|
||||
{
|
||||
_episodes.First().EpisodeNumber = 10;
|
||||
|
||||
Subject.Map(_parsedEpisodeInfo, _series.TvRageId, _singleEpisodeSearchCriteria);
|
||||
Subject.Map(_parsedEpisodeInfo, _series.TvdbId, _series.TvRageId, _singleEpisodeSearchCriteria);
|
||||
|
||||
Mocker.GetMock<IEpisodeService>()
|
||||
.Verify(v => v.FindEpisode(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>()), Times.Once());
|
||||
|
@ -59,6 +59,13 @@ private void GivenMatchBySeriesTitle()
|
||||
.Returns(_series);
|
||||
}
|
||||
|
||||
private void GivenMatchByTvdbId()
|
||||
{
|
||||
Mocker.GetMock<ISeriesService>()
|
||||
.Setup(s => s.FindByTvdbId(It.IsAny<Int32>()))
|
||||
.Returns(_series);
|
||||
}
|
||||
|
||||
private void GivenMatchByTvRageId()
|
||||
{
|
||||
Mocker.GetMock<ISeriesService>()
|
||||
@ -76,18 +83,29 @@ public void should_lookup_series_by_name()
|
||||
{
|
||||
GivenMatchBySeriesTitle();
|
||||
|
||||
Subject.Map(_parsedEpisodeInfo, _series.TvRageId);
|
||||
Subject.Map(_parsedEpisodeInfo, _series.TvdbId, _series.TvRageId);
|
||||
|
||||
Mocker.GetMock<ISeriesService>()
|
||||
.Verify(v => v.FindByTitle(It.IsAny<string>()), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_use_tvdbid_when_series_title_lookup_fails()
|
||||
{
|
||||
GivenMatchByTvdbId();
|
||||
|
||||
Subject.Map(_parsedEpisodeInfo, _series.TvdbId, _series.TvRageId);
|
||||
|
||||
Mocker.GetMock<ISeriesService>()
|
||||
.Verify(v => v.FindByTvdbId(It.IsAny<Int32>()), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_use_tvrageid_when_series_title_lookup_fails()
|
||||
{
|
||||
GivenMatchByTvRageId();
|
||||
|
||||
Subject.Map(_parsedEpisodeInfo, _series.TvRageId);
|
||||
Subject.Map(_parsedEpisodeInfo, 0, _series.TvRageId);
|
||||
|
||||
Mocker.GetMock<ISeriesService>()
|
||||
.Verify(v => v.FindByTvRageId(It.IsAny<int>()), Times.Once());
|
||||
@ -102,7 +120,7 @@ public void should_not_use_tvrageid_when_scene_naming_exception_exists()
|
||||
.Setup(v => v.FindTvdbId(It.IsAny<string>()))
|
||||
.Returns(10);
|
||||
|
||||
var result = Subject.Map(_parsedEpisodeInfo, _series.TvRageId);
|
||||
var result = Subject.Map(_parsedEpisodeInfo, _series.TvdbId, _series.TvRageId);
|
||||
|
||||
Mocker.GetMock<ISeriesService>()
|
||||
.Verify(v => v.FindByTvRageId(It.IsAny<int>()), Times.Never());
|
||||
@ -115,7 +133,7 @@ public void should_use_search_criteria_series_title()
|
||||
{
|
||||
GivenMatchBySeriesTitle();
|
||||
|
||||
Subject.Map(_parsedEpisodeInfo, _series.TvRageId, _singleEpisodeSearchCriteria);
|
||||
Subject.Map(_parsedEpisodeInfo, _series.TvdbId, _series.TvRageId, _singleEpisodeSearchCriteria);
|
||||
|
||||
Mocker.GetMock<ISeriesService>()
|
||||
.Verify(v => v.FindByTitle(It.IsAny<string>()), Times.Never());
|
||||
@ -126,18 +144,29 @@ public void should_FindByTitle_when_search_criteria_matching_fails()
|
||||
{
|
||||
GivenParseResultSeriesDoesntMatchSearchCriteria();
|
||||
|
||||
Subject.Map(_parsedEpisodeInfo, 10, _singleEpisodeSearchCriteria);
|
||||
Subject.Map(_parsedEpisodeInfo, 10, 10, _singleEpisodeSearchCriteria);
|
||||
|
||||
Mocker.GetMock<ISeriesService>()
|
||||
.Verify(v => v.FindByTitle(It.IsAny<string>()), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_FindByTvdbId_when_search_criteria_and_FindByTitle_matching_fails()
|
||||
{
|
||||
GivenParseResultSeriesDoesntMatchSearchCriteria();
|
||||
|
||||
Subject.Map(_parsedEpisodeInfo, 10, 10, _singleEpisodeSearchCriteria);
|
||||
|
||||
Mocker.GetMock<ISeriesService>()
|
||||
.Verify(v => v.FindByTvdbId(It.IsAny<Int32>()), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_FindByTvRageId_when_search_criteria_and_FindByTitle_matching_fails()
|
||||
{
|
||||
GivenParseResultSeriesDoesntMatchSearchCriteria();
|
||||
|
||||
Subject.Map(_parsedEpisodeInfo, 10, _singleEpisodeSearchCriteria);
|
||||
Subject.Map(_parsedEpisodeInfo, 10, 10, _singleEpisodeSearchCriteria);
|
||||
|
||||
Mocker.GetMock<ISeriesService>()
|
||||
.Verify(v => v.FindByTvRageId(It.IsAny<int>()), Times.Once());
|
||||
@ -150,7 +179,7 @@ public void should_use_tvdbid_matching_when_alias_is_found()
|
||||
.Setup(s => s.FindTvdbId(It.IsAny<string>()))
|
||||
.Returns(_series.TvdbId);
|
||||
|
||||
Subject.Map(_parsedEpisodeInfo, _series.TvRageId, _singleEpisodeSearchCriteria);
|
||||
Subject.Map(_parsedEpisodeInfo, _series.TvdbId, _series.TvRageId, _singleEpisodeSearchCriteria);
|
||||
|
||||
Mocker.GetMock<ISeriesService>()
|
||||
.Verify(v => v.FindByTitle(It.IsAny<string>()), Times.Never());
|
||||
@ -161,7 +190,7 @@ public void should_use_tvrageid_match_from_search_criteria_when_title_match_fail
|
||||
{
|
||||
GivenParseResultSeriesDoesntMatchSearchCriteria();
|
||||
|
||||
Subject.Map(_parsedEpisodeInfo, _series.TvRageId, _singleEpisodeSearchCriteria);
|
||||
Subject.Map(_parsedEpisodeInfo, _series.TvdbId, _series.TvRageId, _singleEpisodeSearchCriteria);
|
||||
|
||||
Mocker.GetMock<ISeriesService>()
|
||||
.Verify(v => v.FindByTitle(It.IsAny<string>()), Times.Never());
|
||||
|
@ -65,7 +65,7 @@ private IEnumerable<DownloadDecision> GetDecisions(List<ReleaseInfo> reports, Se
|
||||
|
||||
if (parsedEpisodeInfo == null || parsedEpisodeInfo.IsPossibleSpecialEpisode)
|
||||
{
|
||||
var specialEpisodeInfo = _parsingService.ParseSpecialEpisodeTitle(report.Title, report.TvRageId, searchCriteria);
|
||||
var specialEpisodeInfo = _parsingService.ParseSpecialEpisodeTitle(report.Title, report.TvdbId, report.TvRageId, searchCriteria);
|
||||
|
||||
if (specialEpisodeInfo != null)
|
||||
{
|
||||
@ -75,7 +75,7 @@ private IEnumerable<DownloadDecision> GetDecisions(List<ReleaseInfo> reports, Se
|
||||
|
||||
if (parsedEpisodeInfo != null && !parsedEpisodeInfo.SeriesTitle.IsNullOrWhiteSpace())
|
||||
{
|
||||
var remoteEpisode = _parsingService.Map(parsedEpisodeInfo, report.TvRageId, searchCriteria);
|
||||
var remoteEpisode = _parsingService.Map(parsedEpisodeInfo, report.TvdbId, report.TvRageId, searchCriteria);
|
||||
remoteEpisode.Release = report;
|
||||
|
||||
if (remoteEpisode.Series != null)
|
||||
|
@ -62,7 +62,7 @@ public TrackedDownload TrackDownload(DownloadClientDefinition downloadClient, Do
|
||||
|
||||
if (parsedEpisodeInfo != null)
|
||||
{
|
||||
trackedDownload.RemoteEpisode = _parsingService.Map(parsedEpisodeInfo);
|
||||
trackedDownload.RemoteEpisode = _parsingService.Map(parsedEpisodeInfo, 0, 0);
|
||||
}
|
||||
|
||||
if (historyItems.Any())
|
||||
|
@ -151,6 +151,7 @@ public void Handle(EpisodeGrabbedEvent message)
|
||||
history.Data.Add("Size", message.Episode.Release.Size.ToString());
|
||||
history.Data.Add("DownloadUrl", message.Episode.Release.DownloadUrl);
|
||||
history.Data.Add("Guid", message.Episode.Release.Guid);
|
||||
history.Data.Add("TvdbId", message.Episode.Release.TvdbId.ToString());
|
||||
history.Data.Add("TvRageId", message.Episode.Release.TvRageId.ToString());
|
||||
history.Data.Add("Protocol", ((int)message.Episode.Release.DownloadProtocol).ToString());
|
||||
|
||||
|
@ -56,6 +56,10 @@ public IList<ReleaseInfo> ParseResponse(IndexerResponse indexerResponse)
|
||||
torrentInfo.DownloadUrl = RegexProtocol.Replace(torrent.DownloadURL, protocol);
|
||||
torrentInfo.InfoUrl = string.Format("{0}//broadcasthe.net/torrents.php?id={1}&torrentid={2}", protocol, torrent.GroupID, torrent.TorrentID);
|
||||
//torrentInfo.CommentUrl =
|
||||
if (torrent.TvdbID.HasValue)
|
||||
{
|
||||
torrentInfo.TvdbId = torrent.TvdbID.Value;
|
||||
}
|
||||
if (torrent.TvrageID.HasValue)
|
||||
{
|
||||
torrentInfo.TvRageId = torrent.TvrageID.Value;
|
||||
|
@ -1,7 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FluentValidation.Results;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Common.Http;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Parser;
|
||||
@ -11,6 +13,8 @@ namespace NzbDrone.Core.Indexers.Newznab
|
||||
{
|
||||
public class Newznab : HttpIndexerBase<NewznabSettings>
|
||||
{
|
||||
private readonly INewznabCapabilitiesProvider _capabilitiesProvider;
|
||||
|
||||
public override string Name
|
||||
{
|
||||
get
|
||||
@ -24,7 +28,7 @@ public override string Name
|
||||
|
||||
public override IIndexerRequestGenerator GetRequestGenerator()
|
||||
{
|
||||
return new NewznabRequestGenerator()
|
||||
return new NewznabRequestGenerator(_capabilitiesProvider)
|
||||
{
|
||||
PageSize = PageSize,
|
||||
Settings = Settings
|
||||
@ -50,10 +54,10 @@ public override IEnumerable<ProviderDefinition> DefaultDefinitions
|
||||
}
|
||||
}
|
||||
|
||||
public Newznab(IHttpClient httpClient, IIndexerStatusService indexerStatusService, IConfigService configService, IParsingService parsingService, Logger logger)
|
||||
public Newznab(INewznabCapabilitiesProvider capabilitiesProvider, IHttpClient httpClient, IIndexerStatusService indexerStatusService, IConfigService configService, IParsingService parsingService, Logger logger)
|
||||
: base(httpClient, indexerStatusService, configService, parsingService, logger)
|
||||
{
|
||||
|
||||
_capabilitiesProvider = capabilitiesProvider;
|
||||
}
|
||||
|
||||
private IndexerDefinition GetDefinition(string name, NewznabSettings settings)
|
||||
@ -82,5 +86,42 @@ private NewznabSettings GetSettings(string url, params int[] categories)
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
protected override void Test(List<ValidationFailure> failures)
|
||||
{
|
||||
base.Test(failures);
|
||||
|
||||
failures.AddIfNotNull(TestCapabilities());
|
||||
}
|
||||
|
||||
protected virtual ValidationFailure TestCapabilities()
|
||||
{
|
||||
try
|
||||
{
|
||||
var capabilities = _capabilitiesProvider.GetCapabilities(Settings);
|
||||
|
||||
if (capabilities.SupportedSearchParameters != null && capabilities.SupportedSearchParameters.Contains("q"))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (capabilities.SupportedTvSearchParameters != null &&
|
||||
new[] { "q", "tvdbid", "rid" }.Any(v => capabilities.SupportedTvSearchParameters.Contains(v)) &&
|
||||
new[] { "season", "ep" }.All(v => capabilities.SupportedTvSearchParameters.Contains(v)))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new ValidationFailure(string.Empty, "Indexer does not support required search parameters");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.WarnException("Unable to connect to indexer: " + ex.Message, ex);
|
||||
|
||||
return new ValidationFailure(string.Empty, "Unable to connect to indexer, check the log for more details");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
28
src/NzbDrone.Core/Indexers/Newznab/NewznabCapabilities.cs
Normal file
28
src/NzbDrone.Core/Indexers/Newznab/NewznabCapabilities.cs
Normal file
@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NzbDrone.Core.Indexers.Newznab
|
||||
{
|
||||
public class NewznabCapabilities
|
||||
{
|
||||
public string[] SupportedSearchParameters { get; set; }
|
||||
public string[] SupportedTvSearchParameters { get; set; }
|
||||
public List<NewznabCategory> Categories { get; set; }
|
||||
|
||||
public NewznabCapabilities()
|
||||
{
|
||||
SupportedSearchParameters = new[] { "q" };
|
||||
SupportedTvSearchParameters = new[] { "q", "rid", "season", "ep" }; // This should remain 'rid' for older newznab installs.
|
||||
Categories = new List<NewznabCategory>();
|
||||
}
|
||||
}
|
||||
|
||||
public class NewznabCategory
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Description { get; set; }
|
||||
|
||||
public List<NewznabCategory> Subcategories { get; set; }
|
||||
}
|
||||
}
|
@ -7,27 +7,27 @@
|
||||
using NzbDrone.Common.Http;
|
||||
using NzbDrone.Common.Serializer;
|
||||
|
||||
namespace NzbDrone.Core.Indexers.Torznab
|
||||
namespace NzbDrone.Core.Indexers.Newznab
|
||||
{
|
||||
public interface ITorznabCapabilitiesProvider
|
||||
public interface INewznabCapabilitiesProvider
|
||||
{
|
||||
TorznabCapabilities GetCapabilities(TorznabSettings settings);
|
||||
NewznabCapabilities GetCapabilities(NewznabSettings settings);
|
||||
}
|
||||
|
||||
public class TorznabCapabilitiesProvider : ITorznabCapabilitiesProvider
|
||||
public class NewznabCapabilitiesProvider : INewznabCapabilitiesProvider
|
||||
{
|
||||
private readonly ICached<TorznabCapabilities> _capabilitiesCache;
|
||||
private readonly ICached<NewznabCapabilities> _capabilitiesCache;
|
||||
private readonly IHttpClient _httpClient;
|
||||
private readonly Logger _logger;
|
||||
|
||||
public TorznabCapabilitiesProvider(ICacheManager cacheManager, IHttpClient httpClient, Logger logger)
|
||||
public NewznabCapabilitiesProvider(ICacheManager cacheManager, IHttpClient httpClient, Logger logger)
|
||||
{
|
||||
_capabilitiesCache = cacheManager.GetCache<TorznabCapabilities>(GetType());
|
||||
_capabilitiesCache = cacheManager.GetCache<NewznabCapabilities>(GetType());
|
||||
_httpClient = httpClient;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public TorznabCapabilities GetCapabilities(TorznabSettings indexerSettings)
|
||||
public NewznabCapabilities GetCapabilities(NewznabSettings indexerSettings)
|
||||
{
|
||||
var key = indexerSettings.ToJson();
|
||||
var capabilities = _capabilitiesCache.Get(key, () => FetchCapabilities(indexerSettings), TimeSpan.FromDays(7));
|
||||
@ -35,9 +35,9 @@ public TorznabCapabilities GetCapabilities(TorznabSettings indexerSettings)
|
||||
return capabilities;
|
||||
}
|
||||
|
||||
private TorznabCapabilities FetchCapabilities(TorznabSettings indexerSettings)
|
||||
private NewznabCapabilities FetchCapabilities(NewznabSettings indexerSettings)
|
||||
{
|
||||
var capabilities = new TorznabCapabilities();
|
||||
var capabilities = new NewznabCapabilities();
|
||||
|
||||
var url = string.Format("{0}/api?t=caps", indexerSettings.Url.TrimEnd('/'));
|
||||
|
||||
@ -62,9 +62,9 @@ private TorznabCapabilities FetchCapabilities(TorznabSettings indexerSettings)
|
||||
return capabilities;
|
||||
}
|
||||
|
||||
private TorznabCapabilities ParseCapabilities(HttpResponse response)
|
||||
private NewznabCapabilities ParseCapabilities(HttpResponse response)
|
||||
{
|
||||
var capabilities = new TorznabCapabilities();
|
||||
var capabilities = new NewznabCapabilities();
|
||||
|
||||
var xmlRoot = XDocument.Parse(response.Content).Element("caps");
|
||||
|
||||
@ -97,17 +97,17 @@ private TorznabCapabilities ParseCapabilities(HttpResponse response)
|
||||
{
|
||||
foreach (var xmlCategory in xmlCategories.Elements("category"))
|
||||
{
|
||||
var cat = new TorznabCategory
|
||||
var cat = new NewznabCategory
|
||||
{
|
||||
Id = int.Parse(xmlCategory.Attribute("id").Value),
|
||||
Name = xmlCategory.Attribute("name").Value,
|
||||
Description = xmlCategory.Attribute("description") != null ? xmlCategory.Attribute("description").Value : string.Empty,
|
||||
Subcategories = new List<TorznabCategory>()
|
||||
Subcategories = new List<NewznabCategory>()
|
||||
};
|
||||
|
||||
foreach (var xmlSubcat in xmlCategory.Elements("subcat"))
|
||||
{
|
||||
cat.Subcategories.Add(new TorznabCategory
|
||||
cat.Subcategories.Add(new NewznabCategory
|
||||
{
|
||||
Id = int.Parse(xmlSubcat.Attribute("id").Value),
|
||||
Name = xmlSubcat.Attribute("name").Value,
|
@ -9,21 +9,79 @@ namespace NzbDrone.Core.Indexers.Newznab
|
||||
{
|
||||
public class NewznabRequestGenerator : IIndexerRequestGenerator
|
||||
{
|
||||
public Int32 MaxPages { get; set; }
|
||||
public Int32 PageSize { get; set; }
|
||||
private readonly INewznabCapabilitiesProvider _capabilitiesProvider;
|
||||
public int MaxPages { get; set; }
|
||||
public int PageSize { get; set; }
|
||||
public NewznabSettings Settings { get; set; }
|
||||
|
||||
public NewznabRequestGenerator()
|
||||
public NewznabRequestGenerator(INewznabCapabilitiesProvider capabilitiesProvider)
|
||||
{
|
||||
_capabilitiesProvider = capabilitiesProvider;
|
||||
|
||||
MaxPages = 30;
|
||||
PageSize = 100;
|
||||
}
|
||||
|
||||
private bool SupportsSearch
|
||||
{
|
||||
get
|
||||
{
|
||||
var capabilities = _capabilitiesProvider.GetCapabilities(Settings);
|
||||
|
||||
return capabilities.SupportedSearchParameters != null &&
|
||||
capabilities.SupportedSearchParameters.Contains("q");
|
||||
}
|
||||
}
|
||||
|
||||
private bool SupportsTvSearch
|
||||
{
|
||||
get
|
||||
{
|
||||
var capabilities = _capabilitiesProvider.GetCapabilities(Settings);
|
||||
|
||||
return capabilities.SupportedTvSearchParameters != null &&
|
||||
capabilities.SupportedTvSearchParameters.Contains("q") &&
|
||||
capabilities.SupportedTvSearchParameters.Contains("season") &&
|
||||
capabilities.SupportedTvSearchParameters.Contains("ep");
|
||||
}
|
||||
}
|
||||
|
||||
private bool SupportsTvdbSearch
|
||||
{
|
||||
get
|
||||
{
|
||||
var capabilities = _capabilitiesProvider.GetCapabilities(Settings);
|
||||
|
||||
return capabilities.SupportedTvSearchParameters != null &&
|
||||
capabilities.SupportedTvSearchParameters.Contains("tvdbid") &&
|
||||
capabilities.SupportedTvSearchParameters.Contains("season") &&
|
||||
capabilities.SupportedTvSearchParameters.Contains("ep");
|
||||
}
|
||||
}
|
||||
|
||||
private bool SupportsTvRageSearch
|
||||
{
|
||||
get
|
||||
{
|
||||
var capabilities = _capabilitiesProvider.GetCapabilities(Settings);
|
||||
|
||||
return capabilities.SupportedTvSearchParameters != null &&
|
||||
capabilities.SupportedTvSearchParameters.Contains("rid") &&
|
||||
capabilities.SupportedTvSearchParameters.Contains("season") &&
|
||||
capabilities.SupportedTvSearchParameters.Contains("ep");
|
||||
}
|
||||
}
|
||||
|
||||
public virtual IList<IEnumerable<IndexerRequest>> GetRecentRequests()
|
||||
{
|
||||
var pageableRequests = new List<IEnumerable<IndexerRequest>>();
|
||||
|
||||
pageableRequests.AddIfNotNull(GetPagedRequests(MaxPages, Settings.Categories.Concat(Settings.AnimeCategories), "tvsearch", ""));
|
||||
var capabilities = _capabilitiesProvider.GetCapabilities(Settings);
|
||||
|
||||
if (capabilities.SupportedTvSearchParameters != null)
|
||||
{
|
||||
pageableRequests.AddIfNotNull(GetPagedRequests(MaxPages, Settings.Categories.Concat(Settings.AnimeCategories), "tvsearch", ""));
|
||||
}
|
||||
|
||||
return pageableRequests;
|
||||
}
|
||||
@ -32,20 +90,28 @@ public virtual IList<IEnumerable<IndexerRequest>> GetSearchRequests(SingleEpisod
|
||||
{
|
||||
var pageableRequests = new List<IEnumerable<IndexerRequest>>();
|
||||
|
||||
if (searchCriteria.Series.TvRageId > 0)
|
||||
if (searchCriteria.Series.TvdbId > 0 && SupportsTvdbSearch)
|
||||
{
|
||||
pageableRequests.AddIfNotNull(GetPagedRequests(MaxPages, Settings.Categories, "tvsearch",
|
||||
String.Format("&rid={0}&season={1}&ep={2}",
|
||||
string.Format("&tvdbid={0}&season={1}&ep={2}",
|
||||
searchCriteria.Series.TvdbId,
|
||||
searchCriteria.SeasonNumber,
|
||||
searchCriteria.EpisodeNumber)));
|
||||
}
|
||||
else if (searchCriteria.Series.TvRageId > 0 && SupportsTvRageSearch)
|
||||
{
|
||||
pageableRequests.AddIfNotNull(GetPagedRequests(MaxPages, Settings.Categories, "tvsearch",
|
||||
string.Format("&rid={0}&season={1}&ep={2}",
|
||||
searchCriteria.Series.TvRageId,
|
||||
searchCriteria.SeasonNumber,
|
||||
searchCriteria.EpisodeNumber)));
|
||||
}
|
||||
else
|
||||
else if (SupportsTvSearch)
|
||||
{
|
||||
foreach (var queryTitle in searchCriteria.QueryTitles)
|
||||
{
|
||||
pageableRequests.AddIfNotNull(GetPagedRequests(MaxPages, Settings.Categories, "tvsearch",
|
||||
String.Format("&q={0}&season={1}&ep={2}",
|
||||
string.Format("&q={0}&season={1}&ep={2}",
|
||||
NewsnabifyTitle(queryTitle),
|
||||
searchCriteria.SeasonNumber,
|
||||
searchCriteria.EpisodeNumber)));
|
||||
@ -59,19 +125,26 @@ public virtual IList<IEnumerable<IndexerRequest>> GetSearchRequests(SeasonSearch
|
||||
{
|
||||
var pageableRequests = new List<IEnumerable<IndexerRequest>>();
|
||||
|
||||
if (searchCriteria.Series.TvRageId > 0)
|
||||
if (searchCriteria.Series.TvdbId > 0 && SupportsTvdbSearch)
|
||||
{
|
||||
pageableRequests.AddIfNotNull(GetPagedRequests(MaxPages, Settings.Categories, "tvsearch",
|
||||
String.Format("&rid={0}&season={1}",
|
||||
string.Format("&tvdbid={0}&season={1}",
|
||||
searchCriteria.Series.TvdbId,
|
||||
searchCriteria.SeasonNumber)));
|
||||
}
|
||||
else if (searchCriteria.Series.TvRageId > 0 && SupportsTvRageSearch)
|
||||
{
|
||||
pageableRequests.AddIfNotNull(GetPagedRequests(MaxPages, Settings.Categories, "tvsearch",
|
||||
string.Format("&rid={0}&season={1}",
|
||||
searchCriteria.Series.TvRageId,
|
||||
searchCriteria.SeasonNumber)));
|
||||
}
|
||||
else
|
||||
else if (SupportsTvSearch)
|
||||
{
|
||||
foreach (var queryTitle in searchCriteria.QueryTitles)
|
||||
{
|
||||
pageableRequests.AddIfNotNull(GetPagedRequests(MaxPages, Settings.Categories, "tvsearch",
|
||||
String.Format("&q={0}&season={1}",
|
||||
string.Format("&q={0}&season={1}",
|
||||
NewsnabifyTitle(queryTitle),
|
||||
searchCriteria.SeasonNumber)));
|
||||
}
|
||||
@ -84,19 +157,26 @@ public virtual IList<IEnumerable<IndexerRequest>> GetSearchRequests(DailyEpisode
|
||||
{
|
||||
var pageableRequests = new List<IEnumerable<IndexerRequest>>();
|
||||
|
||||
if (searchCriteria.Series.TvRageId > 0)
|
||||
if (searchCriteria.Series.TvdbId > 0 && SupportsTvdbSearch)
|
||||
{
|
||||
pageableRequests.AddIfNotNull(GetPagedRequests(MaxPages, Settings.Categories, "tvsearch",
|
||||
String.Format("&rid={0}&season={1:yyyy}&ep={1:MM}/{1:dd}",
|
||||
string.Format("&tvdbid={0}&season={1:yyyy}&ep={1:MM}/{1:dd}",
|
||||
searchCriteria.Series.TvdbId,
|
||||
searchCriteria.AirDate)));
|
||||
}
|
||||
else if (searchCriteria.Series.TvRageId > 0 && SupportsTvRageSearch)
|
||||
{
|
||||
pageableRequests.AddIfNotNull(GetPagedRequests(MaxPages, Settings.Categories, "tvsearch",
|
||||
string.Format("&rid={0}&season={1:yyyy}&ep={1:MM}/{1:dd}",
|
||||
searchCriteria.Series.TvRageId,
|
||||
searchCriteria.AirDate)));
|
||||
}
|
||||
else
|
||||
else if (SupportsTvSearch)
|
||||
{
|
||||
foreach (var queryTitle in searchCriteria.QueryTitles)
|
||||
{
|
||||
pageableRequests.AddIfNotNull(GetPagedRequests(MaxPages, Settings.Categories, "tvsearch",
|
||||
String.Format("&q={0}&season={1:yyyy}&ep={1:MM}/{1:dd}",
|
||||
string.Format("&q={0}&season={1:yyyy}&ep={1:MM}/{1:dd}",
|
||||
NewsnabifyTitle(queryTitle),
|
||||
searchCriteria.AirDate)));
|
||||
}
|
||||
@ -109,12 +189,15 @@ public virtual IList<IEnumerable<IndexerRequest>> GetSearchRequests(AnimeEpisode
|
||||
{
|
||||
var pageableRequests = new List<IEnumerable<IndexerRequest>>();
|
||||
|
||||
foreach (var queryTitle in searchCriteria.QueryTitles)
|
||||
if (SupportsSearch)
|
||||
{
|
||||
pageableRequests.AddIfNotNull(GetPagedRequests(MaxPages, Settings.AnimeCategories, "search",
|
||||
String.Format("&q={0}+{1:00}",
|
||||
NewsnabifyTitle(queryTitle),
|
||||
searchCriteria.AbsoluteEpisodeNumber)));
|
||||
foreach (var queryTitle in searchCriteria.QueryTitles)
|
||||
{
|
||||
pageableRequests.AddIfNotNull(GetPagedRequests(MaxPages, Settings.AnimeCategories, "search",
|
||||
string.Format("&q={0}+{1:00}",
|
||||
NewsnabifyTitle(queryTitle),
|
||||
searchCriteria.AbsoluteEpisodeNumber)));
|
||||
}
|
||||
}
|
||||
|
||||
return pageableRequests;
|
||||
@ -124,29 +207,32 @@ public virtual IList<IEnumerable<IndexerRequest>> GetSearchRequests(SpecialEpiso
|
||||
{
|
||||
var pageableRequests = new List<IEnumerable<IndexerRequest>>();
|
||||
|
||||
foreach (var queryTitle in searchCriteria.EpisodeQueryTitles)
|
||||
if (SupportsSearch)
|
||||
{
|
||||
var query = queryTitle.Replace('+', ' ');
|
||||
query = System.Web.HttpUtility.UrlEncode(query);
|
||||
foreach (var queryTitle in searchCriteria.EpisodeQueryTitles)
|
||||
{
|
||||
var query = queryTitle.Replace('+', ' ');
|
||||
query = System.Web.HttpUtility.UrlEncode(query);
|
||||
|
||||
pageableRequests.AddIfNotNull(GetPagedRequests(MaxPages, Settings.Categories.Concat(Settings.AnimeCategories), "search",
|
||||
String.Format("&q={0}",
|
||||
query)));
|
||||
pageableRequests.AddIfNotNull(GetPagedRequests(MaxPages, Settings.Categories.Concat(Settings.AnimeCategories), "search",
|
||||
string.Format("&q={0}",
|
||||
query)));
|
||||
}
|
||||
}
|
||||
|
||||
return pageableRequests;
|
||||
}
|
||||
|
||||
private IEnumerable<IndexerRequest> GetPagedRequests(Int32 maxPages, IEnumerable<Int32> categories, String searchType, String parameters)
|
||||
private IEnumerable<IndexerRequest> GetPagedRequests(int maxPages, IEnumerable<int> categories, string searchType, string parameters)
|
||||
{
|
||||
if (categories.Empty())
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
|
||||
var categoriesQuery = String.Join(",", categories.Distinct());
|
||||
var categoriesQuery = string.Join(",", categories.Distinct());
|
||||
|
||||
var baseUrl = String.Format("{0}/api?t={1}&cat={2}&extended=1{3}", Settings.Url.TrimEnd('/'), searchType, categoriesQuery, Settings.AdditionalParameters);
|
||||
var baseUrl = string.Format("{0}/api?t={1}&cat={2}&extended=1{3}", Settings.Url.TrimEnd('/'), searchType, categoriesQuery, Settings.AdditionalParameters);
|
||||
|
||||
if (Settings.ApiKey.IsNotNullOrWhiteSpace())
|
||||
{
|
||||
@ -155,18 +241,18 @@ private IEnumerable<IndexerRequest> GetPagedRequests(Int32 maxPages, IEnumerable
|
||||
|
||||
if (PageSize == 0)
|
||||
{
|
||||
yield return new IndexerRequest(String.Format("{0}{1}", baseUrl, parameters), HttpAccept.Rss);
|
||||
yield return new IndexerRequest(string.Format("{0}{1}", baseUrl, parameters), HttpAccept.Rss);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (var page = 0; page < maxPages; page++)
|
||||
{
|
||||
yield return new IndexerRequest(String.Format("{0}&offset={1}&limit={2}{3}", baseUrl, page * PageSize, PageSize, parameters), HttpAccept.Rss);
|
||||
yield return new IndexerRequest(string.Format("{0}&offset={1}&limit={2}{3}", baseUrl, page * PageSize, PageSize, parameters), HttpAccept.Rss);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static String NewsnabifyTitle(String title)
|
||||
private static string NewsnabifyTitle(string title)
|
||||
{
|
||||
return title.Replace("+", "%20");
|
||||
}
|
||||
|
@ -44,6 +44,7 @@ protected override ReleaseInfo ProcessItem(XElement item, ReleaseInfo releaseInf
|
||||
{
|
||||
releaseInfo = base.ProcessItem(item, releaseInfo);
|
||||
|
||||
releaseInfo.TvdbId = GetTvdbId(item);
|
||||
releaseInfo.TvRageId = GetTvRageId(item);
|
||||
|
||||
return releaseInfo;
|
||||
@ -97,6 +98,19 @@ protected override string GetDownloadUrl(XElement item)
|
||||
return url;
|
||||
}
|
||||
|
||||
protected virtual int GetTvdbId(XElement item)
|
||||
{
|
||||
var tvdbIdString = TryGetNewznabAttribute(item, "tvdbid");
|
||||
int tvdbId;
|
||||
|
||||
if (!tvdbIdString.IsNullOrWhiteSpace() && int.TryParse(tvdbIdString, out tvdbId))
|
||||
{
|
||||
return tvdbId;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected virtual int GetTvRageId(XElement item)
|
||||
{
|
||||
var tvRageIdString = TryGetNewznabAttribute(item, "rageid");
|
||||
|
@ -61,24 +61,24 @@ public class NewznabSettings : IProviderConfig
|
||||
|
||||
public NewznabSettings()
|
||||
{
|
||||
Categories = new[] {5030, 5040};
|
||||
AnimeCategories = Enumerable.Empty<Int32>();
|
||||
Categories = new[] { 5030, 5040 };
|
||||
AnimeCategories = Enumerable.Empty<int>();
|
||||
}
|
||||
|
||||
[FieldDefinition(0, Label = "URL")]
|
||||
public String Url { get; set; }
|
||||
public string Url { get; set; }
|
||||
|
||||
[FieldDefinition(1, Label = "API Key")]
|
||||
public String ApiKey { get; set; }
|
||||
public string ApiKey { get; set; }
|
||||
|
||||
[FieldDefinition(2, Label = "Categories", HelpText = "Comma Separated list, leave blank to disable standard/daily shows", Advanced = true)]
|
||||
public IEnumerable<Int32> Categories { get; set; }
|
||||
public IEnumerable<int> Categories { get; set; }
|
||||
|
||||
[FieldDefinition(3, Label = "Anime Categories", HelpText = "Comma Separated list, leave blank to disable anime", Advanced = true)]
|
||||
public IEnumerable<Int32> AnimeCategories { get; set; }
|
||||
public IEnumerable<int> AnimeCategories { get; set; }
|
||||
|
||||
[FieldDefinition(4, Label = "Additional Parameters", HelpText = "Additional newznab parameters", Advanced = true)]
|
||||
public String AdditionalParameters { get; set; }
|
||||
[FieldDefinition(4, Label = "Additional Parameters", HelpText = "Additional Newznab parameters", Advanced = true)]
|
||||
public string AdditionalParameters { get; set; }
|
||||
|
||||
public NzbDroneValidationResult Validate()
|
||||
{
|
||||
|
@ -57,10 +57,18 @@ public IList<ReleaseInfo> ParseResponse(IndexerResponse indexerResponse)
|
||||
torrentInfo.PublishDate = torrent.pubdate;
|
||||
torrentInfo.Seeders = torrent.seeders;
|
||||
torrentInfo.Peers = torrent.leechers + torrent.seeders;
|
||||
|
||||
if (torrent.episode_info != null && torrent.episode_info.tvrage != null)
|
||||
|
||||
if (torrent.episode_info != null)
|
||||
{
|
||||
torrentInfo.TvRageId = torrent.episode_info.tvrage.Value;
|
||||
if (torrent.episode_info.tvdb != null)
|
||||
{
|
||||
torrentInfo.TvdbId = torrent.episode_info.tvdb.Value;
|
||||
}
|
||||
|
||||
if (torrent.episode_info.tvrage != null)
|
||||
{
|
||||
torrentInfo.TvRageId = torrent.episode_info.tvrage.Value;
|
||||
}
|
||||
}
|
||||
|
||||
results.Add(torrentInfo);
|
||||
|
@ -6,6 +6,7 @@
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Common.Http;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Indexers.Newznab;
|
||||
using NzbDrone.Core.Parser;
|
||||
using NzbDrone.Core.ThingiProvider;
|
||||
|
||||
@ -13,7 +14,7 @@ namespace NzbDrone.Core.Indexers.Torznab
|
||||
{
|
||||
public class Torznab : HttpIndexerBase<TorznabSettings>
|
||||
{
|
||||
private readonly ITorznabCapabilitiesProvider _torznabCapabilitiesProvider;
|
||||
private readonly INewznabCapabilitiesProvider _capabilitiesProvider;
|
||||
|
||||
public override string Name
|
||||
{
|
||||
@ -28,7 +29,7 @@ public override string Name
|
||||
|
||||
public override IIndexerRequestGenerator GetRequestGenerator()
|
||||
{
|
||||
return new TorznabRequestGenerator(_torznabCapabilitiesProvider)
|
||||
return new NewznabRequestGenerator(_capabilitiesProvider)
|
||||
{
|
||||
PageSize = PageSize,
|
||||
Settings = Settings
|
||||
@ -48,10 +49,10 @@ public override IEnumerable<ProviderDefinition> DefaultDefinitions
|
||||
}
|
||||
}
|
||||
|
||||
public Torznab(ITorznabCapabilitiesProvider torznabCapabilitiesProvider, IHttpClient httpClient, IIndexerStatusService indexerStatusService, IConfigService configService, IParsingService parsingService, Logger logger)
|
||||
public Torznab(INewznabCapabilitiesProvider capabilitiesProvider, IHttpClient httpClient, IIndexerStatusService indexerStatusService, IConfigService configService, IParsingService parsingService, Logger logger)
|
||||
: base(httpClient, indexerStatusService, configService, parsingService, logger)
|
||||
{
|
||||
_torznabCapabilitiesProvider = torznabCapabilitiesProvider;
|
||||
_capabilitiesProvider = capabilitiesProvider;
|
||||
}
|
||||
|
||||
private IndexerDefinition GetDefinition(string name, TorznabSettings settings)
|
||||
@ -92,7 +93,7 @@ protected virtual ValidationFailure TestCapabilities()
|
||||
{
|
||||
try
|
||||
{
|
||||
var capabilities = _torznabCapabilitiesProvider.GetCapabilities(Settings);
|
||||
var capabilities = _capabilitiesProvider.GetCapabilities(Settings);
|
||||
|
||||
if (capabilities.SupportedSearchParameters != null && capabilities.SupportedSearchParameters.Contains("q"))
|
||||
{
|
||||
@ -100,8 +101,8 @@ protected virtual ValidationFailure TestCapabilities()
|
||||
}
|
||||
|
||||
if (capabilities.SupportedTvSearchParameters != null &&
|
||||
(capabilities.SupportedSearchParameters.Contains("q") || capabilities.SupportedSearchParameters.Contains("rid")) &&
|
||||
capabilities.SupportedTvSearchParameters.Contains("season") && capabilities.SupportedTvSearchParameters.Contains("ep"))
|
||||
new[] { "q", "tvdbid", "rid" }.Any(v => capabilities.SupportedTvSearchParameters.Contains(v)) &&
|
||||
new[] { "season", "ep" }.All(v => capabilities.SupportedTvSearchParameters.Contains(v)))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
@ -1,28 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NzbDrone.Core.Indexers.Torznab
|
||||
{
|
||||
public class TorznabCapabilities
|
||||
{
|
||||
public string[] SupportedSearchParameters { get; set; }
|
||||
public string[] SupportedTvSearchParameters { get; set; }
|
||||
public List<TorznabCategory> Categories { get; set; }
|
||||
|
||||
public TorznabCapabilities()
|
||||
{
|
||||
SupportedSearchParameters = new[] { "q", "offset", "limit" };
|
||||
SupportedTvSearchParameters = new[] { "q", "rid", "season", "ep", "offset", "limit" };
|
||||
Categories = new List<TorznabCategory>();
|
||||
}
|
||||
}
|
||||
|
||||
public class TorznabCategory
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Description { get; set; }
|
||||
|
||||
public List<TorznabCategory> Subcategories { get; set; }
|
||||
}
|
||||
}
|
@ -8,8 +8,7 @@ public TorznabException(string message, params object[] args) : base(message, ar
|
||||
{
|
||||
}
|
||||
|
||||
public TorznabException(string message)
|
||||
: base(message)
|
||||
public TorznabException(string message) : base(message)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -1,228 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Common.Http;
|
||||
using NzbDrone.Core.IndexerSearch.Definitions;
|
||||
|
||||
namespace NzbDrone.Core.Indexers.Torznab
|
||||
{
|
||||
public class TorznabRequestGenerator : IIndexerRequestGenerator
|
||||
{
|
||||
private readonly ITorznabCapabilitiesProvider _capabilitiesProvider;
|
||||
|
||||
public int MaxPages { get; set; }
|
||||
public int PageSize { get; set; }
|
||||
|
||||
public TorznabSettings Settings { get; set; }
|
||||
|
||||
public TorznabRequestGenerator(ITorznabCapabilitiesProvider capabilitiesProvider)
|
||||
{
|
||||
_capabilitiesProvider = capabilitiesProvider;
|
||||
|
||||
MaxPages = 30;
|
||||
PageSize = 100;
|
||||
}
|
||||
|
||||
private bool SupportsSearch
|
||||
{
|
||||
get
|
||||
{
|
||||
var capabilities = _capabilitiesProvider.GetCapabilities(Settings);
|
||||
|
||||
return capabilities.SupportedSearchParameters != null
|
||||
&& capabilities.SupportedSearchParameters.Contains("q");
|
||||
}
|
||||
}
|
||||
|
||||
private bool SupportsTvSearch
|
||||
{
|
||||
get
|
||||
{
|
||||
var capabilities = _capabilitiesProvider.GetCapabilities(Settings);
|
||||
|
||||
return capabilities.SupportedTvSearchParameters != null
|
||||
&& capabilities.SupportedTvSearchParameters.Contains("q")
|
||||
&& capabilities.SupportedTvSearchParameters.Contains("season")
|
||||
&& capabilities.SupportedTvSearchParameters.Contains("ep");
|
||||
}
|
||||
}
|
||||
|
||||
private bool SupportsTvRageSearch
|
||||
{
|
||||
get
|
||||
{
|
||||
var capabilities = _capabilitiesProvider.GetCapabilities(Settings);
|
||||
|
||||
return capabilities.SupportedTvSearchParameters != null
|
||||
&& capabilities.SupportedTvSearchParameters.Contains("rid")
|
||||
&& capabilities.SupportedTvSearchParameters.Contains("season")
|
||||
&& capabilities.SupportedTvSearchParameters.Contains("ep")
|
||||
&& Settings.EnableRageIDLookup;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual IList<IEnumerable<IndexerRequest>> GetRecentRequests()
|
||||
{
|
||||
var pageableRequests = new List<IEnumerable<IndexerRequest>>();
|
||||
|
||||
var capabilities = _capabilitiesProvider.GetCapabilities(Settings);
|
||||
|
||||
if (capabilities.SupportedTvSearchParameters != null)
|
||||
{
|
||||
pageableRequests.AddIfNotNull(GetPagedRequests(MaxPages, Settings.Categories.Concat(Settings.AnimeCategories), "tvsearch", ""));
|
||||
}
|
||||
|
||||
return pageableRequests;
|
||||
}
|
||||
|
||||
public virtual IList<IEnumerable<IndexerRequest>> GetSearchRequests(SingleEpisodeSearchCriteria searchCriteria)
|
||||
{
|
||||
var pageableRequests = new List<IEnumerable<IndexerRequest>>();
|
||||
|
||||
if (searchCriteria.Series.TvRageId > 0 && SupportsTvRageSearch)
|
||||
{
|
||||
pageableRequests.AddIfNotNull(GetPagedRequests(MaxPages, Settings.Categories, "tvsearch",
|
||||
string.Format("&rid={0}&season={1}&ep={2}",
|
||||
searchCriteria.Series.TvRageId,
|
||||
searchCriteria.SeasonNumber,
|
||||
searchCriteria.EpisodeNumber)));
|
||||
}
|
||||
else if (SupportsTvSearch)
|
||||
{
|
||||
foreach (var queryTitle in searchCriteria.QueryTitles)
|
||||
{
|
||||
pageableRequests.AddIfNotNull(GetPagedRequests(MaxPages, Settings.Categories, "tvsearch",
|
||||
string.Format("&q={0}&season={1}&ep={2}",
|
||||
NewsnabifyTitle(queryTitle),
|
||||
searchCriteria.SeasonNumber,
|
||||
searchCriteria.EpisodeNumber)));
|
||||
}
|
||||
}
|
||||
|
||||
return pageableRequests;
|
||||
}
|
||||
|
||||
public virtual IList<IEnumerable<IndexerRequest>> GetSearchRequests(SeasonSearchCriteria searchCriteria)
|
||||
{
|
||||
var pageableRequests = new List<IEnumerable<IndexerRequest>>();
|
||||
|
||||
if (searchCriteria.Series.TvRageId > 0 && SupportsTvRageSearch)
|
||||
{
|
||||
pageableRequests.AddIfNotNull(GetPagedRequests(MaxPages, Settings.Categories, "tvsearch",
|
||||
string.Format("&rid={0}&season={1}",
|
||||
searchCriteria.Series.TvRageId,
|
||||
searchCriteria.SeasonNumber)));
|
||||
}
|
||||
else if (SupportsTvSearch)
|
||||
{
|
||||
foreach (var queryTitle in searchCriteria.QueryTitles)
|
||||
{
|
||||
pageableRequests.AddIfNotNull(GetPagedRequests(MaxPages, Settings.Categories, "tvsearch",
|
||||
string.Format("&q={0}&season={1}",
|
||||
NewsnabifyTitle(queryTitle),
|
||||
searchCriteria.SeasonNumber)));
|
||||
}
|
||||
}
|
||||
|
||||
return pageableRequests;
|
||||
}
|
||||
|
||||
public virtual IList<IEnumerable<IndexerRequest>> GetSearchRequests(DailyEpisodeSearchCriteria searchCriteria)
|
||||
{
|
||||
var pageableRequests = new List<IEnumerable<IndexerRequest>>();
|
||||
|
||||
if (searchCriteria.Series.TvRageId > 0 && SupportsTvRageSearch)
|
||||
{
|
||||
pageableRequests.AddIfNotNull(GetPagedRequests(MaxPages, Settings.Categories, "tvsearch",
|
||||
string.Format("&rid={0}&season={1:yyyy}&ep={1:MM}/{1:dd}",
|
||||
searchCriteria.Series.TvRageId,
|
||||
searchCriteria.AirDate)));
|
||||
}
|
||||
else if (SupportsTvSearch)
|
||||
{
|
||||
foreach (var queryTitle in searchCriteria.QueryTitles)
|
||||
{
|
||||
pageableRequests.AddIfNotNull(GetPagedRequests(MaxPages, Settings.Categories, "tvsearch",
|
||||
string.Format("&q={0}&season={1:yyyy}&ep={1:MM}/{1:dd}",
|
||||
NewsnabifyTitle(queryTitle),
|
||||
searchCriteria.AirDate)));
|
||||
}
|
||||
}
|
||||
|
||||
return pageableRequests;
|
||||
}
|
||||
|
||||
public virtual IList<IEnumerable<IndexerRequest>> GetSearchRequests(AnimeEpisodeSearchCriteria searchCriteria)
|
||||
{
|
||||
var pageableRequests = new List<IEnumerable<IndexerRequest>>();
|
||||
|
||||
if (SupportsSearch)
|
||||
{
|
||||
foreach (var queryTitle in searchCriteria.QueryTitles)
|
||||
{
|
||||
pageableRequests.AddIfNotNull(GetPagedRequests(MaxPages, Settings.AnimeCategories, "search",
|
||||
string.Format("&q={0}+{1:00}",
|
||||
NewsnabifyTitle(queryTitle),
|
||||
searchCriteria.AbsoluteEpisodeNumber)));
|
||||
}
|
||||
}
|
||||
|
||||
return pageableRequests;
|
||||
}
|
||||
|
||||
public virtual IList<IEnumerable<IndexerRequest>> GetSearchRequests(SpecialEpisodeSearchCriteria searchCriteria)
|
||||
{
|
||||
var pageableRequests = new List<IEnumerable<IndexerRequest>>();
|
||||
|
||||
if (SupportsSearch)
|
||||
{
|
||||
foreach (var queryTitle in searchCriteria.EpisodeQueryTitles)
|
||||
{
|
||||
var query = queryTitle.Replace('+', ' ');
|
||||
query = System.Web.HttpUtility.UrlEncode(query);
|
||||
|
||||
pageableRequests.AddIfNotNull(GetPagedRequests(MaxPages, Settings.Categories.Concat(Settings.AnimeCategories), "search",
|
||||
string.Format("&q={0}",
|
||||
query)));
|
||||
}
|
||||
}
|
||||
|
||||
return pageableRequests;
|
||||
}
|
||||
|
||||
private IEnumerable<IndexerRequest> GetPagedRequests(int maxPages, IEnumerable<int> categories, string searchType, string parameters)
|
||||
{
|
||||
if (categories.Empty())
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
|
||||
var categoriesQuery = string.Join(",", categories.Distinct());
|
||||
|
||||
var baseUrl = string.Format("{0}/api?t={1}&cat={2}&extended=1{3}", Settings.Url.TrimEnd('/'), searchType, categoriesQuery, Settings.AdditionalParameters);
|
||||
|
||||
if (Settings.ApiKey.IsNotNullOrWhiteSpace())
|
||||
{
|
||||
baseUrl += "&apikey=" + Settings.ApiKey;
|
||||
}
|
||||
|
||||
if (PageSize == 0)
|
||||
{
|
||||
yield return new IndexerRequest(string.Format("{0}{1}", baseUrl, parameters), HttpAccept.Rss);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (var page = 0; page < maxPages; page++)
|
||||
{
|
||||
yield return new IndexerRequest(string.Format("{0}&offset={1}&limit={2}{3}", baseUrl, page * PageSize, PageSize, parameters), HttpAccept.Rss);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static string NewsnabifyTitle(string title)
|
||||
{
|
||||
return title.Replace("+", "%20");
|
||||
}
|
||||
}
|
||||
}
|
@ -13,7 +13,7 @@ public class TorznabRssParser : TorrentRssParser
|
||||
|
||||
protected override bool PreProcess(IndexerResponse indexerResponse)
|
||||
{
|
||||
var xdoc = XDocument.Parse(indexerResponse.Content);
|
||||
var xdoc = LoadXmlDocument(indexerResponse);
|
||||
var error = xdoc.Descendants("error").FirstOrDefault();
|
||||
|
||||
if (error == null) return true;
|
||||
@ -40,6 +40,7 @@ protected override ReleaseInfo ProcessItem(XElement item, ReleaseInfo releaseInf
|
||||
{
|
||||
var torrentInfo = base.ProcessItem(item, releaseInfo) as TorrentInfo;
|
||||
|
||||
torrentInfo.TvdbId = GetTvdbId(item);
|
||||
torrentInfo.TvRageId = GetTvRageId(item);
|
||||
|
||||
return torrentInfo;
|
||||
@ -67,12 +68,12 @@ protected override string GetCommentUrl(XElement item)
|
||||
return ParseUrl(item.TryGetValue("comments"));
|
||||
}
|
||||
|
||||
protected override Int64 GetSize(XElement item)
|
||||
protected override long GetSize(XElement item)
|
||||
{
|
||||
Int64 size;
|
||||
long size;
|
||||
|
||||
var sizeString = TryGetTorznabAttribute(item, "size");
|
||||
if (!sizeString.IsNullOrWhiteSpace() && Int64.TryParse(sizeString, out size))
|
||||
if (!sizeString.IsNullOrWhiteSpace() && long.TryParse(sizeString, out size))
|
||||
{
|
||||
return size;
|
||||
}
|
||||
@ -99,12 +100,25 @@ protected override string GetDownloadUrl(XElement item)
|
||||
return url;
|
||||
}
|
||||
|
||||
protected virtual Int32 GetTvRageId(XElement item)
|
||||
protected virtual int GetTvdbId(XElement item)
|
||||
{
|
||||
var tvdbIdString = TryGetTorznabAttribute(item, "tvdbid");
|
||||
int tvdbId;
|
||||
|
||||
if (!tvdbIdString.IsNullOrWhiteSpace() && int.TryParse(tvdbIdString, out tvdbId))
|
||||
{
|
||||
return tvdbId;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected virtual int GetTvRageId(XElement item)
|
||||
{
|
||||
var tvRageIdString = TryGetTorznabAttribute(item, "rageid");
|
||||
Int32 tvRageId;
|
||||
int tvRageId;
|
||||
|
||||
if (!tvRageIdString.IsNullOrWhiteSpace() && Int32.TryParse(tvRageIdString, out tvRageId))
|
||||
if (!tvRageIdString.IsNullOrWhiteSpace() && int.TryParse(tvRageIdString, out tvRageId))
|
||||
{
|
||||
return tvRageId;
|
||||
}
|
||||
@ -121,25 +135,25 @@ protected override string GetMagnetUrl(XElement item)
|
||||
return TryGetTorznabAttribute(item, "magneturl");
|
||||
}
|
||||
|
||||
protected override Int32? GetSeeders(XElement item)
|
||||
protected override int? GetSeeders(XElement item)
|
||||
{
|
||||
var seeders = TryGetTorznabAttribute(item, "seeders");
|
||||
|
||||
if (seeders.IsNotNullOrWhiteSpace())
|
||||
{
|
||||
return Int32.Parse(seeders);
|
||||
return int.Parse(seeders);
|
||||
}
|
||||
|
||||
return base.GetSeeders(item);
|
||||
}
|
||||
|
||||
protected override Int32? GetPeers(XElement item)
|
||||
protected override int? GetPeers(XElement item)
|
||||
{
|
||||
var peers = TryGetTorznabAttribute(item, "peers");
|
||||
|
||||
if (peers.IsNotNullOrWhiteSpace())
|
||||
{
|
||||
return Int32.Parse(peers);
|
||||
return int.Parse(peers);
|
||||
}
|
||||
|
||||
var seeders = TryGetTorznabAttribute(item, "seeders");
|
||||
@ -147,7 +161,7 @@ protected override string GetMagnetUrl(XElement item)
|
||||
|
||||
if (seeders.IsNotNullOrWhiteSpace() && leechers.IsNotNullOrWhiteSpace())
|
||||
{
|
||||
return Int32.Parse(seeders) + Int32.Parse(leechers);
|
||||
return int.Parse(seeders) + int.Parse(leechers);
|
||||
}
|
||||
|
||||
return base.GetPeers(item);
|
||||
|
@ -3,8 +3,10 @@
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using FluentValidation;
|
||||
using FluentValidation.Results;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Core.Annotations;
|
||||
using NzbDrone.Core.Indexers.Newznab;
|
||||
using NzbDrone.Core.ThingiProvider;
|
||||
using NzbDrone.Core.Validation;
|
||||
|
||||
@ -14,7 +16,6 @@ public class TorznabSettingsValidator : AbstractValidator<TorznabSettings>
|
||||
{
|
||||
private static readonly string[] ApiKeyWhiteList =
|
||||
{
|
||||
"hdaccess.net",
|
||||
"hd4free.xyz",
|
||||
};
|
||||
|
||||
@ -32,46 +33,27 @@ private static bool ShouldHaveApiKey(TorznabSettings settings)
|
||||
|
||||
public TorznabSettingsValidator()
|
||||
{
|
||||
Custom(newznab =>
|
||||
{
|
||||
if (newznab.Categories.Empty() && newznab.AnimeCategories.Empty())
|
||||
{
|
||||
return new ValidationFailure("", "Either 'Categories' or 'Anime Categories' must be provided");
|
||||
}
|
||||
|
||||
return null;
|
||||
});
|
||||
|
||||
RuleFor(c => c.Url).ValidRootUrl();
|
||||
RuleFor(c => c.ApiKey).NotEmpty().When(ShouldHaveApiKey);
|
||||
RuleFor(c => c.Categories).NotEmpty().When(c => !c.AnimeCategories.Any());
|
||||
RuleFor(c => c.AnimeCategories).NotEmpty().When(c => !c.Categories.Any());
|
||||
RuleFor(c => c.AdditionalParameters)
|
||||
.Matches(AdditionalParametersRegex)
|
||||
.When(c => !c.AdditionalParameters.IsNullOrWhiteSpace());
|
||||
RuleFor(c => c.AdditionalParameters).Matches(AdditionalParametersRegex)
|
||||
.When(c => !c.AdditionalParameters.IsNullOrWhiteSpace());
|
||||
}
|
||||
}
|
||||
|
||||
public class TorznabSettings : IProviderConfig
|
||||
public class TorznabSettings : NewznabSettings
|
||||
{
|
||||
private static readonly TorznabSettingsValidator Validator = new TorznabSettingsValidator();
|
||||
|
||||
public TorznabSettings()
|
||||
{
|
||||
Categories = new[] { 5030, 5040 };
|
||||
AnimeCategories = Enumerable.Empty<int>();
|
||||
EnableRageIDLookup = true;
|
||||
}
|
||||
|
||||
[FieldDefinition(0, Label = "URL")]
|
||||
public string Url { get; set; }
|
||||
|
||||
[FieldDefinition(1, Label = "API Key")]
|
||||
public string ApiKey { get; set; }
|
||||
|
||||
[FieldDefinition(2, Label = "Categories", HelpText = "Comma Separated list, leave blank to disable standard/daily shows", Advanced = true)]
|
||||
public IEnumerable<int> Categories { get; set; }
|
||||
|
||||
[FieldDefinition(3, Label = "Anime Categories", HelpText = "Comma Separated list, leave blank to disable anime", Advanced = true)]
|
||||
public IEnumerable<int> AnimeCategories { get; set; }
|
||||
|
||||
[FieldDefinition(4, Label = "Additional Parameters", HelpText = "Additional Torznab parameters", Advanced = true)]
|
||||
public string AdditionalParameters { get; set; }
|
||||
|
||||
// TODO: To be removed in the next version.
|
||||
[FieldDefinition(5, Type = FieldType.Checkbox, Label = "Enable RageID Lookup", HelpText = "Disable this if your tracker doesn't have tvrage ids, Sonarr will then use (more expensive) title queries.", Advanced = true)]
|
||||
public bool EnableRageIDLookup { get; set; }
|
||||
|
||||
public NzbDroneValidationResult Validate()
|
||||
{
|
||||
return new NzbDroneValidationResult(Validator.Validate(this));
|
||||
|
@ -519,6 +519,8 @@
|
||||
<Compile Include="Indexers\KickassTorrents\KickassTorrentsSettings.cs" />
|
||||
<Compile Include="Indexers\KickassTorrents\KickassTorrentsRequestGenerator.cs" />
|
||||
<Compile Include="Indexers\Newznab\Newznab.cs" />
|
||||
<Compile Include="Indexers\Newznab\NewznabCapabilities.cs" />
|
||||
<Compile Include="Indexers\Newznab\NewznabCapabilitiesProvider.cs" />
|
||||
<Compile Include="Indexers\Newznab\NewznabException.cs" />
|
||||
<Compile Include="Indexers\Newznab\NewznabRequestGenerator.cs" />
|
||||
<Compile Include="Indexers\Newznab\NewznabRssParser.cs" />
|
||||
@ -558,11 +560,8 @@
|
||||
<Compile Include="Indexers\TorrentRss\TorrentRssParserFactory.cs" />
|
||||
<Compile Include="Indexers\TorrentRss\TorrentRssSettingsDetector.cs" />
|
||||
<Compile Include="Indexers\TorrentRssParser.cs" />
|
||||
<Compile Include="Indexers\Torznab\TorznabCapabilities.cs" />
|
||||
<Compile Include="Indexers\Torznab\TorznabCapabilitiesProvider.cs" />
|
||||
<Compile Include="Indexers\Torznab\Torznab.cs" />
|
||||
<Compile Include="Indexers\Torznab\TorznabException.cs" />
|
||||
<Compile Include="Indexers\Torznab\TorznabRequestGenerator.cs" />
|
||||
<Compile Include="Indexers\Torznab\TorznabRssParser.cs" />
|
||||
<Compile Include="Indexers\Torznab\TorznabSettings.cs" />
|
||||
<Compile Include="Indexers\Wombles\Wombles.cs" />
|
||||
|
@ -15,6 +15,7 @@ public class ReleaseInfo
|
||||
public int IndexerId { get; set; }
|
||||
public string Indexer { get; set; }
|
||||
public DownloadProtocol DownloadProtocol { get; set; }
|
||||
public int TvdbId { get; set; }
|
||||
public int TvRageId { get; set; }
|
||||
public DateTime PublishDate { get; set; }
|
||||
|
||||
@ -73,6 +74,7 @@ public virtual string ToString(string format)
|
||||
stringBuilder.AppendLine("Indexer: " + Indexer ?? "Empty");
|
||||
stringBuilder.AppendLine("CommentUrl: " + CommentUrl ?? "Empty");
|
||||
stringBuilder.AppendLine("DownloadProtocol: " + DownloadProtocol ?? "Empty");
|
||||
stringBuilder.AppendLine("TvdbId: " + TvdbId ?? "Empty");
|
||||
stringBuilder.AppendLine("TvRageId: " + TvRageId ?? "Empty");
|
||||
stringBuilder.AppendLine("PublishDate: " + PublishDate ?? "Empty");
|
||||
return stringBuilder.ToString();
|
||||
|
@ -16,10 +16,10 @@ public interface IParsingService
|
||||
LocalEpisode GetLocalEpisode(string filename, Series series);
|
||||
LocalEpisode GetLocalEpisode(string filename, Series series, ParsedEpisodeInfo folderInfo, bool sceneSource);
|
||||
Series GetSeries(string title);
|
||||
RemoteEpisode Map(ParsedEpisodeInfo parsedEpisodeInfo, Int32 tvRageId = 0, SearchCriteriaBase searchCriteria = null);
|
||||
RemoteEpisode Map(ParsedEpisodeInfo parsedEpisodeInfo, Int32 seriesId, IEnumerable<Int32> episodeIds);
|
||||
RemoteEpisode Map(ParsedEpisodeInfo parsedEpisodeInfo, int tvdbId, int tvRageId, SearchCriteriaBase searchCriteria = null);
|
||||
RemoteEpisode Map(ParsedEpisodeInfo parsedEpisodeInfo, int seriesId, IEnumerable<int> episodeIds);
|
||||
List<Episode> GetEpisodes(ParsedEpisodeInfo parsedEpisodeInfo, Series series, bool sceneSource, SearchCriteriaBase searchCriteria = null);
|
||||
ParsedEpisodeInfo ParseSpecialEpisodeTitle(string title, int tvRageId, SearchCriteriaBase searchCriteria = null);
|
||||
ParsedEpisodeInfo ParseSpecialEpisodeTitle(string title, int tvdbId, int tvRageId, SearchCriteriaBase searchCriteria = null);
|
||||
}
|
||||
|
||||
public class ParsingService : IParsingService
|
||||
@ -109,14 +109,14 @@ public Series GetSeries(string title)
|
||||
return series;
|
||||
}
|
||||
|
||||
public RemoteEpisode Map(ParsedEpisodeInfo parsedEpisodeInfo, Int32 tvRageId, SearchCriteriaBase searchCriteria = null)
|
||||
public RemoteEpisode Map(ParsedEpisodeInfo parsedEpisodeInfo, int tvdbId, int tvRageId, SearchCriteriaBase searchCriteria = null)
|
||||
{
|
||||
var remoteEpisode = new RemoteEpisode
|
||||
{
|
||||
ParsedEpisodeInfo = parsedEpisodeInfo,
|
||||
};
|
||||
|
||||
var series = GetSeries(parsedEpisodeInfo, tvRageId, searchCriteria);
|
||||
var series = GetSeries(parsedEpisodeInfo, tvdbId, tvRageId, searchCriteria);
|
||||
|
||||
if (series == null)
|
||||
{
|
||||
@ -286,20 +286,19 @@ public List<Episode> GetEpisodes(ParsedEpisodeInfo parsedEpisodeInfo, Series ser
|
||||
return result;
|
||||
}
|
||||
|
||||
public ParsedEpisodeInfo ParseSpecialEpisodeTitle(string title, int tvRageId, SearchCriteriaBase searchCriteria = null)
|
||||
public ParsedEpisodeInfo ParseSpecialEpisodeTitle(string title, int tvdbId, int tvRageId, SearchCriteriaBase searchCriteria = null)
|
||||
{
|
||||
if (searchCriteria != null)
|
||||
{
|
||||
var tvdbId = _sceneMappingService.FindTvdbId(title);
|
||||
if (tvdbId.HasValue)
|
||||
if (tvdbId == 0)
|
||||
tvdbId = _sceneMappingService.FindTvdbId(title) ?? 0;
|
||||
|
||||
if (tvdbId != 0 && tvdbId == searchCriteria.Series.TvdbId)
|
||||
{
|
||||
if (searchCriteria.Series.TvdbId == tvdbId)
|
||||
{
|
||||
return ParseSpecialEpisodeTitle(title, searchCriteria.Series);
|
||||
}
|
||||
return ParseSpecialEpisodeTitle(title, searchCriteria.Series);
|
||||
}
|
||||
|
||||
if (tvRageId == searchCriteria.Series.TvRageId)
|
||||
if (tvRageId != 0 && tvRageId == searchCriteria.Series.TvRageId)
|
||||
{
|
||||
return ParseSpecialEpisodeTitle(title, searchCriteria.Series);
|
||||
}
|
||||
@ -310,6 +309,10 @@ public ParsedEpisodeInfo ParseSpecialEpisodeTitle(string title, int tvRageId, Se
|
||||
{
|
||||
series = _seriesService.FindByTitleInexact(title);
|
||||
}
|
||||
if (series == null && tvdbId > 0)
|
||||
{
|
||||
series = _seriesService.FindByTvdbId(tvdbId);
|
||||
}
|
||||
if (series == null && tvRageId > 0)
|
||||
{
|
||||
series = _seriesService.FindByTvRageId(tvRageId);
|
||||
@ -351,20 +354,19 @@ private ParsedEpisodeInfo ParseSpecialEpisodeTitle(string title, Series series)
|
||||
return null;
|
||||
}
|
||||
|
||||
private Series GetSeries(ParsedEpisodeInfo parsedEpisodeInfo, int tvRageId, SearchCriteriaBase searchCriteria)
|
||||
private Series GetSeries(ParsedEpisodeInfo parsedEpisodeInfo, int tvdbId, int tvRageId, SearchCriteriaBase searchCriteria)
|
||||
{
|
||||
Series series = null;
|
||||
|
||||
var tvdbId = _sceneMappingService.FindTvdbId(parsedEpisodeInfo.SeriesTitle);
|
||||
|
||||
if (tvdbId.HasValue)
|
||||
var sceneMappingTvdbId = _sceneMappingService.FindTvdbId(parsedEpisodeInfo.SeriesTitle);
|
||||
if (sceneMappingTvdbId.HasValue)
|
||||
{
|
||||
if (searchCriteria != null && searchCriteria.Series.TvdbId == tvdbId)
|
||||
if (searchCriteria != null && searchCriteria.Series.TvdbId == sceneMappingTvdbId.Value)
|
||||
{
|
||||
return searchCriteria.Series;
|
||||
}
|
||||
|
||||
series = _seriesService.FindByTvdbId(tvdbId.Value);
|
||||
series = _seriesService.FindByTvdbId(sceneMappingTvdbId.Value);
|
||||
|
||||
if (series == null)
|
||||
{
|
||||
@ -382,6 +384,12 @@ private Series GetSeries(ParsedEpisodeInfo parsedEpisodeInfo, int tvRageId, Sear
|
||||
return searchCriteria.Series;
|
||||
}
|
||||
|
||||
if (tvdbId > 0 && tvdbId == searchCriteria.Series.TvdbId)
|
||||
{
|
||||
//TODO: If series is found by TvdbId, we should report it as a scene naming exception, since it will fail to import
|
||||
return searchCriteria.Series;
|
||||
}
|
||||
|
||||
if (tvRageId > 0 && tvRageId == searchCriteria.Series.TvRageId)
|
||||
{
|
||||
//TODO: If series is found by TvRageId, we should report it as a scene naming exception, since it will fail to import
|
||||
@ -391,6 +399,12 @@ private Series GetSeries(ParsedEpisodeInfo parsedEpisodeInfo, int tvRageId, Sear
|
||||
|
||||
series = _seriesService.FindByTitle(parsedEpisodeInfo.SeriesTitle);
|
||||
|
||||
if (series == null && tvdbId > 0)
|
||||
{
|
||||
//TODO: If series is found by TvdbId, we should report it as a scene naming exception, since it will fail to import
|
||||
series = _seriesService.FindByTvdbId(tvdbId);
|
||||
}
|
||||
|
||||
if (series == null && tvRageId > 0)
|
||||
{
|
||||
//TODO: If series is found by TvRageId, we should report it as a scene naming exception, since it will fail to import
|
||||
|
Loading…
Reference in New Issue
Block a user