当前位置: 首页>>代码示例>>Python>>正文


Python Quality.sceneQualityFromName方法代码示例

本文整理汇总了Python中sickrage.core.common.Quality.sceneQualityFromName方法的典型用法代码示例。如果您正苦于以下问题:Python Quality.sceneQualityFromName方法的具体用法?Python Quality.sceneQualityFromName怎么用?Python Quality.sceneQualityFromName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sickrage.core.common.Quality的用法示例。


在下文中一共展示了Quality.sceneQualityFromName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _replace_map

# 需要导入模块: from sickrage.core.common import Quality [as 别名]
# 或者: from sickrage.core.common.Quality import sceneQualityFromName [as 别名]
def _replace_map(episode):
    """
    Generates a replacement map for this episode which maps all possible custom naming patterns to the correct
    value for this episode.

    Returns: A dict with patterns as the keys and their replacement values as the values.
    """

    ep_name = _ep_name(episode)

    def dot(name):
        return sanitizeSceneName(name)

    def us(name):
        return re.sub('[ -]', '_', name)

    def release_name(name):
        if name:
            name = remove_non_release_groups(remove_extension(name))
        return name

    def release_group(show, name):
        if name:
            name = remove_non_release_groups(remove_extension(name))
        else:
            return ""

        try:
            np = NameParser(name, showObj=show, naming_pattern=True)
            parse_result = np.parse(name)
        except (InvalidNameException, InvalidShowException) as e:
            sickrage.LOGGER.debug("Unable to get parse release_group: {}".format(e))
            return ''

        if not parse_result.release_group:
            return ''
        return parse_result.release_group

    _, epQual = Quality.splitCompositeStatus(episode.status)  # @UnusedVariable

    if sickrage.NAMING_STRIP_YEAR:
        show_name = re.sub(r"\(\d+\)$", "", episode.show.name).rstrip()
    else:
        show_name = episode.show.name

    # try to get the release group
    rel_grp = {}
    rel_grp[b"SiCKRAGE"] = 'SiCKRAGE'
    if hasattr(episode, 'location'):  # from the location name
        rel_grp[b'location'] = release_group(episode.show, episode.location)
        if not rel_grp[b'location']:
            del rel_grp[b'location']
    if hasattr(episode, '_release_group'):  # from the release group field in db
        rel_grp[b'database'] = episode._release_group
        if not rel_grp[b'database']:
            del rel_grp[b'database']
    if hasattr(episode, 'release_name'):  # from the release name field in db
        rel_grp[b'release_name'] = release_group(episode.show, episode.release_name)
        if not rel_grp[b'release_name']:
            del rel_grp[b'release_name']

    # use release_group, release_name, location in that order
    if 'database' in rel_grp:
        relgrp = 'database'
    elif 'release_name' in rel_grp:
        relgrp = 'release_name'
    elif 'location' in rel_grp:
        relgrp = 'location'
    else:
        relgrp = 'SiCKRAGE'

    # try to get the release encoder to comply with scene naming standards
    encoder = Quality.sceneQualityFromName(episode.release_name.replace(rel_grp[relgrp], ""), epQual)
    if encoder:
        sickrage.LOGGER.debug("Found codec for '" + show_name + ": " + ep_name + "'.")

    return {
        '%SN': show_name,
        '%S.N': dot(show_name),
        '%S_N': us(show_name),
        '%EN': ep_name,
        '%E.N': dot(ep_name),
        '%E_N': us(ep_name),
        '%QN': Quality.qualityStrings[epQual],
        '%Q.N': dot(Quality.qualityStrings[epQual]),
        '%Q_N': us(Quality.qualityStrings[epQual]),
        '%SQN': Quality.sceneQualityStrings[epQual] + encoder,
        '%SQ.N': dot(Quality.sceneQualityStrings[epQual] + encoder),
        '%SQ_N': us(Quality.sceneQualityStrings[epQual] + encoder),
        '%S': str(episode.season),
        '%0S': '%02d' % episode.season,
        '%E': str(episode.episode),
        '%0E': '%02d' % episode.episode,
        '%XS': str(episode.scene_season),
        '%0XS': '%02d' % episode.scene_season,
        '%XE': str(episode.scene_episode),
        '%0XE': '%02d' % episode.scene_episode,
        '%AB': '%(#)03d' % {'#': episode.absolute_number},
        '%XAB': '%(#)03d' % {'#': episode.scene_absolute_number},
        '%RN': release_name(episode.release_name),
#.........这里部分代码省略.........
开发者ID:TATUMTOT,项目名称:SickRage,代码行数:103,代码来源:__init__.py


注:本文中的sickrage.core.common.Quality.sceneQualityFromName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。