Fixed: Doki rss feed now uses correct url for torrent.

This commit is contained in:
Taloth Saldono 2015-07-13 20:26:00 +02:00
parent 51155ba909
commit 3ad7673d69
6 changed files with 80 additions and 2 deletions

View File

@ -123,5 +123,33 @@ namespace NzbDrone.Core.Test.IndexerTests.TorrentRssIndexerTests
torrentInfo.Peers.Should().NotHaveValue();
torrentInfo.Seeders.Should().NotHaveValue();
}
[Test]
public void should_parse_recent_feed_from_Doki()
{
Subject.Definition.Settings.As<TorrentRssIndexerSettings>().AllowZeroSize = true;
GivenRecentFeedResponse("TorrentRss/Doki.xml");
var releases = Subject.FetchRecent();
releases.Should().HaveCount(5);
releases.First().Should().BeOfType<TorrentInfo>();
var torrentInfo = releases.First() as TorrentInfo;
torrentInfo.Title.Should().Be("[Doki] PriPara 50 (848x480 h264 AAC) [6F0B49FD] mkv");
torrentInfo.DownloadProtocol.Should().Be(DownloadProtocol.Torrent);
torrentInfo.DownloadUrl.Should().Be("http://tracker.anime-index.org/download.php?id=82d8ad84403e01a7786130905ca169a3429e657f&f=%5BDoki%5D+PriPara+-+50+%28848x480+h264+AAC%29+%5B6F0B49FD%5D.mkv.torrent");
torrentInfo.InfoUrl.Should().BeNullOrEmpty();
torrentInfo.CommentUrl.Should().BeNullOrEmpty();
torrentInfo.Indexer.Should().Be(Subject.Definition.Name);
torrentInfo.PublishDate.Should().Be(DateTime.Parse("Thu, 02 Jul 2015 08:18:29 GMT").ToUniversalTime());
torrentInfo.Size.Should().Be(0);
torrentInfo.InfoHash.Should().BeNull();
torrentInfo.MagnetUrl.Should().BeNull();
torrentInfo.Peers.Should().NotHaveValue();
torrentInfo.Seeders.Should().NotHaveValue();
}
}
}

View File

@ -43,6 +43,7 @@ namespace NzbDrone.Core.Test.IndexerTests.TorrentRssIndexerTests
settings.ShouldBeEquivalentTo(new TorrentRssIndexerParserSettings
{
UseEZTVFormat = true,
UseEnclosureUrl = false,
UseEnclosureLength = false,
ParseSizeInDescription = false,
ParseSeedersInDescription = false,
@ -60,6 +61,7 @@ namespace NzbDrone.Core.Test.IndexerTests.TorrentRssIndexerTests
settings.ShouldBeEquivalentTo(new TorrentRssIndexerParserSettings
{
UseEZTVFormat = false,
UseEnclosureUrl = false,
UseEnclosureLength = false,
ParseSizeInDescription = true,
ParseSeedersInDescription = false,
@ -77,6 +79,7 @@ namespace NzbDrone.Core.Test.IndexerTests.TorrentRssIndexerTests
settings.ShouldBeEquivalentTo(new TorrentRssIndexerParserSettings
{
UseEZTVFormat = false,
UseEnclosureUrl = false,
UseEnclosureLength = false,
ParseSizeInDescription = true,
ParseSeedersInDescription = true,
@ -96,6 +99,7 @@ namespace NzbDrone.Core.Test.IndexerTests.TorrentRssIndexerTests
settings.ShouldBeEquivalentTo(new TorrentRssIndexerParserSettings
{
UseEZTVFormat = false,
UseEnclosureUrl = true,
UseEnclosureLength = false,
ParseSizeInDescription = false,
ParseSeedersInDescription = false,
@ -113,6 +117,7 @@ namespace NzbDrone.Core.Test.IndexerTests.TorrentRssIndexerTests
settings.ShouldBeEquivalentTo(new TorrentRssIndexerParserSettings
{
UseEZTVFormat = false,
UseEnclosureUrl = true,
UseEnclosureLength = false,
ParseSizeInDescription = true,
ParseSeedersInDescription = false,
@ -130,6 +135,7 @@ namespace NzbDrone.Core.Test.IndexerTests.TorrentRssIndexerTests
settings.ShouldBeEquivalentTo(new TorrentRssIndexerParserSettings
{
UseEZTVFormat = false,
UseEnclosureUrl = false,
UseEnclosureLength = false,
ParseSizeInDescription = false,
ParseSeedersInDescription = false,
@ -137,6 +143,26 @@ namespace NzbDrone.Core.Test.IndexerTests.TorrentRssIndexerTests
});
}
[Test]
public void should_detect_rss_settings_for_Doki()
{
_indexerSettings.AllowZeroSize = true;
GivenRecentFeedResponse("TorrentRss/Doki.xml");
var settings = Subject.Detect(_indexerSettings);
settings.ShouldBeEquivalentTo(new TorrentRssIndexerParserSettings
{
UseEZTVFormat = false,
UseEnclosureUrl = true,
UseEnclosureLength = false,
ParseSizeInDescription = false,
ParseSeedersInDescription = false,
SizeElementName = null
});
}
[Test]
[Ignore("Cannot reliably reject unparseable titles")]
public void should_reject_rss_settings_for_AwesomeHD()

View File

@ -6,6 +6,7 @@ namespace NzbDrone.Core.Indexers.TorrentRss
{
public bool UseEZTVFormat { get; set; }
public bool ParseSeedersInDescription { get; set; }
public bool UseEnclosureUrl { get; set; }
public bool UseEnclosureLength { get; set; }
public bool ParseSizeInDescription { get; set; }
public string SizeElementName { get; set; }

View File

@ -42,6 +42,7 @@ namespace NzbDrone.Core.Indexers.TorrentRss
UseGuidInfoUrl = false,
ParseSeedersInDescription = parserSettings.ParseSeedersInDescription,
UseEnclosureUrl = parserSettings.UseEnclosureUrl,
UseEnclosureLength = parserSettings.UseEnclosureLength,
ParseSizeInDescription = parserSettings.ParseSizeInDescription,
SizeElementName = parserSettings.SizeElementName

View File

@ -107,18 +107,31 @@ namespace NzbDrone.Core.Indexers.TorrentRss
private TorrentRssIndexerParserSettings GetGenericTorrentRssParserSettings(IndexerResponse response, TorrentRssIndexerSettings indexerSettings)
{
var settings = new TorrentRssIndexerParserSettings
var parser = new TorrentRssParser
{
UseEnclosureUrl = true,
UseEnclosureLength = true,
ParseSeedersInDescription = true
};
var parser = new TorrentRssParser
var item = parser.GetItems(response).FirstOrDefault();
if (item == null)
{
throw new UnsupportedFeedException("Empty feed, cannot check if feed is parsable.");
}
var settings = new TorrentRssIndexerParserSettings()
{
UseEnclosureUrl = true,
UseEnclosureLength = true,
ParseSeedersInDescription = true
};
if (item.Element("enclosure") == null)
{
parser.UseEnclosureUrl = settings.UseEnclosureUrl = false;
}
var releases = ParseResponse(parser, response);
ValidateReleases(releases, indexerSettings);

View File

@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Xml.Linq;
using NzbDrone.Common.Extensions;
@ -19,6 +20,14 @@ namespace NzbDrone.Core.Indexers
}
public IEnumerable<XElement> GetItems(IndexerResponse indexerResponse)
{
var document = LoadXmlDocument(indexerResponse);
var items = GetItems(document);
return items;
}
protected override ReleaseInfo CreateNewReleaseInfo()
{
return new TorrentInfo();