public void EpisodeIsEnricherReturnsFalseWhenNoEpisodeNumber()
        {
            var guideProgram = new GuideProgram();
            var program      = new GuideEnricherProgram(guideProgram);

            program.EpisodeIsEnriched().ShouldBeFalse();
        }
        public override bool Match(GuideEnricherProgram guideProgram, List <TvdbEpisode> episodes)
        {
            if (guideProgram == null)
            {
                throw new ArgumentNullException("enrichedGuideProgram");
            }
            if (IsStringPropertyNull(guideProgram, guideProgram.Description, "Description"))
            {
                return(false);
            }
            //
            var match = firstSentence.Match(guideProgram.Description);

            if (match == null || string.IsNullOrEmpty(match.Value))
            {
                return(false);
            }

            this.MatchAttempts++;
            var matchedEpisode = episodes.FirstOrDefault(x => x.EpisodeName == match.Value);

            if (matchedEpisode != null)
            {
                return(this.Matched(guideProgram, matchedEpisode));
            }

            return(false);
        }
示例#3
0
        public void ShouldUpdateSimilarPrograms()
        {
            var programA =
                new GuideEnricherProgram(
                    new GuideProgram
            {
                Title               = "Intervention",
                SubTitle            = "Sarah; Mikeal",
                PreviouslyAiredTime = new DateTime(2011, 6, 27),
                GuideProgramId      = Guid.NewGuid()
            });

            var programB =
                new GuideEnricherProgram(
                    new GuideProgram
            {
                Title          = "Intervention",
                SubTitle       = "Sarah; Mikeal",
                GuideProgramId = Guid.NewGuid()
            });

            var matchedSeries = new GuideEnricherSeries("Intervention", false, false, false);
            var pendingSeries = new List <GuideEnricherProgram>(1)
            {
                programB
            };

            matchedSeries.AddProgram(programA);



            var similarPrograms = matchedSeries.FindSimilarPrograms(pendingSeries, programA);

            similarPrograms.Count.ShouldEqual(1);
        }
        public void EnrichProgram(GuideEnricherProgram existingProgram, TvdbSeries tvdbSeries)
        {
            if (existingProgram == null)
            {
                throw new ArgumentNullException("existingProgram");
            }
            if (tvdbSeries == null)
            {
                throw new ArgumentNullException("tvdbSeries");
            }
            //
            log.DebugFormat("Starting lookup for {0} - {1}", existingProgram.Title, existingProgram.SubTitle);

            foreach (var matchMethod in this.matchMethods)
            {
                try
                {
                    if (matchMethod.Match(existingProgram, tvdbSeries.Episodes))
                    {
                        existingProgram.Matched = true;
                        break;
                    }
                }
                catch (Exception e)
                {
                    log.ErrorFormat("Matchmethod \"{0}\" failed with exception \"{1}\"", matchMethod.MethodName, e.GetBaseException().Message, e);
                }
            }
        }
        public override bool Match(GuideEnricherProgram guideProgram, List <TvdbEpisode> episodes)
        {
            if (guideProgram == null)
            {
                throw new ArgumentNullException("enrichedGuideProgram");
            }
            if (IsStringPropertyNull(guideProgram, guideProgram.SubTitle, "SubTitle"))
            {
                return(false);
            }
            //
            this.MatchAttempts++;
            foreach (var episode in episodes)
            {
                if (!string.IsNullOrEmpty(episode.EpisodeName))
                {
                    if (Regex.Replace(episode.EpisodeName, REMOVE_PUNCTUATION_REG_EX, string.Empty) == Regex.Replace(guideProgram.SubTitle, REMOVE_PUNCTUATION_REG_EX, string.Empty))
                    {
                        return(this.Matched(guideProgram, episode));
                    }
                }
            }

            return(this.Unmatched(guideProgram));
        }
        public void ShouldUpdateSimilarPrograms()
        {
            var programA =
                new GuideEnricherProgram(
                    new GuideProgram
                    {
                        Title = "Intervention",
                        SubTitle = "Sarah; Mikeal",
                        PreviouslyAiredTime = new DateTime(2011, 6, 27),
                        GuideProgramId = Guid.NewGuid()
                    });

            var programB =
                new GuideEnricherProgram(
                    new GuideProgram
                    {
                        Title = "Intervention",
                        SubTitle = "Sarah; Mikeal",
                        GuideProgramId = Guid.NewGuid()
                    });

            var matchedSeries = new GuideEnricherSeries("Intervention", false, false, false);
            var pendingSeries = new List<GuideEnricherProgram>(1) { programB };

            matchedSeries.AddProgram(programA);



            var similarPrograms = matchedSeries.FindSimilarPrograms(pendingSeries, programA);

            similarPrograms.Count.ShouldEqual(1);
        }
        protected bool Matched(GuideEnricherProgram guideProgram, TvdbEpisode episode)
        {
            if (guideProgram == null)
            {
                throw new ArgumentNullException("guideProgram");
            }
            if (episode == null)
            {
                throw new ArgumentNullException("episode");
            }
            //
            this.SuccessfulMatches++;
            guideProgram.EpisodeNumber        = episode.EpisodeNumber;
            guideProgram.SeriesNumber         = episode.SeasonNumber;
            guideProgram.EpisodeNumberDisplay = Enricher.FormatSeasonAndEpisode(episode.SeasonNumber, episode.EpisodeNumber);

            if (bool.Parse(Config.Instance.GetProperty("updateSubtitles")))
            {
                guideProgram.SubTitle = episode.EpisodeName;
            }

            if (bool.Parse(Config.Instance.GetProperty("episodeInDescription")))
            {
                var descriptionWithNoEpisodeNumber = Regex.Replace(guideProgram.Description, "^S[0-9][0-9]E[0-9][0-9] - ", string.Empty);
                guideProgram.Description = string.Format("{0} - {1}", guideProgram.EpisodeNumberDisplay, descriptionWithNoEpisodeNumber);
            }

            this.log.DebugFormat("[{0}] Correctly matched {1} - {2} as {3}", this.MethodName, guideProgram.Title, guideProgram.SubTitle, guideProgram.EpisodeNumberDisplay);
            return(true);
        }
示例#8
0
        public void GetValidEpisodeNumberInSubtitle()
        {
            var program = new GuideEnricherProgram(new GuideProgram {
                Title = "Some Show", SubTitle = "13"
            });

            program.GetValidEpisodeNumber().ShouldEqual(13);
        }
 protected virtual bool IsStringPropertyNull(GuideEnricherProgram guideProgram, string value, string propertyName)
 {
     if (string.IsNullOrWhiteSpace(value))
     {
         this.log.DebugFormat("[{0}] {1} - {2:MM/dd hh:mm tt} does not have a \"{3}\"", this.MethodName, guideProgram.Title, guideProgram.StartTime, propertyName);
         return true;
     }
     return false;
 }
 protected virtual bool IsStringPropertyNull(GuideEnricherProgram guideProgram, string value, string propertyName)
 {
     if (string.IsNullOrWhiteSpace(value))
     {
         this.log.DebugFormat("[{0}] {1} - {2:MM/dd hh:mm tt} does not have a \"{3}\"", this.MethodName, guideProgram.Title, guideProgram.StartTime, propertyName);
         return(true);
     }
     return(false);
 }
 public void EpisodeIsEnricherReturnsFalseWhenNoSeasonEpisode()
 {
     var guideProgram = new GuideProgram();
     guideProgram.SeriesNumber = 3;
     guideProgram.EpisodeNumber = 10;
     guideProgram.EpisodeNumberDisplay = "Test";
     var program = new GuideEnricherProgram(guideProgram);
     program.EpisodeIsEnriched().ShouldBeFalse();
 }
 public void EpisodeIsEnricherReturnsTrueWhenEpisodeNumberAndSeasonEpisode()
 {
     var guideProgram = new GuideProgram();
     guideProgram.SeriesNumber = 3;
     guideProgram.EpisodeNumber = 10;
     guideProgram.EpisodeNumberDisplay = "S03E10";
     var program = new GuideEnricherProgram(guideProgram);
     program.EpisodeIsEnriched().ShouldBeTrue();
 }
        public void EpisodeNumber302MapsToSeason3Episode2()
        {
            var program = new GuideEnricherProgram(new GuideProgram { Title = "Some Program", EpisodeNumber = 302 });
            this.matcher.Match(program, this.episodes);

            program.SeriesNumber.ShouldEqual(3);
            program.EpisodeNumber.ShouldEqual(2);
            program.SubTitle.ShouldEqual("Test 3-2");
            program.EpisodeNumberDisplay.ShouldEqual("S03E02");
        }
        public void EpisodeNumber1108MapsToSeason11Episode8()
        {
            var program = new GuideEnricherProgram(new GuideProgram { Title = "Some Program", EpisodeNumber = 1108 });
            this.matcher.Match(program, this.episodes);

            program.SeriesNumber.ShouldEqual(11);
            program.EpisodeNumber.ShouldEqual(8);
            program.SubTitle.ShouldEqual("Test 11-8");
            program.EpisodeNumberDisplay.ShouldEqual("S11E08");
        }
        public void EpisodeIsEnricherReturnsTrueWhenEpisodeNumberAndSeasonEpisode()
        {
            var guideProgram = new GuideProgram();

            guideProgram.SeriesNumber         = 3;
            guideProgram.EpisodeNumber        = 10;
            guideProgram.EpisodeNumberDisplay = "S03E10";
            var program = new GuideEnricherProgram(guideProgram);

            program.EpisodeIsEnriched().ShouldBeTrue();
        }
        public void EpisodeIsEnricherReturnsFalseWhenNoSeasonEpisode()
        {
            var guideProgram = new GuideProgram();

            guideProgram.SeriesNumber         = 3;
            guideProgram.EpisodeNumber        = 10;
            guideProgram.EpisodeNumberDisplay = "Test";
            var program = new GuideEnricherProgram(guideProgram);

            program.EpisodeIsEnriched().ShouldBeFalse();
        }
        public void EpisodeNumber1108MapsToSeason11Episode8()
        {
            var program = new GuideEnricherProgram(new GuideProgram {
                Title = "Some Program", EpisodeNumber = 1108
            });

            this.matcher.Match(program, this.episodes);

            program.SeriesNumber.ShouldEqual(11);
            program.EpisodeNumber.ShouldEqual(8);
            program.SubTitle.ShouldEqual("Test 11-8");
            program.EpisodeNumberDisplay.ShouldEqual("S11E08");
        }
        public void EpisodeNumber302MapsToSeason3Episode2()
        {
            var program = new GuideEnricherProgram(new GuideProgram {
                Title = "Some Program", EpisodeNumber = 302
            });

            this.matcher.Match(program, this.episodes);

            program.SeriesNumber.ShouldEqual(3);
            program.EpisodeNumber.ShouldEqual(2);
            program.SubTitle.ShouldEqual("Test 3-2");
            program.EpisodeNumberDisplay.ShouldEqual("S03E02");
        }
        public override bool Match(GuideEnricherProgram enrichedGuideProgram, List<TvdbEpisode> episodes)
        {
            var episodeNumber = enrichedGuideProgram.GetValidEpisodeNumber();

            this.MatchAttempts++;

            var matchedEpisode = episodes.FirstOrDefault(x => x.SeasonNumber == episodeNumber / 100 && x.EpisodeNumber == episodeNumber % 100);
            if (matchedEpisode != null)
            {
                return this.Matched(enrichedGuideProgram, matchedEpisode);
            }
            
            return this.Unmatched(enrichedGuideProgram);
        }
        public override bool Match(GuideEnricherProgram guideProgram, List<TvdbEpisode> episodes)
        {
            if (guideProgram == null) throw new ArgumentNullException("enrichedGuideProgram");
            if (IsStringPropertyNull(guideProgram, guideProgram.Description, "Description")) return false;
            //
            var description = guideProgram.Description.ToLower();
            this.MatchAttempts++;
            var matchedEpisode = episodes.FirstOrDefault(x => !string.IsNullOrEmpty(x.EpisodeName) && new Regex(string.Concat("^", x.EpisodeName, "\\W"), RegexOptions.IgnoreCase).IsMatch(description));
            if (matchedEpisode != null)
            {
                return this.Matched(guideProgram, matchedEpisode);
            }

            return false;
        }
        public override bool Match(GuideEnricherProgram enrichedGuideProgram, List <TvdbEpisode> episodes)
        {
            var episodeNumber = enrichedGuideProgram.GetValidEpisodeNumber();

            this.MatchAttempts++;

            var matchedEpisode = episodes.FirstOrDefault(x => x.SeasonNumber == episodeNumber / 100 && x.EpisodeNumber == episodeNumber % 100);

            if (matchedEpisode != null)
            {
                return(this.Matched(enrichedGuideProgram, matchedEpisode));
            }

            return(this.Unmatched(enrichedGuideProgram));
        }
        public override bool Match(GuideEnricherProgram guideProgram, List<TvdbEpisode> episodes)
        {
            if (guideProgram == null) throw new ArgumentNullException("guideProgram");
            if (IsStringPropertyNull(guideProgram, guideProgram.SubTitle, "SubTitle")) return false;
            //
            this.MatchAttempts++;
            foreach (var episode in episodes)
            {
                if (episode.EpisodeName == guideProgram.SubTitle)
                {
                    return this.Matched(guideProgram, episode);
                }
            }

            return this.Unmatched(guideProgram);
        }
        private async Task AddUpcomingProgramsAsync(ScheduleType scheduleType)
        {
            var schedules = await Proxies.SchedulerService.GetAllSchedules(ChannelType.Television, scheduleType);

            // EpisodeDisplayname must have S01E01 format
            var episodeDataValidRegEx = new System.Text.RegularExpressions.Regex(@"S\d\dE\d\d");

            //
            foreach (var scheduleSummary in schedules)
            {
                if (!scheduleSummary.IsActive)
                {
                    continue;
                }
                //
                var schedule = await Proxies.SchedulerService.GetScheduleById(scheduleSummary.ScheduleId);

                // remove schedule filters
                var filtersToRemove = new List <ScheduleRuleType>
                {
                    { ScheduleRuleType.EpisodeNumberEquals },
                    { ScheduleRuleType.EpisodeNumberContains },
                    { ScheduleRuleType.EpisodeNumberDoesNotContain },
                    { ScheduleRuleType.EpisodeNumberStartsWith },
                    { ScheduleRuleType.NewEpisodesOnly },
                    { ScheduleRuleType.NewTitlesOnly },
                    { ScheduleRuleType.SkipRepeats }
                };
                schedule.Rules.RemoveAll(x => filtersToRemove.Contains(x.Type));
                //
                foreach (var program in await Proxies.SchedulerService.GetUpcomingPrograms(schedule, true))
                {
                    var guideProgram = new GuideEnricherProgram(await Proxies.GuideService.GetProgramById(program.GuideProgramId.Value));
                    // skip already enriched entries
                    if (episodeDataValidRegEx.IsMatch(guideProgram.EpisodeNumberDisplay))
                    {
                        continue;
                    }
                    //
                    if (!this.seriesToEnrich.ContainsKey(guideProgram.Title))
                    {
                        this.seriesToEnrich.Add(guideProgram.Title, new GuideEnricherSeries(guideProgram.Title, config.UpdateMatchedEpisodes, config.UpdateSubtitlesParameter, config.UpdateDescription));
                    }
                    this.seriesToEnrich[guideProgram.Title].AddProgram(guideProgram);
                }
            }
        }
示例#24
0
        public override bool Match(GuideEnricherProgram guideProgram, List <TvdbEpisode> episodes)
        {
            if (!guideProgram.PreviouslyAiredTime.HasValue)
            {
                return(false);
            }

            this.MatchAttempts++;
            var match = episodes.Where(e => e.FirstAired == guideProgram.PreviouslyAiredTime).FirstOrDefault();

            if (match != null)
            {
                return(this.Matched(guideProgram, match));
            }

            return(this.Unmatched(guideProgram));
        }
        public override bool Match(GuideEnricherProgram guideProgram, List<TvdbEpisode> episodes)
        {
            if (guideProgram == null) throw new ArgumentNullException("enrichedGuideProgram");
            if (IsStringPropertyNull(guideProgram, guideProgram.Description, "Description")) return false;
            //
            var match = quotedSentence.Match(guideProgram.Description);
            if (match == null || string.IsNullOrEmpty(match.Value))
                return false;

            this.MatchAttempts++;
            var matchedEpisode = episodes.FirstOrDefault(x => x.EpisodeName == match.Value);
            if (matchedEpisode != null)
            {
                return this.Matched(guideProgram, matchedEpisode);
            }
            return this.Unmatched(guideProgram);
        }
 private void EnrichProgramsInSeries(GuideEnricherSeries series, TvdbSeries OnlineSeries)
 {
     this.tvdbLibAccess.DebugEpisodeDump(OnlineSeries);
     do
     {
         GuideEnricherProgram guideProgram = series.PendingPrograms[0];
         this.tvdbLibAccess.EnrichProgram(guideProgram, OnlineSeries);
         if (guideProgram.Matched)
         {
             series.AddAllToEnrichedPrograms(guideProgram);
         }
         else
         {
             series.AddAllToFailedPrograms(guideProgram);
         }
     }while (series.PendingPrograms.Count > 0);
 }
        public override bool Match(GuideEnricherProgram guideProgram, List<TvdbEpisode> episodes)
        {
            if (!guideProgram.PreviouslyAiredTime.HasValue)
            {
                return false;
            }

            this.MatchAttempts++;
            var match = episodes.Where(e => e.FirstAired == guideProgram.PreviouslyAiredTime).FirstOrDefault();

            if (match != null)
            {
                return this.Matched(guideProgram, match);
            }

            return this.Unmatched(guideProgram);
        }
        public override bool Match(GuideEnricherProgram guideProgram, List<TvdbEpisode> episodes)
        {
            if (guideProgram == null) throw new ArgumentNullException("enrichedGuideProgram");
            if (IsStringPropertyNull(guideProgram, guideProgram.SubTitle, "SubTitle")) return false;
            //
            this.MatchAttempts++;
            foreach (var episode in episodes)
            {
                if (!string.IsNullOrEmpty(episode.EpisodeName))
                {
                    if (Regex.Replace(episode.EpisodeName, REMOVE_PUNCTUATION_REG_EX, string.Empty) == Regex.Replace(guideProgram.SubTitle, REMOVE_PUNCTUATION_REG_EX, string.Empty))
                    {
                        return this.Matched(guideProgram, episode);
                    }
                }
            }

            return this.Unmatched(guideProgram);
        }
        public override bool Match(GuideEnricherProgram guideProgram, List <TvdbEpisode> episodes)
        {
            if (guideProgram == null)
            {
                throw new ArgumentNullException("enrichedGuideProgram");
            }
            //
            Match match = null;
            int   index = 0;

            do
            {
                match = regexes[index++].Match(guideProgram.Description);
            } while (string.IsNullOrEmpty(match.Value) && index < regexes.Count);
            if (match != null && !string.IsNullOrEmpty(match.Value))
            {
                this.MatchAttempts++;
                int seasonNumber  = 0;
                int episodeNumber = 0;
                if (!int.TryParse(match.Groups["season"].Value, out seasonNumber))
                {
                    // roman literal?
                    seasonNumber = this.RomanToNumeric(match.Groups["season"].Value);
                }
                if (!int.TryParse(match.Groups["episode"].Value, out episodeNumber))
                {
                    // roman literal?
                    episodeNumber = this.RomanToNumeric(match.Groups["episode"].Value);
                }
                if (seasonNumber != 0 && episodeNumber != 0)
                {
                    var matchedEpisode = episodes.FirstOrDefault(x => x.SeasonNumber == seasonNumber && x.EpisodeNumber == episodeNumber);
                    if (matchedEpisode != null)
                    {
                        return(this.Matched(guideProgram, matchedEpisode));
                    }
                }
            }
            return(this.Unmatched(guideProgram));
        }
示例#30
0
        public override bool Match(GuideEnricherProgram guideProgram, List <TvdbEpisode> episodes)
        {
            if (guideProgram == null)
            {
                throw new ArgumentNullException("guideProgram");
            }
            if (IsStringPropertyNull(guideProgram, guideProgram.SubTitle, "SubTitle"))
            {
                return(false);
            }
            //
            this.MatchAttempts++;
            foreach (var episode in episodes)
            {
                if (episode.EpisodeName == guideProgram.SubTitle)
                {
                    return(this.Matched(guideProgram, episode));
                }
            }

            return(this.Unmatched(guideProgram));
        }
        public override bool Match(GuideEnricherProgram guideProgram, List<TvdbEpisode> episodes)
        {
            var episodeNumber = guideProgram.GetValidEpisodeNumber();
            if (episodeNumber == 0)
            {
                this.log.DebugFormat("Cannot use match method [{0}] {1} does not have an episode number", this.MethodName, guideProgram.Title);
                return false;
            }
            
            this.CalculateAbsoluteNumbers(episodes);
            this.MatchAttempts++;

            foreach (var episode in episodes)
            {
                if (episodeNumber == episode.AbsoluteNumber)
                {
                    return this.Matched(guideProgram, episode);
                }
            }

            return this.Unmatched(guideProgram);
        }
        public void EnrichProgram(GuideEnricherProgram existingProgram, TvdbSeries tvdbSeries)
        {
            if (existingProgram == null) throw new ArgumentNullException("existingProgram");
            if (tvdbSeries == null) throw new ArgumentNullException("tvdbSeries");
            //
            log.DebugFormat("Starting lookup for {0} - {1}", existingProgram.Title, existingProgram.SubTitle);

            foreach (var matchMethod in this.matchMethods)
            {
                try
                {
                    if (matchMethod.Match(existingProgram, tvdbSeries.Episodes))
                    {
                        existingProgram.Matched = true;
                        break;
                    }
                }
                catch (Exception e)
                {
                    log.ErrorFormat("Matchmethod \"{0}\" failed with exception \"{1}\"", matchMethod.MethodName, e.GetBaseException().Message, e);
                }
            }
        }
示例#33
0
        public override bool Match(GuideEnricherProgram guideProgram, List <TvdbEpisode> episodes)
        {
            if (guideProgram == null)
            {
                throw new ArgumentNullException("enrichedGuideProgram");
            }
            if (IsStringPropertyNull(guideProgram, guideProgram.Description, "Description"))
            {
                return(false);
            }
            //
            var description = guideProgram.Description.ToLower();

            this.MatchAttempts++;
            var matchedEpisode = episodes.FirstOrDefault(x => !string.IsNullOrEmpty(x.EpisodeName) && new Regex(string.Concat("^", x.EpisodeName, "\\W"), RegexOptions.IgnoreCase).IsMatch(description));

            if (matchedEpisode != null)
            {
                return(this.Matched(guideProgram, matchedEpisode));
            }

            return(false);
        }
        public override bool Match(GuideEnricherProgram guideProgram, List <TvdbEpisode> episodes)
        {
            var episodeNumber = guideProgram.GetValidEpisodeNumber();

            if (episodeNumber == 0)
            {
                this.log.DebugFormat("Cannot use match method [{0}] {1} does not have an episode number", this.MethodName, guideProgram.Title);
                return(false);
            }

            this.CalculateAbsoluteNumbers(episodes);
            this.MatchAttempts++;

            foreach (var episode in episodes)
            {
                if (episodeNumber == episode.AbsoluteNumber)
                {
                    return(this.Matched(guideProgram, episode));
                }
            }

            return(this.Unmatched(guideProgram));
        }
 public override bool Match(GuideEnricherProgram guideProgram, List<TvdbEpisode> episodes)
 {
     if (guideProgram == null) throw new ArgumentNullException("enrichedGuideProgram");
     //
     Match match = null;
     int index = 0;
     do
     {
         match = regexes[index++].Match(guideProgram.Description);
     } while (string.IsNullOrEmpty(match.Value) && index < regexes.Count);
     if (match != null && !string.IsNullOrEmpty(match.Value))
     {
         this.MatchAttempts++;
         int seasonNumber = 0;
         int episodeNumber = 0;
         if (!int.TryParse(match.Groups["season"].Value, out seasonNumber))
         {
             // roman literal?
             seasonNumber = this.RomanToNumeric(match.Groups["season"].Value);
         }
         if (!int.TryParse(match.Groups["episode"].Value, out episodeNumber))
         {
             // roman literal?
             episodeNumber = this.RomanToNumeric(match.Groups["episode"].Value);
         }
         if (seasonNumber != 0 && episodeNumber != 0)
         {
             var matchedEpisode = episodes.FirstOrDefault(x => x.SeasonNumber == seasonNumber && x.EpisodeNumber == episodeNumber);
             if (matchedEpisode != null)
             {
                 return this.Matched(guideProgram, matchedEpisode);
             }
         }
     }
     return this.Unmatched(guideProgram);
 }
        protected bool Matched(GuideEnricherProgram guideProgram, TvdbEpisode episode)
        {
            if (guideProgram == null) throw new ArgumentNullException("guideProgram");
            if (episode == null) throw new ArgumentNullException("episode");
            //
            this.SuccessfulMatches++;
            guideProgram.EpisodeNumber = episode.EpisodeNumber;
            guideProgram.SeriesNumber = episode.SeasonNumber;
            guideProgram.EpisodeNumberDisplay = Enricher.FormatSeasonAndEpisode(episode.SeasonNumber, episode.EpisodeNumber);

            if (bool.Parse(Config.Instance.GetProperty("updateSubtitles")))
            {
                guideProgram.SubTitle = episode.EpisodeName;
            }

            if (bool.Parse(Config.Instance.GetProperty("episodeInDescription")))
            {
                var descriptionWithNoEpisodeNumber = Regex.Replace(guideProgram.Description, "^S[0-9][0-9]E[0-9][0-9] - ", string.Empty);
                guideProgram.Description = string.Format("{0} - {1}", guideProgram.EpisodeNumberDisplay, descriptionWithNoEpisodeNumber);
            }

            this.log.DebugFormat("[{0}] Correctly matched {1} - {2} as {3}", this.MethodName, guideProgram.Title, guideProgram.SubTitle, guideProgram.EpisodeNumberDisplay);
            return true;
        }
 private async Task AddUpcomingProgramsAsync(ScheduleType scheduleType)
 {
     var schedules = await Proxies.SchedulerService.GetAllSchedules(ChannelType.Television, scheduleType);
     // EpisodeDisplayname must have S01E01 format
     var episodeDataValidRegEx = new System.Text.RegularExpressions.Regex(@"S\d\dE\d\d");
     //
     foreach (var scheduleSummary in schedules)
     {
         if (!scheduleSummary.IsActive) continue;
         //
         var schedule = await Proxies.SchedulerService.GetScheduleById(scheduleSummary.ScheduleId);
         // remove schedule filters
         var filtersToRemove = new List<ScheduleRuleType>
                 {
                     { ScheduleRuleType.EpisodeNumberEquals },
                     { ScheduleRuleType.EpisodeNumberContains },
                     { ScheduleRuleType.EpisodeNumberDoesNotContain },
                     { ScheduleRuleType.EpisodeNumberStartsWith },
                     { ScheduleRuleType.NewEpisodesOnly },
                     { ScheduleRuleType.NewTitlesOnly },
                     { ScheduleRuleType.SkipRepeats }
                  };
         schedule.Rules.RemoveAll(x => filtersToRemove.Contains(x.Type));
         //
         foreach (var program in await Proxies.SchedulerService.GetUpcomingPrograms(schedule, true))
         {
             var guideProgram = new GuideEnricherProgram(await Proxies.GuideService.GetProgramById(program.GuideProgramId.Value));
             // skip already enriched entries
             if (episodeDataValidRegEx.IsMatch(guideProgram.EpisodeNumberDisplay)) continue;
             //
             if (!this.seriesToEnrich.ContainsKey(guideProgram.Title))
             {
                 this.seriesToEnrich.Add(guideProgram.Title, new GuideEnricherSeries(guideProgram.Title, config.UpdateMatchedEpisodes, config.UpdateSubtitlesParameter, config.UpdateDescription));
             }
             this.seriesToEnrich[guideProgram.Title].AddProgram(guideProgram);
         }
     }
 }
 public void GetValidEpisodeNumberInEpisodeNumber()
 {
     var program = new GuideEnricherProgram(new GuideProgram { Title = "Some Show", EpisodeNumber = 13 });
     program.GetValidEpisodeNumber().ShouldEqual(13);
 }
 public abstract bool Match(GuideEnricherProgram enrichedGuideProgram, List<TvdbEpisode> episodes);
 protected bool Unmatched(GuideEnricherProgram guideProgram)
 {
     this.log.DebugFormat("[{0}] Could not match {1} - {2}", this.MethodName, guideProgram.Title, guideProgram.SubTitle);
     return false;
 }
 protected bool Unmatched(GuideEnricherProgram guideProgram)
 {
     this.log.DebugFormat("[{0}] Could not match {1} - {2}", this.MethodName, guideProgram.Title, guideProgram.SubTitle);
     return(false);
 }
 public void EpisodeIsEnricherReturnsFalseWhenNoEpisodeNumber()
 {
     var guideProgram = new GuideProgram();
     var program = new GuideEnricherProgram(guideProgram);
     program.EpisodeIsEnriched().ShouldBeFalse();
 }
 public abstract bool Match(GuideEnricherProgram enrichedGuideProgram, List <TvdbEpisode> episodes);