mirror of
https://github.com/Radarr/Radarr.git
synced 2024-09-11 03:52:33 +02:00
Using Newznab extended attributes to get the tvrage id for matching
This commit is contained in:
parent
42e9d41b33
commit
ad4326a9c4
@ -36,7 +36,7 @@ public ReleaseModule(IFetchAndParseRss rssFetcherAndParser,
|
||||
|
||||
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 @@ public void Setup()
|
||||
_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 @@ 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>()), 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 @@ [Test] 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>()), 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 @@ public void broken_report_shouldnt_blowup_the_process()
|
||||
{
|
||||
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 @@ public void broken_report_shouldnt_blowup_the_process()
|
||||
|
||||
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 @@ private IEnumerable<DownloadDecision> GetDecisions(IEnumerable<ReportInfo> repor
|
||||
|
||||
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 @@ public override IEnumerable<string> RecentFeed
|
||||
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 @@ protected override ReportInfo PostProcessor(XElement item, ReportInfo currentRes
|
||||
{
|
||||
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 @@ protected override ReportInfo PostProcessor(XElement item, ReportInfo currentRes
|
||||
}
|
||||
|
||||
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 @@ public class ReportInfo
|
||||
public String Indexer { get; set; }
|
||||
public int Age { get; set; }
|
||||
public string ReleaseGroup { get; set; }
|
||||
public int TvRageId { get; set; }
|
||||
}
|
||||
}
|
@ -11,7 +11,7 @@ public interface IParsingService
|
||||
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 @@ public Series GetSeries(string title)
|
||||
return _seriesService.FindByTitle(searchTitle);
|
||||
}
|
||||
|
||||
public RemoteEpisode Map(ParsedEpisodeInfo parsedEpisodeInfo)
|
||||
public RemoteEpisode Map(ParsedEpisodeInfo parsedEpisodeInfo, int tvRageId)
|
||||
{
|
||||
var remoteEpisode = new RemoteEpisode
|
||||
{
|
||||
@ -81,6 +81,12 @@ public RemoteEpisode Map(ParsedEpisodeInfo parsedEpisodeInfo)
|
||||
|
||||
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 @@ public interface ISeriesRepository : IBasicRepository<Series>
|
||||
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 @@ public Series FindByTvdbId(int tvdbId)
|
||||
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 @@ public interface ISeriesService
|
||||
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 @@ public Series FindByTvdbId(int tvdbId)
|
||||
return _seriesRepository.FindByTvdbId(tvdbId);
|
||||
}
|
||||
|
||||
public Series FindByTvRageId(int tvRageId)
|
||||
{
|
||||
return _seriesRepository.FindByTvRageId(tvRageId);
|
||||
}
|
||||
|
||||
public Series FindBySlug(string slug)
|
||||
{
|
||||
var series = _seriesRepository.FindBySlug(slug);
|
||||
|
Loading…
Reference in New Issue
Block a user