예제 #1
0
        public Decision IsSatisfiedBy(RemoteMovie subject, SearchCriteriaBase searchCriteria)
        {
            if (!subject.ParsedMovieInfo.Quality.Revision.IsRepack)
            {
                return(Decision.Accept());
            }

            if (subject.Movie.MovieFileId != 0)
            {
                var file = subject.Movie.MovieFile;

                if (_upgradableSpecification.IsRevisionUpgrade(file.Quality, subject.ParsedMovieInfo.Quality))
                {
                    var releaseGroup     = subject.ParsedMovieInfo.ReleaseGroup;
                    var fileReleaseGroup = file.ReleaseGroup;

                    if (fileReleaseGroup.IsNullOrWhiteSpace())
                    {
                        return(Decision.Reject("Unable to determine release group for the existing file"));
                    }

                    if (releaseGroup.IsNullOrWhiteSpace())
                    {
                        return(Decision.Reject("Unable to determine release group for this release"));
                    }

                    if (!fileReleaseGroup.Equals(releaseGroup, StringComparison.InvariantCultureIgnoreCase))
                    {
                        _logger.Debug(
                            "Release is a repack for a different release group. Release Group: {0}. File release group: {1}",
                            releaseGroup,
                            fileReleaseGroup);
                        return(Decision.Reject(
                                   "Release is a repack for a different release group. Release Group: {0}. File release group: {1}",
                                   releaseGroup,
                                   fileReleaseGroup));
                    }
                }
            }

            return(Decision.Accept());
        }
예제 #2
0
        public virtual Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase searchCriteria)
        {
            var releaseGroup = subject.ParsedEpisodeInfo.ReleaseGroup;

            if (subject.Series.SeriesType != SeriesTypes.Anime)
            {
                return(Decision.Accept());
            }

            foreach (var file in subject.Episodes.Where(c => c.EpisodeFileId != 0).Select(c => c.EpisodeFile.Value))
            {
                if (file == null)
                {
                    continue;
                }

                if (_upgradableSpecification.IsRevisionUpgrade(file.Quality, subject.ParsedEpisodeInfo.Quality))
                {
                    if (file.ReleaseGroup.IsNullOrWhiteSpace())
                    {
                        _logger.Debug("Unable to compare release group, existing file's release group is unknown");
                        return(Decision.Reject("Existing release group is unknown"));
                    }

                    if (releaseGroup.IsNullOrWhiteSpace())
                    {
                        _logger.Debug("Unable to compare release group, release's release group is unknown");
                        return(Decision.Reject("Release group is unknown"));
                    }

                    if (file.ReleaseGroup != releaseGroup)
                    {
                        _logger.Debug("Existing Release group is: {0} - release's release group is: {1}", file.ReleaseGroup, releaseGroup);
                        return(Decision.Reject("{0} does not match existing release group {1}", releaseGroup, file.ReleaseGroup));
                    }
                }
            }

            return(Decision.Accept());
        }
예제 #3
0
        public Decision IsSatisfiedBy(RemoteBook subject, SearchCriteriaBase searchCriteria)
        {
            if (!subject.ParsedBookInfo.Quality.Revision.IsRepack)
            {
                return(Decision.Accept());
            }

            foreach (var book in subject.Books)
            {
                var releaseGroup = subject.ParsedBookInfo.ReleaseGroup;
                var bookFiles    = _mediaFileService.GetFilesByBook(book.Id);

                foreach (var file in bookFiles)
                {
                    if (_upgradableSpecification.IsRevisionUpgrade(file.Quality, subject.ParsedBookInfo.Quality))
                    {
                        var fileReleaseGroup = file.ReleaseGroup;

                        if (fileReleaseGroup.IsNullOrWhiteSpace())
                        {
                            return(Decision.Reject("Unable to determine release group for the existing file"));
                        }

                        if (releaseGroup.IsNullOrWhiteSpace())
                        {
                            return(Decision.Reject("Unable to determine release group for this release"));
                        }

                        if (!fileReleaseGroup.Equals(releaseGroup, StringComparison.InvariantCultureIgnoreCase))
                        {
                            _logger.Debug("Release is a repack for a different release group. Release Group: {0}. File release group: {1}", releaseGroup, fileReleaseGroup);
                            return(Decision.Reject("Release is a repack for a different release group. Release Group: {0}. File release group: {1}", releaseGroup, fileReleaseGroup));
                        }
                    }
                }
            }

            return(Decision.Accept());
        }