Пример #1
0
    def isCorrectMovie(self, item, movie, qualityType, imdbResults = False, singleCategory = False):

        # Ignore already added.
        if self.alreadyTried(item, movie.id):
            log.info('Already tried this one, ignored: %s' % item.name)
            return False

        nzbWords = re.split('\W+', self.toSearchString(item.name).lower())

        # Must contain any required words
        requiredWords = self.config.get('global', 'requiredWords').split(',')
        for word in requiredWords:
            if word.lower().strip() not in nzbWords:
                log.info('NZB does not contain required word %s: %s' % (word, item.name))
                return False

        # Contains ignored word
        ignoredWords = self.config.get('global', 'ignoreWords').split(',')
        for word in ignoredWords:
            if word.strip() and word.strip().lower() in nzbWords:
                log.info('NZB contains ignored word %s: %s' % (word, item.name))
                return False

        q = Qualities()
        type = q.types.get(qualityType)

        # Contains lower quality string
        if self.containsOtherQuality(item.name, type, singleCategory):
            log.info('Wrong: %s, looking for %s' % (item.name, type['label']))
            return False

        # File to small
        minSize = q.minimumSize(qualityType)
        if minSize > item.size:
            log.info('"%s" is too small to be %s. %sMB instead of the minimal of %sMB.' % (item.name, type['label'], item.size, minSize))
            return False

        # File to large
        maxSize = q.maximumSize(qualityType)
        if maxSize < item.size:
            log.info('"%s" is too large to be %s. %sMB instead of the maximum of %sMB.' % (item.name, type['label'], item.size, maxSize))
            return False

        if imdbResults:
            return True

        # Check if nzb contains imdb link
        if self.checkIMDB([item.content], movie.imdb):
            return True

        # if no IMDB link, at least check year range 1
        if len(movie.name.split(' ')) > 2 and self.correctYear([item.name], movie.year, 1) and self.correctName(item.name, movie.name):
            return True

        # if no IMDB link, at least check year
        if len(movie.name.split(' ')) == 2 and self.correctYear([item.name], movie.year, 0) and self.correctName(item.name, movie.name):
            return True

        return False
Пример #2
0
    def isCorrectMovie(self, item, movie, qualityType, imdbResults = False, singleCategory = False):

        # Ignore already added.
        if self.alreadyTried(item, movie.id):
            log.info('Already tried this one, ignored: %s' % item.name)
            return False

        def get_words(text):
            return filter(None, re.split('\W+', text.lower()))

        nzbWords = get_words(item.name)
        requiredWords = get_words(self.config.get('global', 'requiredWords'))
        missing = set(requiredWords) - set(nzbWords)
        if missing:
            log.info("NZB '%s' misses the following required words: %s" %
                            (item.name, ", ".join(missing)))
            return False

        ignoredWords = get_words(self.config.get('global', 'ignoreWords'))
        blacklisted = set(ignoredWords).intersection(set(nzbWords))
        if blacklisted:
            log.info("NZB '%s' contains the following blacklisted words: %s" %
                            (item.name, ", ".join(blacklisted)))
            return False

        q = Qualities()
        type = q.types.get(qualityType)

        # Contains lower quality string
        if self.containsOtherQuality(item.name, type, singleCategory):
            log.info('Wrong: %s, contains other quality, looking for %s' % (item.name, type['label']))
            return False

        # Outsize retention
        if item.type is 'nzb':
            if item.date < time.time() - (int(self.config.get('NZB', 'retention')) * 24 * 60 * 60):
                log.info('Found but outside %s retention: %s' % (self.config.get('NZB', 'retention'), item.name))
                return False

        # File to small
        minSize = q.minimumSize(qualityType)
        if minSize > item.size:
            log.info('"%s" is too small to be %s. %sMB instead of the minimal of %sMB.' % (item.name, type['label'], item.size, minSize))
            return False

        # File to large
        maxSize = q.maximumSize(qualityType)
        if maxSize < item.size:
            log.info('"%s" is too large to be %s. %sMB instead of the maximum of %sMB.' % (item.name, type['label'], item.size, maxSize))
            return False

        if imdbResults:
            return True

        # Check if nzb contains imdb link
        if self.checkIMDB([item.content], movie.imdb):
            return True

        # if no IMDB link, at least check year range 1
        #if len(movie.name.split(' ')) > 2 and self.correctYear([item.name], movie.year, 1) and self.correctName(item.name, movie.name):
        if self.correctName(item.name, movie.name):
            return True

        # if no IMDB link, at least check year
        #if len(movie.name.split(' ')) == 2 and self.correctYear([item.name], movie.year, 0) and self.correctName(item.name, movie.name):
        if self.correctName(item.name, movie.name):
            return True

        log.info("Wrong: %s, undetermined naming. Looking for '%s (%s)'" % (item.name, movie.name, movie.year))
        return False
Пример #3
0
    def isCorrectMovie(self,
                       item,
                       movie,
                       qualityType,
                       imdbResults=False,
                       singleCategory=False):

        # Ignore already added.
        #if self.alreadyTried(item, movie.id):
        #    log.info('Already tried this one, ignored: %s' % item.name)
        #    return False

        def get_words(text):
            return filter(None, re.split('\W+', text.lower()))

        nzbWords = get_words(item.name)
        requiredWords = self.config.get('global', 'requiredWords').split(',')
        # missing = set(requiredWords) - set(nzbWords)
        missing = True
        for word in requiredWords:
            if word.strip() and word.strip().lower() in nzbWords:
                missing = False

        if missing:
            log.info("NZB '%s' misses the required words" % (item.name))
            return False

        ignoredWords = get_words(self.config.get('global', 'ignoreWords'))
        blacklisted = set(ignoredWords).intersection(set(nzbWords))
        if blacklisted:
            log.info("NZB '%s' contains the following blacklisted words: %s" %
                     (item.name, ", ".join(blacklisted)))
            return False

        q = Qualities()
        type = q.types.get(qualityType)

        # Contains lower quality string
        if self.containsOtherQuality(item.name, type, singleCategory):
            log.info('Wrong: %s, contains other quality, looking for %s' %
                     (item.name, type['label']))
            return False

        # Outsize retention
        if item.type is 'nzb':
            if item.date < time.time() - (
                    int(self.config.get('NZB', 'retention')) * 24 * 60 * 60):
                log.info('Found but outside %s retention: %s' %
                         (self.config.get('NZB', 'retention'), item.name))
                return False

        # File to small
        minSize = q.minimumSize(qualityType)
        if minSize > item.size:
            log.info(
                '"%s" is too small to be %s. %sMB instead of the minimal of %sMB.'
                % (item.name, type['label'], item.size, minSize))
            return False

        # File to large
        maxSize = q.maximumSize(qualityType)
        if maxSize < item.size:
            log.info(
                '"%s" is too large to be %s. %sMB instead of the maximum of %sMB.'
                % (item.name, type['label'], item.size, maxSize))
            return False

        if imdbResults:
            return True

        # Check if nzb contains imdb link
        if self.checkIMDB([item.content], movie.imdb):
            return True

        # if no IMDB link, at least check year range 1
        if len(movie.name.split(' ')) > 2 and self.correctYear(
            [item.name], movie.year, 1) and self.correctName(
                item.name, movie.name):
            return True

        # if no IMDB link, at least check year
        if len(movie.name.split(' ')) == 2 and self.correctYear(
            [item.name], movie.year, 0) and self.correctName(
                item.name, movie.name):
            return True

        log.info("Wrong: %s, undetermined naming. Looking for '%s (%s)'" %
                 (item.name, movie.name, movie.year))
        return False