1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2026-04-24 22:36:19 -04:00

Improve handling of multiple seasons in one file

Fixed: Invalid scene numbering leading to manual import failing to load
Fixes #2255
This commit is contained in:
Mark McDowall
2017-12-28 21:48:05 -08:00
parent 3492d6bbaa
commit e8c5e417b6
5 changed files with 65 additions and 16 deletions
+15 -2
View File
@@ -1,5 +1,6 @@
using System.Linq;
using System.Collections.Generic;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Tv;
using NzbDrone.Core.MediaFiles.MediaInfo;
@@ -26,7 +27,19 @@ namespace NzbDrone.Core.Parser.Model
{
get
{
return Episodes.Select(c => c.SeasonNumber).Distinct().Single();
var seasons = Episodes.Select(c => c.SeasonNumber).Distinct().ToList();
if (seasons.Empty())
{
throw new InvalidSeasonException("Expected one season, but found none");
}
if (seasons.Count > 1)
{
throw new InvalidSeasonException("Expected one season, but found {0} ({1})", seasons.Count, string.Join(", ", seasons));
}
return seasons.Single();
}
}
@@ -37,4 +50,4 @@ namespace NzbDrone.Core.Parser.Model
return Path;
}
}
}
}