EpisodeFile parsing was incorrect due to change of relationship with Episode

pull/3113/head
markus101 14 years ago
parent 891acfff44
commit ce6bcbfec1

@ -51,15 +51,27 @@ namespace NzbDrone.Core.Providers
{ {
var episodesInFile = Parser.ParseEpisodeInfo(filePath); var episodesInFile = Parser.ParseEpisodeInfo(filePath);
//Stores the list of episodes to add to the EpisodeFile
var episodes = new List<Episode>(); var episodes = new List<Episode>();
foreach (var parsedEpisode in episodesInFile) foreach (var parsedEpisode in episodesInFile)
{ {
EpisodeParseResult closureEpisode = parsedEpisode; EpisodeParseResult closureEpisode = parsedEpisode;
var episode = _episodeProvider.GetEpisode(series.SeriesId, closureEpisode.SeasonNumber, var episode = _episodeProvider.GetEpisode(series.SeriesId, closureEpisode.SeasonNumber,
closureEpisode.EpisodeNumber); closureEpisode.EpisodeNumber);
episodes.Add(episode);
if (episode != null) if (episode != null)
{ {
episodes.Add(episode);
}
else
Logger.Warn("Unable to find Series:{0} Season:{1} Episode:{2} in the database. File:{3}", series.Title, closureEpisode.SeasonNumber, closureEpisode.EpisodeNumber, filePath);
}
//Return null if no Episodes exist in the DB for the parsed episodes from file
if (episodes.Count < 1)
return null;
var episodeFile = new EpisodeFile(); var episodeFile = new EpisodeFile();
episodeFile.DateAdded = DateTime.Now; episodeFile.DateAdded = DateTime.Now;
episodeFile.SeriesId = series.SeriesId; episodeFile.SeriesId = series.SeriesId;
@ -69,19 +81,19 @@ namespace NzbDrone.Core.Providers
episodeFile.Quality = Parser.ParseQuality(filePath); episodeFile.Quality = Parser.ParseQuality(filePath);
episodeFile.Proper = Parser.ParseProper(filePath); episodeFile.Proper = Parser.ParseProper(filePath);
_repository.Add(episodeFile); _repository.Add(episodeFile);
Logger.Trace("File {0}:{1} attached to '{2}'", episodeFile.FileId, filePath, episode.EpisodeId);
return episodeFile; //This is for logging, a little ugly...
string episodeList = String.Empty;
foreach (var ep in episodes)
{
episodeList += String.Format(", {0}", ep.EpisodeId).Trim(' ', ',');
} }
Logger.Trace("File {0}:{1} attached to episode(s): '{2}'", episodeFile.FileId, filePath, episodeList);
Logger.Warn("Unable to find Series:{0} Season:{1} Episode:{2} in the database. File:{3}", series.Title, closureEpisode.SeasonNumber, closureEpisode.EpisodeNumber, filePath); return episodeFile;
}
}
else
{
Logger.Trace("[{0}] already exists in the database. skipping.", filePath);
} }
Logger.Trace("[{0}] already exists in the database. skipping.", filePath);
return null; return null;
} }

Loading…
Cancel
Save