mirror of https://github.com/Sonarr/Sonarr
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:
parent
3492d6bbaa
commit
e8c5e417b6
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
@ -205,10 +205,23 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Manual
|
|||
item.Series = decision.LocalEpisode.Series;
|
||||
}
|
||||
|
||||
if (decision.LocalEpisode.Episodes.Any())
|
||||
if (decision.LocalEpisode.Episodes.Any() && decision.LocalEpisode.Episodes.Select(c => c.SeasonNumber).Distinct().Count() == 1)
|
||||
{
|
||||
item.SeasonNumber = decision.LocalEpisode.SeasonNumber;
|
||||
item.Episodes = decision.LocalEpisode.Episodes;
|
||||
var seasons = decision.LocalEpisode.Episodes.Select(c => c.SeasonNumber).Distinct().ToList();
|
||||
|
||||
if (seasons.Empty())
|
||||
{
|
||||
_logger.Warn("Expected one season, but found none for: {0}", decision.LocalEpisode.Path);
|
||||
}
|
||||
else if (seasons.Count > 1)
|
||||
{
|
||||
_logger.Warn("Expected one season, but found {0} ({1}) for: {2}", seasons.Count, string.Join(", ", seasons), decision.LocalEpisode.Path);
|
||||
}
|
||||
else
|
||||
{
|
||||
item.SeasonNumber = decision.LocalEpisode.SeasonNumber;
|
||||
item.Episodes = decision.LocalEpisode.Episodes;
|
||||
}
|
||||
}
|
||||
|
||||
item.Quality = decision.LocalEpisode.Quality;
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
using NLog;
|
||||
using System;
|
||||
using NLog;
|
||||
using NzbDrone.Core.DecisionEngine;
|
||||
using NzbDrone.Core.Download;
|
||||
using NzbDrone.Core.Parser;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
|
||||
namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications
|
||||
|
@ -25,18 +27,23 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications
|
|||
return Decision.Accept();
|
||||
}
|
||||
|
||||
var sample = _detectSample.IsSample(localEpisode.Series,
|
||||
localEpisode.Path,
|
||||
localEpisode.IsSpecial);
|
||||
|
||||
if (sample == DetectSampleResult.Sample)
|
||||
try
|
||||
{
|
||||
return Decision.Reject("Sample");
|
||||
var sample = _detectSample.IsSample(localEpisode.Series, localEpisode.Path, localEpisode.IsSpecial);
|
||||
|
||||
if (sample == DetectSampleResult.Sample)
|
||||
{
|
||||
return Decision.Reject("Sample");
|
||||
}
|
||||
|
||||
else if (sample == DetectSampleResult.Indeterminate)
|
||||
{
|
||||
return Decision.Reject("Unable to determine if file is a sample");
|
||||
}
|
||||
}
|
||||
|
||||
else if (sample == DetectSampleResult.Indeterminate)
|
||||
catch (InvalidSeasonException e)
|
||||
{
|
||||
return Decision.Reject("Unable to determine if file is a sample");
|
||||
_logger.Warn(e, "Invalid season detected during sample check");
|
||||
}
|
||||
|
||||
return Decision.Accept();
|
||||
|
|
|
@ -936,6 +936,7 @@
|
|||
<Compile Include="Notifications\Twitter\Twitter.cs" />
|
||||
<Compile Include="Notifications\Twitter\TwitterService.cs" />
|
||||
<Compile Include="Notifications\Twitter\TwitterSettings.cs" />
|
||||
<Compile Include="Parser\InvalidSeasonException.cs" />
|
||||
<Compile Include="Parser\IsoLanguage.cs" />
|
||||
<Compile Include="Parser\IsoLanguages.cs" />
|
||||
<Compile Include="Parser\LanguageParser.cs" />
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
using NzbDrone.Common.Exceptions;
|
||||
|
||||
namespace NzbDrone.Core.Parser
|
||||
{
|
||||
public class InvalidSeasonException : NzbDroneException
|
||||
{
|
||||
public InvalidSeasonException(string message, params object[] args) : base(message, args)
|
||||
{
|
||||
}
|
||||
|
||||
public InvalidSeasonException(string message) : base(message)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue