Fixed an issue when trying to import files

pull/4/head
Mark McDowall 12 years ago
parent 389201a9eb
commit e8238fb03a

@ -150,18 +150,5 @@ namespace NzbDrone.Core.Test.MediaFileTests.EpisodeImportTests
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());
}
} }
} }

@ -77,7 +77,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport
} }
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);
} }
} }

@ -43,8 +43,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport
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)
{ {

@ -17,5 +17,10 @@ namespace NzbDrone.Core.Parser.Model
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;
}
} }
} }

@ -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 @@ namespace NzbDrone.Core.Parser
_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 @@ namespace NzbDrone.Core.Parser
Series = series, Series = series,
Quality = parsedEpisodeInfo.Quality, Quality = parsedEpisodeInfo.Quality,
Episodes = episodes, Episodes = episodes,
Path = fileName, Path = filename,
ParsedEpisodeInfo = parsedEpisodeInfo ParsedEpisodeInfo = parsedEpisodeInfo
}; };
} }

Loading…
Cancel
Save