Using Newznab extended attributes to get the tvrage id for matching

pull/3113/head
Mark McDowall 11 years ago
parent 42e9d41b33
commit ad4326a9c4

@ -36,7 +36,7 @@ namespace NzbDrone.Api.Indexers
private ReleaseResource DownloadRelease(ReleaseResource release)
{
var remoteEpisode = _parsingService.Map(release.InjectTo<ParsedEpisodeInfo>());
var remoteEpisode = _parsingService.Map(release.InjectTo<ParsedEpisodeInfo>(), 0);
remoteEpisode.Report = release.InjectTo<ReportInfo>();
_downloadService.DownloadReport(remoteEpisode);

@ -59,7 +59,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
_reports = new List<ReportInfo> { new ReportInfo { Title = "The.Office.S03E115.DVDRip.XviD-OSiTV" } };
_remoteEpisode = new RemoteEpisode { Series = new Series() };
Mocker.GetMock<IParsingService>().Setup(c => c.Map(It.IsAny<ParsedEpisodeInfo>()))
Mocker.GetMock<IParsingService>().Setup(c => c.Map(It.IsAny<ParsedEpisodeInfo>(), It.IsAny<int>()))
.Returns(_remoteEpisode);
}
@ -130,7 +130,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
var results = Subject.GetRssDecision(_reports).ToList();
Mocker.GetMock<IParsingService>().Verify(c => c.Map(It.IsAny<ParsedEpisodeInfo>()), Times.Never());
Mocker.GetMock<IParsingService>().Verify(c => c.Map(It.IsAny<ParsedEpisodeInfo>(), It.IsAny<int>()), Times.Never());
_pass1.Verify(c => c.IsSatisfiedBy(It.IsAny<RemoteEpisode>(), null), Times.Never());
_pass2.Verify(c => c.IsSatisfiedBy(It.IsAny<RemoteEpisode>(), null), Times.Never());
@ -146,7 +146,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
var results = Subject.GetRssDecision(_reports).ToList();
Mocker.GetMock<IParsingService>().Verify(c => c.Map(It.IsAny<ParsedEpisodeInfo>()), Times.Never());
Mocker.GetMock<IParsingService>().Verify(c => c.Map(It.IsAny<ParsedEpisodeInfo>(), It.IsAny<int>()), Times.Never());
_pass1.Verify(c => c.IsSatisfiedBy(It.IsAny<RemoteEpisode>(), null), Times.Never());
_pass2.Verify(c => c.IsSatisfiedBy(It.IsAny<RemoteEpisode>(), null), Times.Never());
@ -174,7 +174,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
{
GivenSpecifications(_pass1);
Mocker.GetMock<IParsingService>().Setup(c => c.Map(It.IsAny<ParsedEpisodeInfo>()))
Mocker.GetMock<IParsingService>().Setup(c => c.Map(It.IsAny<ParsedEpisodeInfo>(), It.IsAny<int>()))
.Throws<TestException>();
_reports = new List<ReportInfo>
@ -186,7 +186,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
Subject.GetRssDecision(_reports);
Mocker.GetMock<IParsingService>().Verify(c => c.Map(It.IsAny<ParsedEpisodeInfo>()), Times.Exactly(_reports.Count));
Mocker.GetMock<IParsingService>().Verify(c => c.Map(It.IsAny<ParsedEpisodeInfo>(), It.IsAny<int>()), Times.Exactly(_reports.Count));
ExceptionVerification.ExpectedErrors(3);
}

@ -51,7 +51,7 @@ namespace NzbDrone.Core.DecisionEngine
if (parsedEpisodeInfo != null && !string.IsNullOrWhiteSpace(parsedEpisodeInfo.SeriesTitle))
{
var remoteEpisode = _parsingService.Map(parsedEpisodeInfo);
var remoteEpisode = _parsingService.Map(parsedEpisodeInfo, report.TvRageId);
remoteEpisode.Report = report;
if (remoteEpisode.Series != null)

@ -73,7 +73,7 @@ namespace NzbDrone.Core.Indexers.Newznab
Settings.Categories = new List<int> { 5000 };
}
var url = String.Format("{0}/api?t=tvsearch&cat={1}", Settings.Url.TrimEnd('/'), String.Join(",", Settings.Categories));
var url = String.Format("{0}/api?t=tvsearch&cat={1}&extended=1", Settings.Url.TrimEnd('/'), String.Join(",", Settings.Categories));
if (!String.IsNullOrWhiteSpace(Settings.ApiKey))
{

@ -20,8 +20,9 @@ namespace NzbDrone.Core.Indexers.Newznab
{
if (currentResult != null)
{
var attributes = item.Elements(NewznabNamespace + "attr");
var sizeElement = attributes.SingleOrDefault(e => e.Attribute("name").Value == "size");
var attributes = item.Elements(NewznabNamespace + "attr").ToList();
var sizeElement = attributes.SingleOrDefault(e => e.Attribute("name").Value.Equals("size", StringComparison.CurrentCultureIgnoreCase));
var rageIdElement = attributes.SingleOrDefault(e => e.Attribute("name").Value.Equals("rageid", StringComparison.CurrentCultureIgnoreCase));
if (sizeElement == null)
{
@ -29,6 +30,11 @@ namespace NzbDrone.Core.Indexers.Newznab
}
currentResult.Size = Convert.ToInt64(sizeElement.Attribute("value").Value);
if (rageIdElement != null)
{
currentResult.TvRageId = Convert.ToInt32(rageIdElement.Attribute("value").Value);
}
}
return currentResult;

@ -11,5 +11,6 @@ namespace NzbDrone.Core.Parser.Model
public String Indexer { get; set; }
public int Age { get; set; }
public string ReleaseGroup { get; set; }
public int TvRageId { get; set; }
}
}

@ -11,7 +11,7 @@ namespace NzbDrone.Core.Parser
LocalEpisode GetEpisodes(string filename, Series series);
LocalEpisode GetEpisodes(string filename, Series series, bool sceneSource);
Series GetSeries(string title);
RemoteEpisode Map(ParsedEpisodeInfo parsedEpisodeInfo);
RemoteEpisode Map(ParsedEpisodeInfo parsedEpisodeInfo, int tvRageId);
}
public class ParsingService : IParsingService
@ -72,7 +72,7 @@ namespace NzbDrone.Core.Parser
return _seriesService.FindByTitle(searchTitle);
}
public RemoteEpisode Map(ParsedEpisodeInfo parsedEpisodeInfo)
public RemoteEpisode Map(ParsedEpisodeInfo parsedEpisodeInfo, int tvRageId)
{
var remoteEpisode = new RemoteEpisode
{
@ -81,6 +81,12 @@ namespace NzbDrone.Core.Parser
var series = _seriesService.FindByTitle(parsedEpisodeInfo.SeriesTitle);
if (series == null && tvRageId > 0)
{
series = _seriesService.FindByTvRageId(tvRageId);
//TODO: If series is found by TvRageId, we should report it as a scene naming exception, since it will fail to import
}
if (series == null)
{
_logger.Trace("No matching series {0}", parsedEpisodeInfo.SeriesTitle);

@ -12,6 +12,7 @@ namespace NzbDrone.Core.Tv
List<Series> Search(string title);
Series FindByTitle(string cleanTitle);
Series FindByTvdbId(int tvdbId);
Series FindByTvRageId(int tvRageId);
void SetSeriesType(int seriesId, SeriesTypes seriesTypes);
Series FindBySlug(string slug);
List<String> GetSeriesPaths();
@ -44,6 +45,11 @@ namespace NzbDrone.Core.Tv
return Query.SingleOrDefault(s => s.TvdbId.Equals(tvdbId));
}
public Series FindByTvRageId(int tvRageId)
{
return Query.SingleOrDefault(s => s.TvRageId.Equals(tvRageId));
}
public void SetSeriesType(int seriesId, SeriesTypes seriesType)
{
SetFields(new Series { Id = seriesId, SeriesType = seriesType }, s => s.SeriesType);

@ -19,6 +19,7 @@ namespace NzbDrone.Core.Tv
Series AddSeries(Series newSeries);
void UpdateFromSeriesEditor(IList<Series> editedSeries);
Series FindByTvdbId(int tvdbId);
Series FindByTvRageId(int tvRageId);
Series FindByTitle(string title);
void SetSeriesType(int seriesId, SeriesTypes seriesTypes);
void DeleteSeries(int seriesId, bool deleteFiles);
@ -107,6 +108,11 @@ namespace NzbDrone.Core.Tv
return _seriesRepository.FindByTvdbId(tvdbId);
}
public Series FindByTvRageId(int tvRageId)
{
return _seriesRepository.FindByTvRageId(tvRageId);
}
public Series FindBySlug(string slug)
{
var series = _seriesRepository.FindBySlug(slug);

Loading…
Cancel
Save