Пример #1
0
    def quality_from_name(name, anime=False):
        """
        Return the quality from the episode filename with the regex.

        :param name: Episode filename to analyse
        :param anime: Boolean to indicate if the show we're resolving is anime
        :return: Quality
        """
        from medusa.tagger.episode import EpisodeTags

        if not name:
            return Quality.UNKNOWN

        result = None
        name = os.path.basename(name)
        ep = EpisodeTags(name)

        if anime:
            sd_options = tags.anime_sd.search(name)
            hd_options = tags.anime_hd.search(name)
            full_hd = tags.anime_fullhd.search(name)
            ep.rex['bluray'] = tags.anime_bluray

            # BluRay
            if ep.bluray and (full_hd or hd_options):
                result = Quality.FULLHDBLURAY if full_hd else Quality.HDBLURAY
            # HDTV
            elif full_hd or hd_options:
                result = Quality.FULLHDTV if full_hd else Quality.HDTV
            # SDDVD
            elif ep.dvd:
                result = Quality.SDDVD
            # SDTV
            elif sd_options:
                result = Quality.SDTV

            return Quality.UNKNOWN if result is None else result

        # Is it UHD?
        if ep.vres in [2160, 4320]:
            is_4320 = ep.vres == 4320
            if ep.scan == 'p':
                # BluRay
                if ep.bluray:
                    result = Quality.UHD_8K_BLURAY if is_4320 else Quality.UHD_4K_BLURAY
                # WEB-DL
                elif ep.web or any([ep.amazon, ep.itunes, ep.netflix]):
                    result = Quality.UHD_8K_WEBDL if is_4320 else Quality.UHD_4K_WEBDL
                # HDTV
                else:
                    result = Quality.UHD_8K_TV if is_4320 else Quality.UHD_4K_TV

        # Is it HD?
        elif ep.vres in [1080, 720]:
            is_1080 = ep.vres == 1080
            if ep.scan == 'p':
                # BluRay
                if ep.bluray or ep.hddvd:
                    result = Quality.FULLHDBLURAY if is_1080 else Quality.HDBLURAY
                # WEB-DL
                elif ep.web or any([ep.amazon, ep.itunes, ep.netflix]):
                    result = Quality.FULLHDWEBDL if is_1080 else Quality.HDWEBDL
                # HDTV and MPEG2 encoded
                elif ep.tv == 'hd' and ep.mpeg:
                    result = Quality.RAWHDTV
                # HDTV
                else:
                    result = Quality.FULLHDTV if is_1080 else Quality.HDTV
            elif ep.scan == 'i' and ep.tv == 'hd' and (ep.mpeg or
                                                       (ep.raw
                                                        and ep.avc_non_free)):
                result = Quality.RAWHDTV
        elif ep.hrws:
            result = Quality.HDTV

        # Is it SD?
        elif ep.dvd or ep.bluray:
            # SD DVD
            result = Quality.SDDVD
        elif ep.web or any([ep.amazon, ep.itunes, ep.netflix]):
            # This should be Quality.WEB in the future
            result = Quality.SDTV
        elif ep.tv or any([ep.res == '480p', ep.sat]):
            # SDTV/HDTV
            result = Quality.SDTV

        return Quality.UNKNOWN if result is None else result
Пример #2
0
    def quality_from_name(name, anime=False):
        """
        Return the quality from the episode filename with the regex.

        :param name: Episode filename to analyse
        :param anime: Boolean to indicate if the show we're resolving is anime
        :return: Quality
        """
        from medusa.tagger.episode import EpisodeTags

        if not name:
            return Quality.UNKNOWN

        result = None
        name = os.path.basename(name)
        ep = EpisodeTags(name)

        if anime:
            sd_options = tags.anime_sd.search(name)
            hd_options = tags.anime_hd.search(name)
            full_hd = tags.anime_fullhd.search(name)
            ep.rex['bluray'] = tags.anime_bluray

            # BluRay
            if ep.bluray and (full_hd or hd_options):
                result = Quality.FULLHDBLURAY if full_hd else Quality.HDBLURAY
            # HDTV
            elif full_hd or hd_options:
                result = Quality.FULLHDTV if full_hd else Quality.HDTV
            # SDDVD
            elif ep.dvd:
                result = Quality.SDDVD
            # SDTV
            elif sd_options:
                result = Quality.SDTV

            return Quality.UNKNOWN if result is None else result

        # Is it UHD?
        if ep.vres in [2160, 4320]:
            is_4320 = ep.vres == 4320
            if ep.scan == 'p':
                # BluRay
                if ep.bluray:
                    result = Quality.UHD_8K_BLURAY if is_4320 else Quality.UHD_4K_BLURAY
                # WEB-DL
                elif ep.web or any([ep.amazon, ep.itunes, ep.netflix]):
                    result = Quality.UHD_8K_WEBDL if is_4320 else Quality.UHD_4K_WEBDL
                # HDTV
                else:
                    result = Quality.UHD_8K_TV if is_4320 else Quality.UHD_4K_TV

        # Is it HD?
        elif ep.vres in [1080, 720]:
            is_1080 = ep.vres == 1080
            if ep.scan == 'p':
                # BluRay
                if ep.bluray or ep.hddvd:
                    result = Quality.FULLHDBLURAY if is_1080 else Quality.HDBLURAY
                # WEB-DL
                elif ep.web or any([ep.amazon, ep.itunes, ep.netflix]):
                    result = Quality.FULLHDWEBDL if is_1080 else Quality.HDWEBDL
                # HDTV and MPEG2 encoded
                elif ep.tv == 'hd' and ep.mpeg:
                    result = Quality.RAWHDTV
                # HDTV
                else:
                    result = Quality.FULLHDTV if is_1080 else Quality.HDTV
            elif ep.scan == 'i' and ep.tv == 'hd' and (ep.mpeg or (ep.raw and ep.avc_non_free)):
                result = Quality.RAWHDTV
        elif ep.hrws:
            result = Quality.HDTV

        # Is it SD?
        elif ep.dvd or ep.bluray:
            # SD DVD
            result = Quality.SDDVD
        elif ep.web or any([ep.amazon, ep.itunes, ep.netflix]):
            # This should be Quality.WEB in the future
            result = Quality.SDTV
        elif ep.tv or any([ep.res == '480p', ep.sat]):
            # SDTV/HDTV
            result = Quality.SDTV

        return Quality.UNKNOWN if result is None else result
Пример #3
0
    def quality_from_name(path, anime=False):
        """
        Return the quality from the episode filename or its parent folder.

        :param path: Episode filename or its parent folder
        :param anime: Boolean to indicate if the show we're resolving is anime
        :return: Quality
        """
        from medusa.tagger.episode import EpisodeTags

        if not path:
            return Quality.UNKNOWN

        result = None
        name = os.path.basename(path)
        ep = EpisodeTags(name)

        if anime:
            sd_options = tags.anime_sd.search(name)
            hd_options = tags.anime_hd.search(name)
            full_hd = tags.anime_fullhd.search(name)
            ep.rex['bluray'] = tags.anime_bluray

            # BluRay
            if ep.bluray and (full_hd or hd_options):
                result = Quality.FULLHDBLURAY if full_hd else Quality.HDBLURAY
            # HDTV
            elif full_hd or hd_options:
                result = Quality.FULLHDTV if full_hd else Quality.HDTV
            # SDDVD
            elif ep.dvd:
                result = Quality.SDDVD
            # SDTV
            elif sd_options:
                result = Quality.SDTV

            return Quality.UNKNOWN if result is None else result

        # Is it UHD?
        if ep.vres in [2160, 4320]:
            is_4320 = ep.vres == 4320
            if ep.scan == 'p':
                # BluRay
                if ep.bluray:
                    result = Quality.UHD_8K_BLURAY if is_4320 else Quality.UHD_4K_BLURAY
                # WEB-DL
                elif ep.web:
                    result = Quality.UHD_8K_WEBDL if is_4320 else Quality.UHD_4K_WEBDL
                # HDTV
                else:
                    result = Quality.UHD_8K_TV if is_4320 else Quality.UHD_4K_TV

        # Is it HD?
        elif ep.vres in [1080, 720]:
            is_1080 = ep.vres == 1080
            if ep.scan == 'p':
                # BluRay
                if ep.bluray or ep.hddvd:
                    result = Quality.FULLHDBLURAY if is_1080 else Quality.HDBLURAY
                # WEB-DL
                elif ep.web:
                    result = Quality.FULLHDWEBDL if is_1080 else Quality.HDWEBDL
                # HDTV and MPEG2 encoded
                elif ep.tv == 'hd' and ep.mpeg:
                    result = Quality.RAWHDTV
                # HDTV
                else:
                    result = Quality.FULLHDTV if is_1080 else Quality.HDTV
            elif ep.scan == 'i' and ep.tv == 'hd' and (ep.mpeg or
                                                       (ep.raw
                                                        and ep.avc_non_free)):
                result = Quality.RAWHDTV
        elif ep.hrws:
            result = Quality.HDTV

        # Is it SD?
        elif ep.dvd or ep.bluray:
            # SD DVD
            result = Quality.SDDVD
        elif ep.web and not ep.web.lower().endswith('hd'):
            # This should be Quality.WEB in the future
            result = Quality.SDTV
        elif ep.tv or any([ep.res == '480p', ep.sat]):
            # SDTV/HDTV
            result = Quality.SDTV

        if result is not None:
            return result

        # Try to get the quality from the parent folder
        parent_folder = os.path.basename(os.path.dirname(path))
        if parent_folder:
            return Quality.quality_from_name(parent_folder, anime)

        return Quality.UNKNOWN
Пример #4
0
    def scene_quality(name, anime=False):
        """
        Return The quality from the Scene episode File.

        :param name: Episode filename to analyse
        :param anime: Boolean to indicate if the show we're resolving is Anime
        :return: Quality
        """
        from medusa.tagger.episode import EpisodeTags
        if not name:
            return Quality.UNKNOWN
        else:
            name = os.path.basename(name)

        result = None
        ep = EpisodeTags(name)

        if anime:
            sd_options = tags.anime_sd.search(name)
            hd_options = tags.anime_hd.search(name)
            full_hd = tags.anime_fullhd.search(name)
            ep.rex[u'bluray'] = tags.anime_bluray

            # BluRay
            if ep.bluray and (full_hd or hd_options):
                result = Quality.FULLHDBLURAY if full_hd else Quality.HDBLURAY
            # HD TV
            elif not ep.bluray and (full_hd or hd_options):
                result = Quality.FULLHDTV if full_hd else Quality.HDTV
            # SD DVD
            elif ep.dvd:
                result = Quality.SDDVD
            # SD TV
            elif sd_options:
                result = Quality.SDTV

            return Quality.UNKNOWN if result is None else result

        # Is it UHD?
        if ep.vres in [2160, 4320] and ep.scan == u'p':
            # BluRay
            full_res = (ep.vres == 4320)
            if ep.avc and ep.bluray:
                result = Quality.UHD_4K_BLURAY if not full_res else Quality.UHD_8K_BLURAY
            # WEB-DL
            elif (ep.avc and ep.itunes) or ep.web:
                result = Quality.UHD_4K_WEBDL if not full_res else Quality.UHD_8K_WEBDL
            # HDTV
            elif ep.avc and ep.tv == u'hd':
                result = Quality.UHD_4K_TV if not full_res else Quality.UHD_8K_TV

        # Is it HD?
        elif ep.vres in [1080, 720]:
            if ep.scan == u'p':
                # BluRay
                full_res = (ep.vres == 1080)
                if ep.avc and (ep.bluray or ep.hddvd):
                    result = Quality.FULLHDBLURAY if full_res else Quality.HDBLURAY
                # WEB-DL
                elif (ep.avc and ep.itunes) or ep.web:
                    result = Quality.FULLHDWEBDL if full_res else Quality.HDWEBDL
                # HDTV
                elif ep.avc and ep.tv == u'hd':
                    result = Quality.FULLHDTV if full_res else Quality.HDTV
                elif all([ep.vres == 720, ep.tv == u'hd', ep.mpeg]):
                    result = Quality.RAWHDTV
            elif (ep.res == u'1080i') and ep.tv == u'hd':
                if ep.mpeg or (ep.raw and ep.avc_non_free):
                    result = Quality.RAWHDTV
        elif ep.hrws:
            result = Quality.HDTV

        # Is it SD?
        elif ep.xvid or ep.avc:
            # Is it aussie p2p?  If so its 720p
            if all([ep.tv == u'hd', ep.widescreen, ep.aussie]):
                result = Quality.HDTV
            # SD DVD
            elif ep.dvd or ep.bluray:
                result = Quality.SDDVD
            # SDTV
            elif ep.res == u'480p' or any([ep.tv, ep.sat, ep.web]):
                result = Quality.SDTV

        return Quality.UNKNOWN if result is None else result