1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-16 11:37:58 +02:00

Rss will only download each episode once

This commit is contained in:
Mark McDowall 2013-05-13 23:22:25 -07:00
parent cdc9098ac7
commit e851924417

View File

@ -1,4 +1,5 @@
using System; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using NLog; using NLog;
using NzbDrone.Common.Messaging; using NzbDrone.Common.Messaging;
@ -35,9 +36,6 @@ public void Sync()
var reports = _rssFetcherAndParser.Fetch(); var reports = _rssFetcherAndParser.Fetch();
var decisions = _downloadDecisionMaker.GetRssDecision(reports); var decisions = _downloadDecisionMaker.GetRssDecision(reports);
//TODO: this will download multiple of same episode if they show up in RSS. need to
//proposal: maybe get download decision one by one, that way
var qualifiedReports = decisions var qualifiedReports = decisions
.Where(c => c.Approved) .Where(c => c.Approved)
.Select(c => c.RemoteEpisode) .Select(c => c.RemoteEpisode)
@ -45,11 +43,16 @@ public void Sync()
.ThenBy(c => c.Episodes.Select(e => e.EpisodeNumber).MinOrDefault()) .ThenBy(c => c.Episodes.Select(e => e.EpisodeNumber).MinOrDefault())
.ThenBy(c => c.Report.Age); .ThenBy(c => c.Report.Age);
var downloadedReports = new List<int>();
foreach (var episodeParseResult in qualifiedReports) foreach (var episodeParseResult in qualifiedReports)
{ {
try try
{ {
if (downloadedReports.Intersect(episodeParseResult.Episodes.Select(e => e.Id)).Any()) continue;
_downloadService.DownloadReport(episodeParseResult); _downloadService.DownloadReport(episodeParseResult);
downloadedReports.AddRange(episodeParseResult.Episodes.Select(e => e.Id));
} }
catch (Exception e) catch (Exception e)
{ {