public Episode[] GetShowEpisode(string originalShowName, int season, int episode, CancellationToken token) { var episodes = new List<Episode>(); var list = GetShows(token); var showWords = FileData.GetWordset(originalShowName).ToList(); var showName = string.Join(" ", showWords); Show exactShow = null; if (this.CustomMappings.Contains(showName)) { var custom = this.CustomMappings[showName]; exactShow = list.FirstOrDefault(s => s.Title.Equals(custom.ShowName, StringComparison.CurrentCultureIgnoreCase)); } if (exactShow == null) { exactShow = list.FirstOrDefault(s => s.NormalizedTitle.Equals(showName)) ?? list.FirstOrDefault( s => s.Directory.Equals(showName, StringComparison.CurrentCultureIgnoreCase)) ?? list.FirstOrDefault( s => s.Title.Equals(showName, StringComparison.CurrentCultureIgnoreCase)); } if (exactShow == null) { var ss = new HashSet<string>(showWords); foreach (var sh in list.Where(s => ss.IsSubsetOf(s.ExtendedWordset))) { Episode ep; if (!sh.TryGetEpisode(token, season, episode, out ep)) { ep = new Episode(sh.Title, season.ToString(CultureInfo.InvariantCulture), episode.ToString(CultureInfo.InvariantCulture), "", false); } episodes.Add(ep); } } else { Episode episodeItem; if (exactShow.TryGetEpisode(token, season, episode, out episodeItem)) { episodes.Add(episodeItem); } } return episodes.ToArray(); }
internal bool TryGetEpisode(CancellationToken token, int season, int episode, out Episode episodeInfo) { token.ThrowIfCancellationRequested(); episodeInfo = GetEpisodes(token).FirstOrDefault(ep => ep.SeasonIndex == season && ep.EpisodeIndex == episode); return(episodeInfo != null); }
public ShowEpisodeItem(EpisodeFile file, Episode episode) { this.file = file; this.episode = episode; }
internal bool TryGetEpisode(CancellationToken token, int season, int episode, out Episode episodeInfo) { token.ThrowIfCancellationRequested(); episodeInfo = GetEpisodes(token).FirstOrDefault(ep => ep.SeasonIndex == season && ep.EpisodeIndex == episode); return episodeInfo != null; }