Esempio n. 1
0
        public bool CheckFps(string fpsText, ref SubtitleScore score)
        {
            float fps = 0;

            try
            {
                fps = float.Parse(fpsText, CultureInfo.InvariantCulture);
            }
            catch
            {
            }

            if (VideoFps != null && VideoFps > 0 && fps > 0)
            {
                if (Math.Abs((float)(VideoFps - fps)) < 0.1)
                {
                    score.AddMatch("frame_rate");
                    return(true);
                }

                return(false); // frame rate doesn't match
            }

            return(true); // no frame rate information
        }
Esempio n. 2
0
        public bool CheckImdbId(int imdb, ref SubtitleScore score)
        {
            if (imdb > 0)
            {
                if (VideoType == VideoContentType.Episode)
                {
                    if (ImdbIdEpisodeInt > 0 && imdb == ImdbIdEpisodeInt)
                    {
                        score.AddMatch("imdb_episode");
                        return(true);
                    }
                }

                if (ImdbIdInt > 0)
                {
                    if (imdb == ImdbIdInt)
                    {
                        score.AddMatch("imdb");
                        return(true);
                    }

                    if (VideoType == VideoContentType.Episode && (SeasonNumber != null && SeasonNumber == 0))
                    {
                        return(true); // ignore IMDB mismatch for special episodes
                    }

                    return(false); // IMDB doesn't match
                }
            }

            return(true); // no IMDB info
        }
Esempio n. 3
0
        public bool CheckMovie(Parser.MovieInfo mvInfo, ref SubtitleScore score, bool addEmptyMatches = false)
        {
            if (mvInfo == null)
            {
                return(true); // no enough info to decide if the movie should be skipped
            }

            string title = Parser.Movie.NormalizeTitle(mvInfo.MovieTitle);

            if (title == Parser.Movie.NormalizeTitle(TitleMovie))
            {
                score.AddMatch("title");
            }

            if (Year != null && Year == mvInfo.Year)
            {
                score.AddMatch("year");
            }

            if (MvInfo != null)
            {
                if (mvInfo.ReleaseGroup.IsNotNullOrWhiteSpace() &&
                    MvInfo.ReleaseGroup.IsNotNullOrWhiteSpace() &&
                    mvInfo.ReleaseGroup.EqualsIgnoreCase(MvInfo.ReleaseGroup))
                {
                    score.AddMatch("release_group");
                }

                if (mvInfo.Edition.IsNullOrWhiteSpace() &&
                    MvInfo.Edition.IsNullOrWhiteSpace())
                {
                    if (addEmptyMatches)
                    {
                        score.AddMatch("edition");
                    }
                }
                else
                if (mvInfo.Edition.IsNotNullOrWhiteSpace() &&
                    MvInfo.Edition.IsNotNullOrWhiteSpace() &&
                    mvInfo.Edition.Equals(MvInfo.Edition))
                {
                    score.AddMatch("edition");
                }

                MatchQuality(MvInfo.Quality, mvInfo.Quality, ref score, addEmptyMatches);
            }

            return(true);
        }
Esempio n. 4
0
        protected void MatchQuality(Parser.Qualities.QualityModel qm1, Parser.Qualities.QualityModel qm2,
                                    ref SubtitleScore score, bool addEmptyMatches = false)
        {
            if (qm1 != null && qm2 != null)
            {
                var q1 = qm1.Quality;
                var q2 = qm2.Quality;
                if (q1 != null && q2 != null)
                {
                    if (q1.Source != Parser.Qualities.Source.UNKNOWN && q1.Source == q2.Source)
                    {
                        score.AddMatch("source");
                    }

                    if (q1.Resolution > 0 && q1.Resolution == q2.Resolution)
                    {
                        score.AddMatch("resolution");
                    }

                    if (q1.Modifier == Parser.Qualities.Modifier.NONE && q1.Modifier == q2.Modifier && addEmptyMatches)
                    {
                        score.AddMatch("source_modifier");
                    }
                    else
                    if (q1.Modifier != Parser.Qualities.Modifier.NONE && q1.Modifier == q2.Modifier)
                    {
                        score.AddMatch("source_modifier");
                    }
                }

                if (qm1.AudioCodec.IsNotNullOrWhiteSpace() && qm2.AudioCodec.IsNotNullOrWhiteSpace())
                {
                    if (qm1.AudioCodec == qm2.AudioCodec)
                    {
                        score.AddMatch("audio_codec");
                    }
                }

                if (qm1.VideoCodec.IsNotNullOrWhiteSpace() && qm2.VideoCodec.IsNotNullOrWhiteSpace())
                {
                    if (qm1.VideoCodec == qm2.VideoCodec)
                    {
                        score.AddMatch("video_codec");
                    }
                }
            }
        }
Esempio n. 5
0
        public bool CheckEpisode(Parser.EpisodeInfo epInfo, ref SubtitleScore score)
        {
            if (epInfo == null)
            {
                return(true); // no enough info to decide if the episode should be skipped
            }

            bool season  = true;
            bool episode = true;

            string title = Parser.Episode.NormalizeTitle(epInfo.SeriesTitleInfo.TitleWithoutYear);

            if (title == Parser.Episode.NormalizeTitle(TitleSeries))
            {
                score.AddMatch("title");
            }

            if (Year != null && Year == epInfo.SeriesTitleInfo.Year)
            {
                score.AddMatch("year");
            }

            if (SeasonNumber != null)
            {
                if (SeasonNumber == epInfo.SeasonNumber)
                {
                    score.AddMatch("season");
                }
                else
                if (SeasonNumber > 0)
                {
                    season = false;
                }
            }

            if (EpisodeNumber != null && epInfo.EpisodeNumbers.Length > 0)
            {
                if (epInfo.EpisodeNumbers.Contains(EpisodeNumber ?? 0))
                {
                    score.AddMatch("episode");
                }
                else
                if (EpisodeNumber > 0 && epInfo.EpisodeNumbers[0] > 0)
                {
                    episode = false;
                }
            }

            if (EpInfo != null)
            {
                if (epInfo.ReleaseGroup.IsNotNullOrWhiteSpace() &&
                    EpInfo.ReleaseGroup.IsNotNullOrWhiteSpace() &&
                    epInfo.ReleaseGroup.EqualsIgnoreCase(EpInfo.ReleaseGroup))
                {
                    score.AddMatch("release_group");
                }

                MatchQuality(EpInfo.Quality, epInfo.Quality, ref score);
            }

            return(season && episode);
        }