How to use the guessit.matcher.found_property function in guessit

To help you get started, we’ve selected a few guessit examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github guessit-io / guessit / guessit / transfo / guess_episode_info_from_position.py View on Github external
found_property(series_candidates[0], 'series', confidence=0.7)

        # only 1 group after (in the same path group) and it's probably the
        # episode title.
        title_candidates = GuessEpisodeInfoFromPosition._filter_candidates(after_epnum_in_same_pathgroup(), options)
        if len(title_candidates) == 1:
            found_property(title_candidates[0], 'title', confidence=0.5)
            return
        else:
            # try in the same explicit group, with lower confidence
            title_candidates = GuessEpisodeInfoFromPosition._filter_candidates(after_epnum_in_same_explicitgroup(), options)
            if len(title_candidates) == 1:
                found_property(title_candidates[0], 'title', confidence=0.4)
                return
            elif len(title_candidates) > 1:
                found_property(title_candidates[0], 'title', confidence=0.3)
                return

        # get the one with the longest value
        title_candidates = GuessEpisodeInfoFromPosition._filter_candidates(after_epnum_in_same_pathgroup(), options)
        if title_candidates:
            maxidx = -1
            maxv = -1
            for i, c in enumerate(title_candidates):
                if len(c.clean_value) > maxv:
                    maxidx = i
                    maxv = len(c.clean_value)
            if maxidx > -1:
                found_property(title_candidates[maxidx], 'title', confidence=0.3)
github guessit-io / guessit / guessit / transfo / guess_bonus_features.py View on Github external
if leaf.node_idx < g.node_idx:
                    return leaf

        def next_group(g):
            for leaf in mtree.unidentified_leaves():
                if leaf.node_idx > g.node_idx:
                    return leaf

        def same_group(g1, g2):
            return g1.node_idx[:2] == g2.node_idx[:2]

        bonus = [node for node in mtree.leaves() if 'bonusNumber' in node.guess]
        if bonus:
            bonus_title = next_group(bonus[0])
            if bonus_title and same_group(bonus_title, bonus[0]):
                found_property(bonus_title, 'bonusTitle', confidence=0.8)

        film_number = [node for node in mtree.leaves()
                       if 'filmNumber' in node.guess]
        if film_number:
            film_series = previous_group(film_number[0])
            if film_series:
                found_property(film_series, 'filmSeries', confidence=0.9)

            title = next_group(film_number[0])
            if title:
                found_property(title, 'title', confidence=0.9)

        season = [node for node in mtree.leaves() if 'season' in node.guess]
        if season and 'bonusNumber' in mtree.info:
            series = previous_group(season[0])
            if same_group(series, season[0]):
github mdhiggins / sickbeard_mp4_automator / guessit / transfo / guess_episode_info_from_position.py View on Github external
found_property(title_candidates[0], 'title', confidence=0.4)
            return

        if ('title' not in mtree.info and  # no title
                before_epnum_in_same_pathgroup() == [] and  # no groups before
                len(title_candidates) == 2):  # only 2 groups after

            found_property(title_candidates[0], 'series', confidence=0.4)
            found_property(title_candidates[1], 'title', confidence=0.4)
            return

        # if we have at least 1 valid group before the episodeNumber, then it's
        # probably the series name
        series_candidates = before_epnum_in_same_pathgroup()
        if len(series_candidates) >= 1:
            found_property(series_candidates[0], 'series', confidence=0.7)

        # only 1 group after (in the same path group) and it's probably the
        # episode title.
        title_candidates = self._filter_candidates(after_epnum_in_same_pathgroup(), options)
        if len(title_candidates) == 1:
            found_property(title_candidates[0], 'title', confidence=0.5)
            return
        else:
            # try in the same explicit group, with lower confidence
            title_candidates = self._filter_candidates(after_epnum_in_same_explicitgroup(), options)
            if len(title_candidates) == 1:
                found_property(title_candidates[0], 'title', confidence=0.4)
                return
            elif len(title_candidates) > 1:
                found_property(title_candidates[0], 'title', confidence=0.3)
                return
github caronc / nzb-subliminal / Subliminal / guessit / transfo / guess_episode_info_from_position.py View on Github external
except ValueError:
            series_candidates = []

        if len(series_candidates) == 1:
            found_property(series_candidates[0], 'series', confidence=0.3)

        # if there's a path group that only contains the season info, then the
        # previous one is most likely the series title (ie: ../series/season X/..)
        eps = [node for node in mtree.nodes()
               if 'season' in node.guess and 'episodeNumber' not in node.guess]

        if eps:
            previous = [node for node in mtree.unidentified_leaves()
                        if node.node_idx[0] == eps[0].node_idx[0] - 1]
            if len(previous) == 1:
                found_property(previous[0], 'series', confidence=0.5)

        # If we have found title without any serie name, replace it by the serie name.
        if 'series' not in mtree.info and 'title' in mtree.info:
            title_leaf = mtree.first_leaf_containing('title')
            metadata = title_leaf.guess.metadata('title')
            value = title_leaf.guess['title']
            del title_leaf.guess['title']
            title_leaf.guess.set('series', value, metadata=metadata)
github h3llrais3r / Auto-Subliminal / lib / guessit / transfo / guess_episode_info_from_position.py View on Github external
def after_epnum_in_same_explicitgroup():
            return [leaf for leaf in mtree.unidentified_leaves(lambda x: len(x.clean_value) > 1)
                     if (leaf.node_idx[:2] == epnum_idx[:2] and
                         leaf.node_idx[2:] > epnum_idx[2:])]

        # epnumber is the first group and there are only 2 after it in same
        # path group
        # -> series title - episode title
        title_candidates = self._filter_candidates(after_epnum_in_same_pathgroup(), options)

        if ('title' not in mtree.info and  # no title
                    'series' in mtree.info and # series present
                    before_epnum_in_same_pathgroup() == [] and  # no groups before
                    len(title_candidates) == 1):  # only 1 group after

            found_property(title_candidates[0], 'title', confidence=0.4)
            return

        if ('title' not in mtree.info and  # no title
            before_epnum_in_same_pathgroup() == [] and  # no groups before
            len(title_candidates) == 2):  # only 2 groups after

            found_property(title_candidates[0], 'series', confidence=0.4)
            found_property(title_candidates[1], 'title', confidence=0.4)
            return

        # if we have at least 1 valid group before the episodeNumber, then it's
        # probably the series name
        series_candidates = before_epnum_in_same_pathgroup()
        if len(series_candidates) >= 1:
            found_property(series_candidates[0], 'series', confidence=0.7)
github guessit-io / guessit / guessit / transfo / guess_movie_title_from_position.py View on Github external
not GuessMovieTitleFromPosition.excluded_word(title, series)):

                    found_property(title, 'title', confidence=0.6)
                    found_property(series, 'filmSeries', confidence=0.6)
                    found_property(film_number, 'filmNumber', num, confidence=0.6)
                return

        if folder:
            year_group = folder.first_leaf_containing('year')
            if year_group:
                groups_before = folder.previous_unidentified_leaves(year_group)
                if groups_before:
                    try:
                        node = next(groups_before)
                        if not GuessMovieTitleFromPosition.excluded_word(node):
                            found_property(node, 'title', confidence=0.8)
                            return
                    except StopIteration:
                        pass

        # if we have either format or videoCodec in the folder containing the
        # file or one of its parents, then we should probably look for the title
        # in there rather than in the basename
        try:
            props = list(mtree.previous_leaves_containing(mtree.children[-2],
                                                          ['videoCodec',
                                                           'format',
                                                           'language']))
        except IndexError:
            props = []

        if props:
github pymedusa / Medusa / lib / guessit / transfo / guess_episode_info_from_position.py View on Github external
if not eps:
            eps = [node for node in mtree.leaves() if 'date' in node.guess]

        if eps:
            self.match_from_epnum_position(mtree, eps[0], options)

        else:
            # if we don't have the episode number, but at least 2 groups in the
            # basename, then it's probably series - eptitle
            basename = mtree.node_at((-2,))

            title_candidates = self._filter_candidates(basename.unidentified_leaves(), options)

            if len(title_candidates) >= 2 and 'series' not in mtree.info:
                found_property(title_candidates[0], 'series', confidence=0.4)
                found_property(title_candidates[1], 'title', confidence=0.4)
            elif len(title_candidates) == 1:
                # but if there's only one candidate, it's probably the series name
                found_property(title_candidates[0], 'series' if 'series' not in mtree.info else 'title', confidence=0.4)

        # if we only have 1 remaining valid group in the folder containing the
        # file, then it's likely that it is the series name
        try:
            series_candidates = list(mtree.node_at((-3,)).unidentified_leaves())
        except ValueError:
            series_candidates = []

        if len(series_candidates) == 1:
            found_property(series_candidates[0], 'series', confidence=0.3)

        # if there's a path group that only contains the season info, then the
        # previous one is most likely the series title (ie: ../series/season X/..)
github guessit-io / guessit / guessit / transfo / guess_episode_info_from_position.py View on Github external
title_candidates = GuessEpisodeInfoFromPosition._filter_candidates(after_epnum_in_same_pathgroup(), options)

        if ('title' not in path_node.info and  # no title
                'series' in path_node.info and # series present
                before_epnum_in_same_pathgroup() == [] and  # no groups before
                len(title_candidates) == 1):  # only 1 group after

            found_property(title_candidates[0], 'title', confidence=0.4)
            return

        if ('title' not in path_node.info and  # no title
                before_epnum_in_same_pathgroup() == [] and  # no groups before
                len(title_candidates) == 2):  # only 2 groups after

            found_property(title_candidates[0], 'series', confidence=0.4)
            found_property(title_candidates[1], 'title', confidence=0.4)
            return

        # if we have at least 1 valid group before the episodeNumber, then it's
        # probably the series name
        series_candidates = before_epnum_in_same_pathgroup()
        if len(series_candidates) >= 1:
                found_property(series_candidates[0], 'series', confidence=0.7)

        # only 1 group after (in the same path group) and it's probably the
        # episode title.
        title_candidates = GuessEpisodeInfoFromPosition._filter_candidates(after_epnum_in_same_pathgroup(), options)
        if len(title_candidates) == 1:
            found_property(title_candidates[0], 'title', confidence=0.5)
            return
        else:
            # try in the same explicit group, with lower confidence
github caronc / nzb-subliminal / Subliminal / guessit / transfo / guess_episode_info_from_position.py View on Github external
def after_epnum_in_same_explicitgroup():
            return [leaf for leaf in mtree.unidentified_leaves(lambda x: len(x.clean_value) > 1)
                     if (leaf.node_idx[:2] == epnum_idx[:2] and
                         leaf.node_idx[2:] > epnum_idx[2:])]

        # epnumber is the first group and there are only 2 after it in same
        # path group
        # -> series title - episode title
        title_candidates = self._filter_candidates(after_epnum_in_same_pathgroup(), options)

        if ('title' not in mtree.info and  # no title
                    'series' in mtree.info and # series present
                    before_epnum_in_same_pathgroup() == [] and  # no groups before
                    len(title_candidates) == 1):  # only 1 group after

            found_property(title_candidates[0], 'title', confidence=0.4)
            return

        if ('title' not in mtree.info and  # no title
            before_epnum_in_same_pathgroup() == [] and  # no groups before
            len(title_candidates) == 2):  # only 2 groups after

            found_property(title_candidates[0], 'series', confidence=0.4)
            found_property(title_candidates[1], 'title', confidence=0.4)
            return

        # if we have at least 1 valid group before the episodeNumber, then it's
        # probably the series name
        series_candidates = before_epnum_in_same_pathgroup()
        if len(series_candidates) >= 1:
            found_property(series_candidates[0], 'series', confidence=0.7)
github guessit-io / guessit / guessit / transfo / guess_movie_title_from_position.py View on Github external
try:
                num = int(film_number.clean_value)
            except ValueError:
                pass

            if num:
                self.log.debug('series: %s' % series.clean_value)
                self.log.debug('title: %s' % title.clean_value)
                if (series.clean_value != title.clean_value and
                            series.clean_value != film_number.clean_value and
                            basename_leaves.index(film_number) == 0 and
                            basename_leaves.index(title) == 1 and
                            not GuessMovieTitleFromPosition.excluded_word(title, series)):

                    found_property(title, 'title', confidence=0.6)
                    found_property(series, 'filmSeries', confidence=0.6)
                    found_property(film_number, 'filmNumber', num, confidence=0.6)
                return

        if folder:
            year_group = folder.first_leaf_containing('year')
            if year_group:
                groups_before = folder.previous_unidentified_leaves(year_group)
                if groups_before:
                    try:
                        node = next(groups_before)
                        if not GuessMovieTitleFromPosition.excluded_word(node):
                            found_property(node, 'title', confidence=0.8)
                            return
                    except StopIteration:
                        pass