|
|
@ -17,7 +17,7 @@ namespace NzbDrone.Core.Tv
|
|
|
|
List<Episode> GetEpisodes(IEnumerable<Int32> ids);
|
|
|
|
List<Episode> GetEpisodes(IEnumerable<Int32> ids);
|
|
|
|
Episode FindEpisode(int seriesId, int seasonNumber, int episodeNumber);
|
|
|
|
Episode FindEpisode(int seriesId, int seasonNumber, int episodeNumber);
|
|
|
|
Episode FindEpisode(int seriesId, int absoluteEpisodeNumber);
|
|
|
|
Episode FindEpisode(int seriesId, int absoluteEpisodeNumber);
|
|
|
|
Episode FindEpisodeByTitle(int seriesId, int seasonNumber, string episodeTitle);
|
|
|
|
Episode FindEpisodeByTitle(int seriesId, int seasonNumber, string releaseTitle);
|
|
|
|
List<Episode> FindEpisodesBySceneNumbering(int seriesId, int seasonNumber, int episodeNumber);
|
|
|
|
List<Episode> FindEpisodesBySceneNumbering(int seriesId, int seasonNumber, int episodeNumber);
|
|
|
|
Episode FindEpisodeBySceneNumbering(int seriesId, int sceneAbsoluteEpisodeNumber);
|
|
|
|
Episode FindEpisodeBySceneNumbering(int seriesId, int sceneAbsoluteEpisodeNumber);
|
|
|
|
Episode GetEpisode(int seriesId, String date);
|
|
|
|
Episode GetEpisode(int seriesId, String date);
|
|
|
@ -103,19 +103,25 @@ namespace NzbDrone.Core.Tv
|
|
|
|
return _episodeRepository.GetEpisodes(seriesId, seasonNumber);
|
|
|
|
return _episodeRepository.GetEpisodes(seriesId, seasonNumber);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Episode FindEpisodeByTitle(int seriesId, int seasonNumber, string episodeTitle)
|
|
|
|
public Episode FindEpisodeByTitle(int seriesId, int seasonNumber, string releaseTitle)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// TODO: can replace this search mechanism with something smarter/faster/better
|
|
|
|
// TODO: can replace this search mechanism with something smarter/faster/better
|
|
|
|
var search = Parser.Parser.NormalizeEpisodeTitle(episodeTitle).Replace(".", " ");
|
|
|
|
var normalizedReleaseTitle = Parser.Parser.NormalizeEpisodeTitle(releaseTitle).Replace(".", " ");
|
|
|
|
|
|
|
|
var episodes = _episodeRepository.GetEpisodes(seriesId, seasonNumber);
|
|
|
|
return _episodeRepository.GetEpisodes(seriesId, seasonNumber)
|
|
|
|
|
|
|
|
.FirstOrDefault(e =>
|
|
|
|
var query = episodes.Select(
|
|
|
|
{
|
|
|
|
episode => new
|
|
|
|
// normalize episode title
|
|
|
|
{
|
|
|
|
var title = Parser.Parser.NormalizeEpisodeTitle(e.Title);
|
|
|
|
Position = normalizedReleaseTitle.IndexOf(Parser.Parser.NormalizeEpisodeTitle(episode.Title), StringComparison.CurrentCultureIgnoreCase),
|
|
|
|
// find episode title within search string
|
|
|
|
Length = Parser.Parser.NormalizeEpisodeTitle(episode.Title).Length,
|
|
|
|
return (title.Length > 0) && search.Contains(title);
|
|
|
|
Episode = episode
|
|
|
|
});
|
|
|
|
})
|
|
|
|
|
|
|
|
.Where(e => e.Episode.Title.Length > 0 && e.Position >= 0)
|
|
|
|
|
|
|
|
.OrderBy(e => e.Position)
|
|
|
|
|
|
|
|
.ThenByDescending(e => e.Length)
|
|
|
|
|
|
|
|
.ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return query.First().Episode;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public List<Episode> EpisodesWithFiles(int seriesId)
|
|
|
|
public List<Episode> EpisodesWithFiles(int seriesId)
|
|
|
|