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

Fixed an issue when trying to import files

This commit is contained in:
Mark McDowall 2013-07-13 01:11:04 -07:00
parent 389201a9eb
commit e8238fb03a
5 changed files with 12 additions and 20 deletions

View File

@ -150,18 +150,5 @@ public void failed_parse_shouldnt_blowup_the_process()
ExceptionVerification.ExpectedErrors(3); ExceptionVerification.ExpectedErrors(3);
} }
[Test]
public void should_use_filename_without_extension_when_getting_episodes_from_ParsingService()
{
var expectedFilename = Path.GetFileNameWithoutExtension(_videoFiles.First());
GivenSpecifications(_pass1, _pass2, _pass3);
Subject.GetImportDecisions(_videoFiles, _series);
Mocker.GetMock<IParsingService>().Verify(v => v.GetEpisodes(expectedFilename, _series), Times.Once());
}
} }
} }

View File

@ -77,7 +77,7 @@ public List<ImportDecision> Import(List<ImportDecision> decisions, bool newDownl
} }
catch (Exception e) catch (Exception e)
{ {
_logger.WarnException("Couldn't add report to download queue. " + localEpisode, e); _logger.WarnException("Couldn't import episode " + localEpisode, e);
} }
} }

View File

@ -43,8 +43,7 @@ private IEnumerable<ImportDecision> GetDecisions(IEnumerable<String> videoFiles,
try try
{ {
var fileWithoutExtension = Path.GetFileNameWithoutExtension(file); var parsedEpisode = _parsingService.GetEpisodes(file, series);
var parsedEpisode = _parsingService.GetEpisodes(Path.GetFileNameWithoutExtension(file), series);
if (parsedEpisode != null) if (parsedEpisode != null)
{ {

View File

@ -17,5 +17,10 @@ public class LocalEpisode
public QualityModel Quality { get; set; } public QualityModel Quality { get; set; }
public int SeasonNumber { get { return Episodes.Select(c => c.SeasonNumber).Distinct().Single(); } } public int SeasonNumber { get { return Episodes.Select(c => c.SeasonNumber).Distinct().Single(); } }
public override string ToString()
{
return Path;
}
} }
} }

View File

@ -1,4 +1,5 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Linq; using System.Linq;
using NLog; using NLog;
using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Parser.Model;
@ -8,7 +9,7 @@ namespace NzbDrone.Core.Parser
{ {
public interface IParsingService public interface IParsingService
{ {
LocalEpisode GetEpisodes(string fileName, Series series); LocalEpisode GetEpisodes(string filename, Series series);
Series GetSeries(string title); Series GetSeries(string title);
RemoteEpisode Map(ParsedEpisodeInfo parsedEpisodeInfo); RemoteEpisode Map(ParsedEpisodeInfo parsedEpisodeInfo);
} }
@ -26,9 +27,9 @@ public ParsingService(IEpisodeService episodeService, ISeriesService seriesServi
_logger = logger; _logger = logger;
} }
public LocalEpisode GetEpisodes(string fileName, Series series) public LocalEpisode GetEpisodes(string filename, Series series)
{ {
var parsedEpisodeInfo = Parser.ParseTitle(fileName); var parsedEpisodeInfo = Parser.ParsePath(filename);
if (parsedEpisodeInfo == null) if (parsedEpisodeInfo == null)
{ {
@ -47,7 +48,7 @@ public LocalEpisode GetEpisodes(string fileName, Series series)
Series = series, Series = series,
Quality = parsedEpisodeInfo.Quality, Quality = parsedEpisodeInfo.Quality,
Episodes = episodes, Episodes = episodes,
Path = fileName, Path = filename,
ParsedEpisodeInfo = parsedEpisodeInfo ParsedEpisodeInfo = parsedEpisodeInfo
}; };
} }