Ejemplo n.º 1
0
        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();
        }
Ejemplo n.º 2
0
 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);
 }
Ejemplo n.º 3
0
 public ShowEpisodeItem(EpisodeFile file, Episode episode)
 {
     this.file = file;
     this.episode = episode;
 }
Ejemplo n.º 4
0
 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;
 }