better handling of situations where a parsed episode isn't in the database.

pull/3113/head
kay.one 12 years ago
parent 4e06cf0fa6
commit 6144ff8f3e

@ -120,7 +120,7 @@ namespace NzbDrone.Core.Parser
if (series.UseSceneNumbering && parsedEpisodeInfo.SceneSource) if (series.UseSceneNumbering && parsedEpisodeInfo.SceneSource)
{ {
episodeInfo = _episodeService.GetEpisode(series.Id, parsedEpisodeInfo.SeasonNumber, episodeNumber, true); episodeInfo = _episodeService.FindEpisode(series.Id, parsedEpisodeInfo.SeasonNumber, episodeNumber, true);
} }
if (episodeInfo == null) if (episodeInfo == null)
@ -128,7 +128,7 @@ namespace NzbDrone.Core.Parser
episodeInfo = _episodeService.GetEpisode(series.Id, parsedEpisodeInfo.SeasonNumber, episodeNumber); episodeInfo = _episodeService.GetEpisode(series.Id, parsedEpisodeInfo.SeasonNumber, episodeNumber);
if (episodeInfo == null && parsedEpisodeInfo.AirDate != null) if (episodeInfo == null && parsedEpisodeInfo.AirDate != null)
{ {
episodeInfo = _episodeService.GetEpisode(series.Id, parsedEpisodeInfo.AirDate.Value); episodeInfo = _episodeService.FindEpisode(series.Id, parsedEpisodeInfo.AirDate.Value);
} }
} }

@ -13,12 +13,15 @@ namespace NzbDrone.Core.Tv
public interface IEpisodeRepository : IBasicRepository<Episode> public interface IEpisodeRepository : IBasicRepository<Episode>
{ {
Episode Get(int seriesId, int season, int episodeNumber); Episode Get(int seriesId, int season, int episodeNumber);
Episode Find(int seriesId, int season, int episodeNumber);
Episode Get(int seriesId, DateTime date); Episode Get(int seriesId, DateTime date);
Episode Find(int seriesId, DateTime date);
List<Episode> GetEpisodes(int seriesId); List<Episode> GetEpisodes(int seriesId);
List<Episode> GetEpisodes(int seriesId, int seasonNumber); List<Episode> GetEpisodes(int seriesId, int seasonNumber);
List<Episode> GetEpisodeByFileId(int fileId); List<Episode> GetEpisodeByFileId(int fileId);
PagingSpec<Episode> EpisodesWithoutFiles(PagingSpec<Episode> pagingSpec, bool includeSpecials); PagingSpec<Episode> EpisodesWithoutFiles(PagingSpec<Episode> pagingSpec, bool includeSpecials);
Episode GetEpisodeBySceneNumbering(int seriesId, int seasonNumber, int episodeNumber); Episode GetEpisodeBySceneNumbering(int seriesId, int seasonNumber, int episodeNumber);
Episode FindEpisodeBySceneNumbering(int seriesId, int seasonNumber, int episodeNumber);
List<Episode> EpisodesWithFiles(); List<Episode> EpisodesWithFiles();
List<Episode> EpisodesBetweenDates(DateTime startDate, DateTime endDate); List<Episode> EpisodesBetweenDates(DateTime startDate, DateTime endDate);
void SetIgnoreFlat(Episode episode, bool ignoreFlag); void SetIgnoreFlat(Episode episode, bool ignoreFlag);
@ -40,11 +43,21 @@ namespace NzbDrone.Core.Tv
return Query.Single(s => s.SeriesId == seriesId && s.SeasonNumber == season && s.EpisodeNumber == episodeNumber); return Query.Single(s => s.SeriesId == seriesId && s.SeasonNumber == season && s.EpisodeNumber == episodeNumber);
} }
public Episode Find(int seriesId, int season, int episodeNumber)
{
return Query.SingleOrDefault(s => s.SeriesId == seriesId && s.SeasonNumber == season && s.EpisodeNumber == episodeNumber);
}
public Episode Get(int seriesId, DateTime date) public Episode Get(int seriesId, DateTime date)
{ {
return Query.Single(s => s.SeriesId == seriesId && s.AirDate.HasValue && s.AirDate.Value.Date == date.Date); return Query.Single(s => s.SeriesId == seriesId && s.AirDate.HasValue && s.AirDate.Value.Date == date.Date);
} }
public Episode Find(int seriesId, DateTime date)
{
return Query.SingleOrDefault(s => s.SeriesId == seriesId && s.AirDate.HasValue && s.AirDate.Value.Date == date.Date);
}
public List<Episode> GetEpisodes(int seriesId) public List<Episode> GetEpisodes(int seriesId)
{ {
return Query.Where(s => s.SeriesId == seriesId).ToList(); return Query.Where(s => s.SeriesId == seriesId).ToList();
@ -81,7 +94,7 @@ namespace NzbDrone.Core.Tv
pagingSpec.Records = pagingQuery.ToList(); pagingSpec.Records = pagingQuery.ToList();
//TODO: Use the same query for count and records //TODO: Use the same query for count and records
pagingSpec.TotalRecords = Query.Where(e => e.EpisodeFileId == 0 && e.SeasonNumber >= startingSeasonNumber && e.AirDate <= currentTime).Count(); pagingSpec.TotalRecords = Query.Count(e => e.EpisodeFileId == 0 && e.SeasonNumber >= startingSeasonNumber && e.AirDate <= currentTime);
return pagingSpec; return pagingSpec;
} }
@ -91,6 +104,11 @@ namespace NzbDrone.Core.Tv
return Query.Single(s => s.SeriesId == seriesId && s.SeasonNumber == seasonNumber && s.SceneEpisodeNumber == episodeNumber); return Query.Single(s => s.SeriesId == seriesId && s.SeasonNumber == seasonNumber && s.SceneEpisodeNumber == episodeNumber);
} }
public Episode FindEpisodeBySceneNumbering(int seriesId, int seasonNumber, int episodeNumber)
{
return Query.SingleOrDefault(s => s.SeriesId == seriesId && s.SeasonNumber == seasonNumber && s.SceneEpisodeNumber == episodeNumber);
}
public List<Episode> EpisodesWithFiles() public List<Episode> EpisodesWithFiles()
{ {
return Query.Where(s => s.EpisodeFileId != 0).ToList(); return Query.Where(s => s.EpisodeFileId != 0).ToList();

@ -5,11 +5,8 @@ using NLog;
using NzbDrone.Common.Messaging; using NzbDrone.Common.Messaging;
using NzbDrone.Core.Configuration; using NzbDrone.Core.Configuration;
using NzbDrone.Core.Datastore; using NzbDrone.Core.Datastore;
using NzbDrone.Core.Download;
using NzbDrone.Core.Helpers;
using NzbDrone.Core.MediaFiles.Events; using NzbDrone.Core.MediaFiles.Events;
using NzbDrone.Core.MetadataSource; using NzbDrone.Core.MetadataSource;
using NzbDrone.Core.Model;
using NzbDrone.Core.Tv.Events; using NzbDrone.Core.Tv.Events;
namespace NzbDrone.Core.Tv namespace NzbDrone.Core.Tv
@ -18,7 +15,9 @@ namespace NzbDrone.Core.Tv
{ {
Episode GetEpisode(int id); Episode GetEpisode(int id);
Episode GetEpisode(int seriesId, int seasonNumber, int episodeNumber, bool useScene = false); Episode GetEpisode(int seriesId, int seasonNumber, int episodeNumber, bool useScene = false);
Episode FindEpisode(int seriesId, int seasonNumber, int episodeNumber, bool useScene = false);
Episode GetEpisode(int seriesId, DateTime date); Episode GetEpisode(int seriesId, DateTime date);
Episode FindEpisode(int seriesId, DateTime date);
List<Episode> GetEpisodeBySeries(int seriesId); List<Episode> GetEpisodeBySeries(int seriesId);
List<Episode> GetEpisodesBySeason(int seriesId, int seasonNumber); List<Episode> GetEpisodesBySeason(int seriesId, int seasonNumber);
PagingSpec<Episode> EpisodesWithoutFiles(PagingSpec<Episode> pagingSpec); PagingSpec<Episode> EpisodesWithoutFiles(PagingSpec<Episode> pagingSpec);
@ -75,7 +74,16 @@ namespace NzbDrone.Core.Tv
{ {
return _episodeRepository.GetEpisodeBySceneNumbering(seriesId, seasonNumber, episodeNumber); return _episodeRepository.GetEpisodeBySceneNumbering(seriesId, seasonNumber, episodeNumber);
} }
return _episodeRepository.Get(seriesId, seasonNumber, episodeNumber); return _episodeRepository.Find(seriesId, seasonNumber, episodeNumber);
}
public Episode FindEpisode(int seriesId, int seasonNumber, int episodeNumber, bool useSceneNumbering = false)
{
if (useSceneNumbering)
{
return _episodeRepository.FindEpisodeBySceneNumbering(seriesId, seasonNumber, episodeNumber);
}
return _episodeRepository.Find(seriesId, seasonNumber, episodeNumber);
} }
public Episode GetEpisode(int seriesId, DateTime date) public Episode GetEpisode(int seriesId, DateTime date)
@ -83,6 +91,11 @@ namespace NzbDrone.Core.Tv
return _episodeRepository.Get(seriesId, date); return _episodeRepository.Get(seriesId, date);
} }
public Episode FindEpisode(int seriesId, DateTime date)
{
return _episodeRepository.Find(seriesId, date);
}
public List<Episode> GetEpisodeBySeries(int seriesId) public List<Episode> GetEpisodeBySeries(int seriesId)
{ {
return _episodeRepository.GetEpisodes(seriesId).ToList(); return _episodeRepository.GetEpisodes(seriesId).ToList();

@ -14,6 +14,7 @@
<div class="row"> <div class="row">
<span class="label label-info">{{network}}</span> <span class="label label-info">{{network}}</span>
<span class="label label-info">{{runtime}} minutes</span> <span class="label label-info">{{runtime}} minutes</span>
<span class="label label-info">{{path}}</span>
</div> </div>
</div> </div>
</div> </div>

Loading…
Cancel
Save