Beispiel #1
0
    def get_matches(self, video):
        matches = set()

        # episode
        if isinstance(video, Episode):
            # series name
            if video.series and sanitize(self.series) in (
                    sanitize(name)
                    for name in [video.series] + video.alternative_series):
                matches.add('series')
            # year
            if video.original_series and self.year is None or video.year and video.year == self.year:
                matches.add('year')

        # release_group
        if (video.release_group and self.version
                and any(r in sanitize_release_group(self.version)
                        for r in get_equivalent_release_groups(
                            sanitize_release_group(video.release_group)))):
            matches.add('release_group')
        # other properties
        matches |= guess_matches(video,
                                 guessit(self.version, {'type': 'episode'}),
                                 partial=True)

        return matches
Beispiel #2
0
    def get_matches(self, video):
        matches = set()

        # movie
        if isinstance(video, Movie):
            # title
            if video.title and (sanitize(self.title) in (
                    sanitize(name)
                    for name in [video.title] + video.alternative_titles)):
                matches.add('title')
            # year
            if video.year and self.year == video.year:
                matches.add('year')

        # release_group
        if (video.release_group and self.version
                and any(r in sanitize_release_group(self.version)
                        for r in get_equivalent_release_groups(
                            sanitize_release_group(video.release_group)))):
            matches.add('release_group')
        # other properties
        matches |= guess_matches(video,
                                 guessit(self.version, {'type': 'movie'}),
                                 partial=True)

        return matches
Beispiel #3
0
    def get_matches(self, video: Episode):
        matches = set()

        # series
        if video.series and sanitize(self.series) == sanitize(video.series):
            matches.add('series')
        # season
        if video.season and self.season == video.season:
            matches.add('season')
        # episode
        if video.episode and self.episode == video.episode:
            matches.add('episode')
        # title
        if video.title and sanitize(self.title) == sanitize(video.title):
            matches.add('title')
        # year
        if video.original_series and self.year is None or video.year and video.year == self.year:
            matches.add('year')
        # release_group
        if (video.release_group and self.version and
                any(r in sanitize_release_group(self.version)
                    for r in get_equivalent_release_groups(sanitize_release_group(video.release_group)))):
            matches.add('release_group')
        # resolution
        if video.resolution and self.version and video.resolution in self.version.lower():
            matches.add('resolution')
        # source
        if video.source and self.version and video.source.lower() in self.version.lower():
            matches.add('source')
        # other properties
        matches |= guess_matches(video, guessit(self.version), partial=True)

        return matches
Beispiel #4
0
    def get_matches(self, video):
        type_ = "movie" if isinstance(video, Movie) else "episode"
        matches = guess_matches(video,
                                guessit(self.release_info, {"type": type_}))

        # episode
        if isinstance(video, Episode):
            # series
            if video.series and sanitize(self.series) == sanitize(
                    video.series):
                matches.add('series')
            # imdb_id
            if video.series_imdb_id and self.imdb_id and str(
                    self.imdb_id) == str(video.series_imdb_id):
                matches.add('series_imdb_id')
                matches.add('series')
                matches.add('year')
            # year
            if 'year' not in matches and 'series' in matches and video.original_series and self.year is None:
                matches.add('year')
        # movie
        elif isinstance(video, Movie):
            # title
            if video.title and (sanitize(self.series) in (
                    sanitize(name)
                    for name in [video.title] + video.alternative_titles)):
                matches.add('title')
            # imdb_id
            if video.imdb_id and self.imdb_id == video.imdb_id:
                matches.add('imdb_id')
                matches.add('title')
                matches.add('year')
            # year
            if video.year and self.year == video.year:
                matches.add('year')

        # release_group
        if video.release_group and self.releases:
            video_release_groups = get_equivalent_release_groups(
                sanitize_release_group(video.release_group))
            for release in self.releases:

                if any(r in sanitize_release_group(release)
                       for r in video_release_groups):
                    matches.add('release_group')

                    if video.resolution and video.resolution in release.lower(
                    ):
                        matches.add('resolution')

                    if video.source and video.source in release.lower():
                        matches.add('source')

                # We don't have to continue in case it is a perfect match
                if all(m in matches
                       for m in ['release_group', 'resolution', 'source']):
                    break

        self.matches = matches
        return matches
Beispiel #5
0
    def get_matches(self, video):
        matches = set()
        # series
        if video.series and ( sanitize(self.series) == sanitize(fix_inconsistent_naming(video.series)) or sanitize(self.series) == sanitize(video.series)):
            matches.add('series')
        # season
        if video.season and self.season == video.season:
            matches.add('season')
        # episode
        if video.episode and self.episode == video.episode:
            matches.add('episode')
        # year
        if ('series' in matches and video.original_series and self.year is None or
           video.year and video.year == self.year):
            matches.add('year')

        # release_group
        if (video.release_group and self.version and
                any(r in sanitize_release_group(self.version)
                    for r in get_equivalent_release_groups(sanitize_release_group(video.release_group)))):
            matches.add('release_group')
        # resolution
        if video.resolution and self.version and video.resolution in self.version.lower():
            matches.add('resolution')
        # format
        if video.format and self.version and video.format.lower() in self.version.lower():
            matches.add('format')
        # other properties
        matches |= guess_matches(video, guessit(self.release_info))

        return matches
Beispiel #6
0
    def get_matches(self, video):
        matches = set()

        # series name
        if video.series and sanitize(self.series) in (
                sanitize(name) for name in [video.series] + video.alternative_series):
            matches.add('series')
        # season
        if video.season and self.season == video.season:
            matches.add('season')
        # episode
        if video.episode and self.episode == video.episode:
            matches.add('episode')
        # title of the episode
        if video.title and sanitize(self.title) == sanitize(video.title):
            matches.add('title')
        # year
        if video.original_series and self.year is None or video.year and video.year == self.year:
            matches.add('year')
        # release_group
        if (video.release_group and self.version and
                any(r in sanitize_release_group(self.version)
                    for r in get_equivalent_release_groups(sanitize_release_group(video.release_group)))):
            matches.add('release_group')
        # resolution
        if video.resolution and self.version and video.resolution in self.version.lower():
            matches.add('resolution')
        # source
        if video.source and self.version and video.source.lower() in self.version.lower():
            matches.add('source')
        # other properties
        matches |= guess_matches(video, guessit(self.version), partial=True)

        return matches
Beispiel #7
0
    def get_matches(self, video):
        matches = set()
        # series
        if video.series and ( sanitize(self.series) == sanitize(fix_inconsistent_naming(video.series)) or sanitize(self.series) == sanitize(video.series)):
            matches.add('series')
        # season
        if video.season and self.season == video.season:
            matches.add('season')
        # episode
        if video.episode and self.episode == video.episode:
            matches.add('episode')
        # year
        if ('series' in matches and video.original_series and self.year is None or
           video.year and video.year == self.year):
            matches.add('year')

        # release_group
        if (video.release_group and self.version and
                any(r in sanitize_release_group(self.version)
                    for r in get_equivalent_release_groups(sanitize_release_group(video.release_group)))):
            matches.add('release_group')
        # resolution
        if video.resolution and self.version and video.resolution in self.version.lower():
            matches.add('resolution')
        # format
        if video.format and self.version and video.format.lower() in self.version.lower():
            matches.add('format')
        # other properties
        matches |= guess_matches(video, guessit(self.release_info.encode("utf-8")))

        return matches
Beispiel #8
0
    def get_matches(self, video):
        matches = set()
        # series
        if video.series and (sanitize(self.series) == sanitize(
                fix_inconsistent_naming(video.series)) or sanitize(self.series)
                             == sanitize(video.series)):
            matches.add('series')
        # season
        if video.season and self.season == video.season:
            matches.add('season')
        # episode
        if video.episode and self.episode == video.episode:
            matches.add('episode')
        # year
        if ('series' in matches and video.original_series and self.year is None
                or video.year and video.year == self.year):
            matches.add('year')

        logger.debug("Matches: %s", matches)

        # release_group
        if (video.release_group and self.version
                and any(r in sanitize_release_group(self.version)
                        for r in get_equivalent_release_groups(
                            sanitize_release_group(video.release_group)))):
            matches.add('release_group')

        matches |= guess_matches(video, guessit(self.release_info),
                                 {"type": "episode"})

        return matches
Beispiel #9
0
    def get_matches(self, video):
        matches = guess_matches(video,
                                guessit(self.release_info.encode("utf-8")))

        # episode
        if isinstance(video, Episode):
            # series
            if video.series and sanitize(self.series) == sanitize(
                    video.series):
                matches.add('series')
            # season
            if video.season and self.season == video.season:
                matches.add('season')
            # episode
            if video.episode and self.episode == video.episode:
                matches.add('episode')
            # imdb_id
            if video.series_imdb_id and self.imdb_id and str(
                    self.imdb_id) == str(video.series_imdb_id):
                matches.add('series_imdb_id')
                matches.add('series')
                matches.add('year')
            # year
            if ('series' in matches and video.original_series
                    and self.year is None
                    or video.year and video.year == self.year):
                matches.add('year')
        # movie
        elif isinstance(video, Movie):
            # title
            if video.title and (sanitize(self.series) in (
                    sanitize(name)
                    for name in [video.title] + video.alternative_titles)):
                matches.add('title')
            # imdb_id
            if video.imdb_id and self.imdb_id == video.imdb_id:
                matches.add('imdb_id')
                matches.add('title')
                matches.add('year')
            # year
            if video.year and self.year == video.year:
                matches.add('year')

        # release_group
        if (video.release_group and self.version
                and any(r in sanitize_release_group(self.version)
                        for r in get_equivalent_release_groups(
                            sanitize_release_group(video.release_group)))):
            matches.add('release_group')
        # resolution
        if video.resolution and self.version and video.resolution in self.version.lower(
        ):
            matches.add('resolution')
        # format
        if video.format and self.version and video.format.lower(
        ) in self.version.lower():
            matches.add('format')

        self.matches = matches
        return matches
Beispiel #10
0
    def get_matches(self, video):
        matches = set()

        # handle movies and series separately
        if isinstance(video, Episode):
            # series
            if video.series and sanitize(
                    self.title) == fix_inconsistent_naming(
                        video.series) or sanitize(
                            self.alt_title) == fix_inconsistent_naming(
                                video.series):
                matches.add('series')
            # year
            if video.original_series and self.year is None or video.year and video.year == self.year:
                matches.add('year')
            # season
            if video.season and self.season == video.season:
                matches.add('season')
            # episode
            if video.episode and self.episode == video.episode:
                matches.add('episode')
        # movie
        elif isinstance(video, Movie):
            # title
            if video.title and sanitize(self.title) == fix_inconsistent_naming(
                    video.title) or sanitize(
                        self.alt_title) == fix_inconsistent_naming(
                            video.title):
                matches.add('title')
            # year
            if video.year and self.year == video.year:
                matches.add('year')

        # rest is same for both groups

        # release_group
        if (video.release_group and self.releases
                and any(r in sanitize_release_group(self.releases)
                        for r in get_equivalent_release_groups(
                            sanitize_release_group(video.release_group)))):
            matches.add('release_group')
        # resolution
        if video.resolution and self.releases and video.resolution in self.releases.lower(
        ):
            matches.add('resolution')
        # source
        if video.source and self.releases and video.source.lower(
        ) in self.releases.lower():
            matches.add('source')
        # other properties
        matches |= guess_matches(video, guessit(self.releases))

        self.matches = matches

        return matches
Beispiel #11
0
    def get_matches(self, video):
        matches = set()
        video_type = None

        # episode
        if isinstance(video, Episode):
            video_type = 'episode'
            # series name
            if video.series and sanitize(self.series) in (
                    sanitize(name)
                    for name in [video.series] + video.alternative_series):
                matches.add('series')
            # season
            if video.season and self.season == video.season:
                matches.add('season')
            # episode
            if video.episode and self.episode == video.episode:
                matches.add('episode')
            # title of the episode
            if video.title and sanitize(self.title) == sanitize(video.title):
                matches.add('title')
            # year
            if video.original_series and self.year is None or video.year and video.year == self.year:
                matches.add('year')
        # movie
        elif isinstance(video, Movie):
            video_type = 'movie'
            # title
            if video.title and (sanitize(self.title) in (
                    sanitize(name)
                    for name in [video.title] + video.alternative_titles)):
                matches.add('title')
            # year
            if video.year and self.year == video.year:
                matches.add('year')

        # release_group
        if (video.release_group and self.version
                and any(r in sanitize_release_group(self.version)
                        for r in get_equivalent_release_groups(
                            sanitize_release_group(video.release_group)))):
            matches.add('release_group')
        # other properties
        matches |= guess_matches(video,
                                 guessit(self.version, {'type': video_type}),
                                 partial=True)

        return matches
Beispiel #12
0
    def get_matches(self, video):
        matches = set()
        type_ = "movie" if isinstance(video, Movie) else "episode"
        # handle movies and series separately
        if type_ == "episode":
            # series
            if video.series and sanitize(
                    self.title) == fix_inconsistent_naming(
                        video.series) or sanitize(
                            self.alt_title) == fix_inconsistent_naming(
                                video.series):
                matches.add('series')
            # year
            if video.original_series and self.year is None or video.year and video.year == self.year:
                matches.add('year')
            # season
            if video.season and self.season == video.season:
                matches.add('season')
            # episode
            if video.episode and self.episode == video.episode:
                matches.add('episode')
        # movie
        else:
            # title
            if video.title and sanitize(self.title) == fix_inconsistent_naming(
                    video.title) or sanitize(
                        self.alt_title) == fix_inconsistent_naming(
                            video.title):
                matches.add('title')
            # year
            if video.year and self.year == video.year:
                matches.add('year')

        # rest is same for both groups

        # release_group
        if (video.release_group and self.releases
                and any(r in sanitize_release_group(self.releases)
                        for r in get_equivalent_release_groups(
                            sanitize_release_group(video.release_group)))):
            matches.add('release_group')

        matches |= guess_matches(video, guessit(self.releases,
                                                {"type": type_}))

        self.matches = matches

        return matches
    def get_matches(self, video):
        matches = set()

        # handle movies and series separately
        if isinstance(video, Episode):
            # series
            if video.series and sanitize(self.title) == fix_inconsistent_naming(video.series) or sanitize(
                    self.alt_title) == fix_inconsistent_naming(video.series):
                matches.add('series')
            # year
            if video.original_series and self.year is None or video.year and video.year == self.year:
                matches.add('year')
            # season
            if video.season and self.season == video.season:
                matches.add('season')
            # episode
            if video.episode and self.episode == video.episode:
                matches.add('episode')
        # movie
        elif isinstance(video, Movie):
            # title
            if video.title and sanitize(self.title) == fix_inconsistent_naming(video.title) or sanitize(
                    self.alt_title) == fix_inconsistent_naming(video.title):
                matches.add('title')
            # year
            if video.year and self.year == video.year:
                matches.add('year')

        # rest is same for both groups

        # release_group
        if (video.release_group and self.releases and
                any(r in sanitize_release_group(self.releases)
                    for r in get_equivalent_release_groups(sanitize_release_group(video.release_group)))):
            matches.add('release_group')
        # resolution
        if video.resolution and self.releases and video.resolution in self.releases.lower():
            matches.add('resolution')
        # format
        if video.format and self.releases and video.format.lower() in self.releases.lower():
            matches.add('format')
        # other properties
        matches |= guess_matches(video, guessit(self.releases))

        self.matches = matches

        return matches
Beispiel #14
0
    def get_matches(self, video):
        matches = set()

        # handle movies and series separately
        if isinstance(video, Episode):
            # series
            matches.add('series')
            # year
            if video.year == self.year:
                matches.add('year')
            # season
            if video.season == self.season:
                matches.add('season')
            # episode
            if video.episode == self.episode:
                matches.add('episode')
        # movie
        elif isinstance(video, Movie):
            # title
            matches.add('title')
            # year
            if video.year == self.year:
                matches.add('year')

        # rest is same for both groups

        # release_group
        if (video.release_group and self.releases and
                any(r in sanitize_release_group(self.releases)
                    for r in get_equivalent_release_groups(sanitize_release_group(video.release_group)))):
            matches.add('release_group')
        # resolution
        if video.resolution and self.releases and video.resolution in self.releases.lower():
            matches.add('resolution')
        # source
        if video.source and self.releases and video.source.lower() in self.releases.lower():
            matches.add('source')
        # hash
        if self.hash_matched:
            matches.add('hash')
        # other properties
        matches |= guess_matches(video, guessit(self.releases))

        self.matches = matches

        return matches
Beispiel #15
0
    def get_matches(self, video):
        matches = set()
        type_ = "movie" if isinstance(video, Movie) else "episode"

        # handle movies and series separately
        if type_ == "episode":
            # series
            matches.add('series')
            # year
            if video.year == self.year:
                matches.add('year')
            # season
            if video.season == self.season:
                matches.add('season')
            # episode
            if video.episode == self.episode:
                matches.add('episode')
        else:
            # title
            matches.add('title')
            # year
            if video.year == self.year:
                matches.add('year')

        # rest is same for both groups

        # release_group
        if (video.release_group and self.releases
                and any(r in sanitize_release_group(self.releases)
                        for r in get_equivalent_release_groups(
                            sanitize_release_group(video.release_group)))):
            matches.add('release_group')

        if self.hash_matched:
            matches.add('hash')

        # other properties
        matches |= guess_matches(video, guessit(self.releases,
                                                {"type": type_}))

        self.matches = matches

        return matches
Beispiel #16
0
    def get_matches(self, video):
        matches = set()
        # series
        if isinstance(video, Episode) and self.movie_kind == 'episode':
            if video.series and (sanitize(self.title) in (
                    sanitize(name)
                    for name in [video.series] + video.alternative_series)):
                matches.add('series')
            # season
            if video.season and self.season == video.season:
                matches.add('season')
            # episode
            if video.episode and self.episode == video.episode:
                matches.add('episode')

            # tvdb_id
            if video.tvdb_id and str(self.tvdb_id) == str(video.tvdb_id):
                matches.add('tvdb_id')

        elif isinstance(video, Movie) and self.movie_kind == 'movie':
            # title
            if video.title and (sanitize(self.title) in (
                    sanitize(name)
                    for name in [video.title] + video.alternative_titles)):
                matches.add('title')

            # imdb_id
            if video.imdb_id and self.imdb_id and str(self.imdb_id) == str(
                    video.imdb_id):
                matches.add('imdb_id')

            # year
            if video.year and self.year == video.year:
                matches.add('year')
        else:
            logger.info('%r is not a valid movie_kind', self.movie_kind)
            return matches

        # release_group
        if video.release_group and self.release:
            rg = sanitize_release_group(video.release_group)
            if any(r in sanitize_release_group(self.release)
                   for r in get_equivalent_release_groups(rg)):
                matches.add('release_group')

                # blatantly assume we've got a matching format if the release group matches
                # fixme: smart?
                #matches.add('format')

        # resolution
        if video.resolution and self.version and str(
                video.resolution) in self.version.lower():
            matches.add('resolution')
        # format
        if video.format and self.format:
            formats = [video.format]
            if video.format == "WEB-DL":
                formats.append("WEB")

            for fmt in formats:
                if fmt.lower() in self.format.lower():
                    matches.add('format')
                    break

        matches |= guess_matches(video,
                                 guessit(self.release_info),
                                 partial=True)
        self.matches = matches
        return matches
Beispiel #17
0
    def get_matches(self, video):
        matches = set()
        # series
        if isinstance(video, Episode) and self.movie_kind == 'episode':
            if video.series and (sanitize(self.title) in (
                     sanitize(name) for name in [video.series] + video.alternative_series)):
                matches.add('series')
            # season
            if video.season and self.season == video.season:
                matches.add('season')
            # episode
            if video.episode and self.episode == video.episode:
                matches.add('episode')

            # tvdb_id
            if video.tvdb_id and str(self.tvdb_id) == str(video.tvdb_id):
                matches.add('tvdb_id')

        elif isinstance(video, Movie) and self.movie_kind == 'movie':
            # title
            if video.title and (sanitize(self.title) in (
                     sanitize(name) for name in [video.title] + video.alternative_titles)):
                matches.add('title')

            # imdb_id
            if video.imdb_id and self.imdb_id and str(self.imdb_id) == str(video.imdb_id):
                matches.add('imdb_id')

            # year
            if video.year and self.year == video.year:
                matches.add('year')
        else:
            logger.info('%r is not a valid movie_kind', self.movie_kind)
            return matches

        # release_group
        if video.release_group and self.release:
            rg = sanitize_release_group(video.release_group)
            if any(r in sanitize_release_group(self.release) for r in get_equivalent_release_groups(rg)):
                matches.add('release_group')

                # blatantly assume we've got a matching format if the release group matches
                # fixme: smart?
                #matches.add('format')

        # resolution
        if video.resolution and self.version and str(video.resolution) in self.version.lower():
            matches.add('resolution')
        # format
        if video.format and self.format:
            formats = [video.format]
            if video.format == "WEB-DL":
                formats.append("WEB")

            for fmt in formats:
                if fmt.lower() in self.format.lower():
                    matches.add('format')
                    break

        matches |= guess_matches(video, guessit(self.release_info), partial=True)
        self.matches = matches
        return matches