mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-04 10:02:40 +01:00
better handling of situations where a parsed episode isn't in the database.
This commit is contained in:
parent
4e06cf0fa6
commit
6144ff8f3e
@ -64,7 +64,7 @@ public Series GetSeries(string title)
|
||||
return _seriesService.FindByTitle(searchTitle);
|
||||
}
|
||||
|
||||
public RemoteEpisode Map(ParsedEpisodeInfo parsedEpisodeInfo)
|
||||
public RemoteEpisode Map(ParsedEpisodeInfo parsedEpisodeInfo)
|
||||
{
|
||||
var remoteEpisode = new RemoteEpisode
|
||||
{
|
||||
@ -120,7 +120,7 @@ private List<Episode> GetEpisodes(ParsedEpisodeInfo parsedEpisodeInfo, Series se
|
||||
|
||||
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)
|
||||
@ -128,7 +128,7 @@ private List<Episode> GetEpisodes(ParsedEpisodeInfo parsedEpisodeInfo, Series se
|
||||
episodeInfo = _episodeService.GetEpisode(series.Id, parsedEpisodeInfo.SeasonNumber, episodeNumber);
|
||||
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>
|
||||
{
|
||||
Episode Get(int seriesId, int season, int episodeNumber);
|
||||
Episode Find(int seriesId, int season, int episodeNumber);
|
||||
Episode Get(int seriesId, DateTime date);
|
||||
Episode Find(int seriesId, DateTime date);
|
||||
List<Episode> GetEpisodes(int seriesId);
|
||||
List<Episode> GetEpisodes(int seriesId, int seasonNumber);
|
||||
List<Episode> GetEpisodeByFileId(int fileId);
|
||||
PagingSpec<Episode> EpisodesWithoutFiles(PagingSpec<Episode> pagingSpec, bool includeSpecials);
|
||||
Episode GetEpisodeBySceneNumbering(int seriesId, int seasonNumber, int episodeNumber);
|
||||
Episode FindEpisodeBySceneNumbering(int seriesId, int seasonNumber, int episodeNumber);
|
||||
List<Episode> EpisodesWithFiles();
|
||||
List<Episode> EpisodesBetweenDates(DateTime startDate, DateTime endDate);
|
||||
void SetIgnoreFlat(Episode episode, bool ignoreFlag);
|
||||
@ -40,11 +43,21 @@ public Episode Get(int seriesId, int season, int 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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
return Query.Where(s => s.SeriesId == seriesId).ToList();
|
||||
@ -81,7 +94,7 @@ public PagingSpec<Episode> EpisodesWithoutFiles(PagingSpec<Episode> pagingSpec,
|
||||
pagingSpec.Records = pagingQuery.ToList();
|
||||
|
||||
//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;
|
||||
}
|
||||
@ -91,6 +104,11 @@ public Episode GetEpisodeBySceneNumbering(int seriesId, int seasonNumber, int ep
|
||||
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()
|
||||
{
|
||||
return Query.Where(s => s.EpisodeFileId != 0).ToList();
|
||||
|
@ -5,11 +5,8 @@
|
||||
using NzbDrone.Common.Messaging;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.Download;
|
||||
using NzbDrone.Core.Helpers;
|
||||
using NzbDrone.Core.MediaFiles.Events;
|
||||
using NzbDrone.Core.MetadataSource;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Tv.Events;
|
||||
|
||||
namespace NzbDrone.Core.Tv
|
||||
@ -18,7 +15,9 @@ public interface IEpisodeService
|
||||
{
|
||||
Episode GetEpisode(int id);
|
||||
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 FindEpisode(int seriesId, DateTime date);
|
||||
List<Episode> GetEpisodeBySeries(int seriesId);
|
||||
List<Episode> GetEpisodesBySeason(int seriesId, int seasonNumber);
|
||||
PagingSpec<Episode> EpisodesWithoutFiles(PagingSpec<Episode> pagingSpec);
|
||||
@ -75,7 +74,16 @@ public Episode GetEpisode(int seriesId, int seasonNumber, int episodeNumber, boo
|
||||
{
|
||||
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)
|
||||
@ -83,6 +91,11 @@ public Episode GetEpisode(int seriesId, DateTime date)
|
||||
return _episodeRepository.Get(seriesId, date);
|
||||
}
|
||||
|
||||
public Episode FindEpisode(int seriesId, DateTime date)
|
||||
{
|
||||
return _episodeRepository.Find(seriesId, date);
|
||||
}
|
||||
|
||||
public List<Episode> GetEpisodeBySeries(int seriesId)
|
||||
{
|
||||
return _episodeRepository.GetEpisodes(seriesId).ToList();
|
||||
|
@ -14,6 +14,7 @@
|
||||
<div class="row">
|
||||
<span class="label label-info">{{network}}</span>
|
||||
<span class="label label-info">{{runtime}} minutes</span>
|
||||
<span class="label label-info">{{path}}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user