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


Python Rebulk.string方法代码示例

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


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

示例1: video_codec

# 需要导入模块: from rebulk import Rebulk [as 别名]
# 或者: from rebulk.Rebulk import string [as 别名]
def video_codec():
    """
    Builder for rebulk object.
    :return: Created Rebulk object
    :rtype: Rebulk
    """
    rebulk = Rebulk().regex_defaults(flags=re.IGNORECASE, abbreviations=[dash]).string_defaults(ignore_case=True)
    rebulk.defaults(name="video_codec")

    rebulk.regex(r"Rv\d{2}", value="Real")
    rebulk.regex("Mpeg2", value="Mpeg2")
    rebulk.regex("DVDivX", "DivX", value="DivX")
    rebulk.regex("XviD", value="XviD")
    rebulk.regex("[hx]-?264(?:-?AVC(HD)?)?", "MPEG-?4(?:-?AVC(HD)?)", "AVCHD", value="h264")
    rebulk.regex("[hx]-?265(?:-?HEVC)?", "HEVC", value="h265")

    # http://blog.mediacoderhq.com/h264-profiles-and-levels/
    # http://fr.wikipedia.org/wiki/H.264
    rebulk.defaults(name="video_profile", validator=seps_surround)

    rebulk.regex('10.?bits?', 'Hi10P', value='10bit')
    rebulk.regex('8.?bits?', value='8bit')

    rebulk.string('BP', value='BP', tags='video_profile.rule')
    rebulk.string('XP', 'EP', value='XP', tags='video_profile.rule')
    rebulk.string('MP', value='MP', tags='video_profile.rule')
    rebulk.string('HP', 'HiP', value='HP', tags='video_profile.rule')
    rebulk.regex('Hi422P', value='Hi422P', tags='video_profile.rule')
    rebulk.regex('Hi444PP', value='Hi444PP', tags='video_profile.rule')

    rebulk.string('DXVA', value='DXVA', name='video_api')

    rebulk.rules(ValidateVideoCodec, VideoProfileRule)

    return rebulk
开发者ID:dudego,项目名称:guessit,代码行数:37,代码来源:video_codec.py

示例2: when

# 需要导入模块: from rebulk import Rebulk [as 别名]
# 或者: from rebulk.Rebulk import string [as 别名]
    def when(self, matches, context):
        expected_rebulk = Rebulk().defaults(name='release_group')

        for expected_group in context.get('expected_group'):
            if expected_group.startswith('re:'):
                expected_group = expected_group[3:]
                expected_group = expected_group.replace(' ', '-')
                expected_rebulk.regex(expected_group, abbreviations=[dash], flags=re.IGNORECASE)
            else:
                expected_rebulk.string(expected_group, ignore_case=True)

        matches = expected_rebulk.matches(matches.input_string, context)
        return matches
开发者ID:Daedaulus,项目名称:lit-match,代码行数:15,代码来源:release_group.py

示例3: screen_size

# 需要导入模块: from rebulk import Rebulk [as 别名]
# 或者: from rebulk.Rebulk import string [as 别名]
def screen_size():
    """
    Builder for rebulk object.
    :return: Created Rebulk object
    :rtype: Rebulk
    """
    def conflict_solver(match, other):
        """
        Conflict solver for most screen_size.
        """
        if other.name == 'screen_size':
            if 'resolution' in other.tags:
                # The chtouile to solve conflict in "720 x 432" string matching both 720p pattern
                int_value = _digits_re.findall(match.raw)[-1]
                if other.value.startswith(int_value):
                    return match
            return other
        return '__default__'

    rebulk = Rebulk().string_defaults(ignore_case=True).regex_defaults(flags=re.IGNORECASE)
    rebulk.defaults(name="screen_size", validator=seps_surround, conflict_solver=conflict_solver)

    rebulk.regex(r"(?:\d{3,}(?:x|\*))?360(?:i|p?x?)", value="360p")
    rebulk.regex(r"(?:\d{3,}(?:x|\*))?368(?:i|p?x?)", value="368p")
    rebulk.regex(r"(?:\d{3,}(?:x|\*))?480(?:i|p?x?)", value="480p")
    rebulk.regex(r"(?:\d{3,}(?:x|\*))?576(?:i|p?x?)", value="576p")
    rebulk.regex(r"(?:\d{3,}(?:x|\*))?720(?:i|p?(?:50|60)?x?)", value="720p")
    rebulk.regex(r"(?:\d{3,}(?:x|\*))?720(?:p(?:50|60)?x?)", value="720p")
    rebulk.regex(r"(?:\d{3,}(?:x|\*))?720p?hd", value="720p")
    rebulk.regex(r"(?:\d{3,}(?:x|\*))?900(?:i|p?x?)", value="900p")
    rebulk.regex(r"(?:\d{3,}(?:x|\*))?1080i", value="1080i")
    rebulk.regex(r"(?:\d{3,}(?:x|\*))?1080p?x?", value="1080p")
    rebulk.regex(r"(?:\d{3,}(?:x|\*))?1080(?:p(?:50|60)?x?)", value="1080p")
    rebulk.regex(r"(?:\d{3,}(?:x|\*))?1080p?hd", value="1080p")
    rebulk.regex(r"(?:\d{3,}(?:x|\*))?2160(?:i|p?x?)", value="4K")
    rebulk.string('4k', value='4K')

    _digits_re = re.compile(r'\d+')

    rebulk.defaults(name="screen_size", validator=seps_surround)
    rebulk.regex(r'\d{3,}-?(?:x|\*)-?\d{3,}',
                 formatter=lambda value: 'x'.join(_digits_re.findall(value)),
                 abbreviations=[dash],
                 tags=['resolution'],
                 conflict_solver=lambda match, other: '__default__' if other.name == 'screen_size' else other)

    rebulk.rules(ScreenSizeOnlyOne, RemoveScreenSizeConflicts)

    return rebulk
开发者ID:ArthurGarnier,项目名称:SickRage,代码行数:51,代码来源:screen_size.py

示例4: language

# 需要导入模块: from rebulk import Rebulk [as 别名]
# 或者: from rebulk.Rebulk import string [as 别名]
def language():
    """
    Builder for rebulk object.
    :return: Created Rebulk object
    :rtype: Rebulk
    """
    rebulk = Rebulk()

    rebulk.string(*subtitle_prefixes, name="subtitle_language.prefix", ignore_case=True, private=True,
                  validator=seps_surround)
    rebulk.string(*subtitle_suffixes, name="subtitle_language.suffix", ignore_case=True, private=True,
                  validator=seps_surround)
    rebulk.functional(find_languages, properties={'language': [None]})
    rebulk.rules(SubtitlePrefixLanguageRule, SubtitleSuffixLanguageRule, SubtitleExtensionRule)

    return rebulk
开发者ID:Eiber,项目名称:SickRage-Medusa,代码行数:18,代码来源:language.py

示例5: edition

# 需要导入模块: from rebulk import Rebulk [as 别名]
# 或者: from rebulk.Rebulk import string [as 别名]
def edition():
    """
    Builder for rebulk object.
    :return: Created Rebulk object
    :rtype: Rebulk
    """
    rebulk = Rebulk().regex_defaults(flags=re.IGNORECASE, abbreviations=[dash]).string_defaults(ignore_case=True)
    rebulk.defaults(name='edition', validator=seps_surround)

    rebulk.regex('collector', 'collector-edition', 'edition-collector', value='Collector Edition')
    rebulk.regex('special-edition', 'edition-special', value='Special Edition',
                 conflict_solver=lambda match, other: other
                 if other.name == 'episode_details' and other.value == 'Special'
                 else '__default__')
    rebulk.string('se', value='Special Edition', tags='has-neighbor')
    rebulk.regex('criterion-edition', 'edition-criterion', value='Criterion Edition')
    rebulk.regex('deluxe', 'deluxe-edition', 'edition-deluxe', value='Deluxe Edition')
    rebulk.regex('limited', 'limited-edition', value='Limited Edition', tags=['has-neighbor', 'release-group-prefix'])
    rebulk.regex(r'theatrical-cut', r'theatrical-edition', r'theatrical', value='Theatrical Edition')
    rebulk.regex(r"director'?s?-cut", r"director'?s?-cut-edition", r"edition-director'?s?-cut", 'DC',
                 value="Director's Cut")
    rebulk.regex('extended', 'extended-?cut', 'extended-?version',
                 value='Extended', tags=['has-neighbor', 'release-group-prefix'])
    rebulk.regex('alternat(e|ive)(?:-?Cut)?', value='Alternative Cut', tags=['has-neighbor', 'release-group-prefix'])
    for value in ('Remastered', 'Uncensored', 'Uncut', 'Unrated'):
        rebulk.string(value, value=value, tags=['has-neighbor', 'release-group-prefix'])
    rebulk.string('Festival', value='Festival', tags=['has-neighbor-before', 'has-neighbor-after'])

    return rebulk
开发者ID:ArthurGarnier,项目名称:SickRage,代码行数:31,代码来源:edition.py

示例6: screen_size

# 需要导入模块: from rebulk import Rebulk [as 别名]
# 或者: from rebulk.Rebulk import string [as 别名]
def screen_size(config):
    """
    Builder for rebulk object.

    :param config: rule configuration
    :type config: dict
    :return: Created Rebulk object
    :rtype: Rebulk
    """
    interlaced = frozenset({res for res in config['interlaced']})
    progressive = frozenset({res for res in config['progressive']})
    frame_rates = [re.escape(rate) for rate in config['frame_rates']]
    min_ar = config['min_ar']
    max_ar = config['max_ar']

    rebulk = Rebulk()
    rebulk = rebulk.string_defaults(ignore_case=True).regex_defaults(flags=re.IGNORECASE)

    rebulk.defaults(name='screen_size', validator=seps_surround, abbreviations=[dash],
                    disabled=lambda context: is_disabled(context, 'screen_size'))

    frame_rate_pattern = build_or_pattern(frame_rates, name='frame_rate')
    interlaced_pattern = build_or_pattern(interlaced, name='height')
    progressive_pattern = build_or_pattern(progressive, name='height')

    res_pattern = r'(?:(?P<width>\d{3,4})(?:x|\*))?'
    rebulk.regex(res_pattern + interlaced_pattern + r'(?P<scan_type>i)' + frame_rate_pattern + '?')
    rebulk.regex(res_pattern + progressive_pattern + r'(?P<scan_type>p)' + frame_rate_pattern + '?')
    rebulk.regex(res_pattern + progressive_pattern + r'(?P<scan_type>p)?(?:hd)')
    rebulk.regex(res_pattern + progressive_pattern + r'(?P<scan_type>p)?x?')
    rebulk.string('4k', value='2160p')
    rebulk.regex(r'(?P<width>\d{3,4})-?(?:x|\*)-?(?P<height>\d{3,4})',
                 conflict_solver=lambda match, other: '__default__' if other.name == 'screen_size' else other)

    rebulk.regex(frame_rate_pattern + '(p|fps)', name='frame_rate',
                 formatter=FrameRate.fromstring, disabled=lambda context: is_disabled(context, 'frame_rate'))

    rebulk.rules(PostProcessScreenSize(progressive, min_ar, max_ar), ScreenSizeOnlyOne, ResolveScreenSizeConflicts)

    return rebulk
开发者ID:SerhatG,项目名称:nzbToMedia,代码行数:42,代码来源:screen_size.py

示例7: streaming_service

# 需要导入模块: from rebulk import Rebulk [as 别名]
# 或者: from rebulk.Rebulk import string [as 别名]
def streaming_service(config):  # pylint: disable=too-many-statements,unused-argument
    """Streaming service property.

    :param config: rule configuration
    :type config: dict
    :return:
    :rtype: Rebulk
    """
    rebulk = Rebulk(disabled=lambda context: is_disabled(context, 'streaming_service'))
    rebulk = rebulk.string_defaults(ignore_case=True).regex_defaults(flags=re.IGNORECASE, abbreviations=[dash])
    rebulk.defaults(name='streaming_service', tags=['source-prefix'])

    for value, items in config.items():
        patterns = items if isinstance(items, list) else [items]
        for pattern in patterns:
            if pattern.startswith('re:'):
                rebulk.regex(pattern, value=value)
            else:
                rebulk.string(pattern, value=value)

    rebulk.rules(ValidateStreamingService)

    return rebulk
开发者ID:pymedusa,项目名称:SickRage,代码行数:25,代码来源:streaming_service.py

示例8: container

# 需要导入模块: from rebulk import Rebulk [as 别名]
# 或者: from rebulk.Rebulk import string [as 别名]
def container(config):
    """
    Builder for rebulk object.

    :param config: rule configuration
    :type config: dict
    :return: Created Rebulk object
    :rtype: Rebulk
    """
    rebulk = Rebulk(disabled=lambda context: is_disabled(context, 'container'))
    rebulk = rebulk.regex_defaults(flags=re.IGNORECASE).string_defaults(ignore_case=True)
    rebulk.defaults(name='container',
                    formatter=lambda value: value.strip(seps),
                    tags=['extension'],
                    conflict_solver=lambda match, other: other
                    if other.name in ('source', 'video_codec') or
                    other.name == 'container' and 'extension' not in other.tags
                    else '__default__')

    subtitles = config['subtitles']
    info = config['info']
    videos = config['videos']
    torrent = config['torrent']
    nzb = config['nzb']

    rebulk.regex(r'\.'+build_or_pattern(subtitles)+'$', exts=subtitles, tags=['extension', 'subtitle'])
    rebulk.regex(r'\.'+build_or_pattern(info)+'$', exts=info, tags=['extension', 'info'])
    rebulk.regex(r'\.'+build_or_pattern(videos)+'$', exts=videos, tags=['extension', 'video'])
    rebulk.regex(r'\.'+build_or_pattern(torrent)+'$', exts=torrent, tags=['extension', 'torrent'])
    rebulk.regex(r'\.'+build_or_pattern(nzb)+'$', exts=nzb, tags=['extension', 'nzb'])

    rebulk.defaults(name='container',
                    validator=seps_surround,
                    formatter=lambda s: s.lower(),
                    conflict_solver=lambda match, other: match
                    if other.name in ('source',
                                      'video_codec') or other.name == 'container' and 'extension' in other.tags
                    else '__default__')

    rebulk.string(*[sub for sub in subtitles if sub not in ('sub', 'ass')], tags=['subtitle'])
    rebulk.string(*videos, tags=['video'])
    rebulk.string(*torrent, tags=['torrent'])
    rebulk.string(*nzb, tags=['nzb'])

    return rebulk
开发者ID:SerhatG,项目名称:nzbToMedia,代码行数:47,代码来源:container.py

示例9: container

# 需要导入模块: from rebulk import Rebulk [as 别名]
# 或者: from rebulk.Rebulk import string [as 别名]
def container():
    """
    Builder for rebulk object.
    :return: Created Rebulk object
    :rtype: Rebulk
    """
    rebulk = Rebulk().regex_defaults(flags=re.IGNORECASE).string_defaults(ignore_case=True)
    rebulk.defaults(name='container',
                    formatter=lambda value: value.strip(seps),
                    tags=['extension'],
                    conflict_solver=lambda match, other: other
                    if other.name in ['format', 'video_codec'] or
                    other.name == 'container' and 'extension' not in other.tags
                    else '__default__')

    subtitles = ['srt', 'idx', 'sub', 'ssa', 'ass']
    info = ['nfo']
    videos = ['3g2', '3gp', '3gp2', 'asf', 'avi', 'divx', 'flv', 'm4v', 'mk2',
              'mka', 'mkv', 'mov', 'mp4', 'mp4a', 'mpeg', 'mpg', 'ogg', 'ogm',
              'ogv', 'qt', 'ra', 'ram', 'rm', 'ts', 'wav', 'webm', 'wma', 'wmv',
              'iso', 'vob']
    torrent = ['torrent']
    nzb = ['nzb']

    rebulk.regex(r'\.'+build_or_pattern(subtitles)+'$', exts=subtitles, tags=['extension', 'subtitle'])
    rebulk.regex(r'\.'+build_or_pattern(info)+'$', exts=info, tags=['extension', 'info'])
    rebulk.regex(r'\.'+build_or_pattern(videos)+'$', exts=videos, tags=['extension', 'video'])
    rebulk.regex(r'\.'+build_or_pattern(torrent)+'$', exts=torrent, tags=['extension', 'torrent'])
    rebulk.regex(r'\.'+build_or_pattern(nzb)+'$', exts=nzb, tags=['extension', 'nzb'])

    rebulk.defaults(name='container',
                    validator=seps_surround,
                    formatter=lambda s: s.lower(),
                    conflict_solver=lambda match, other: match
                    if other.name in ['format',
                                      'video_codec'] or other.name == 'container' and 'extension' in other.tags
                    else '__default__')

    rebulk.string(*[sub for sub in subtitles if sub not in ['sub']], tags=['subtitle'])
    rebulk.string(*videos, tags=['video'])
    rebulk.string(*torrent, tags=['torrent'])
    rebulk.string(*nzb, tags=['nzb'])

    return rebulk
开发者ID:ArthurGarnier,项目名称:SickRage,代码行数:46,代码来源:container.py

示例10: language

# 需要导入模块: from rebulk import Rebulk [as 别名]
# 或者: from rebulk.Rebulk import string [as 别名]
def language(config, common_words):
    """
    Builder for rebulk object.

    :param config: rule configuration
    :type config: dict
    :param common_words: common words
    :type common_words: set
    :return: Created Rebulk object
    :rtype: Rebulk
    """
    subtitle_both = config['subtitle_affixes']
    subtitle_prefixes = sorted(subtitle_both + config['subtitle_prefixes'], key=length_comparator)
    subtitle_suffixes = sorted(subtitle_both + config['subtitle_suffixes'], key=length_comparator)
    lang_both = config['language_affixes']
    lang_prefixes = sorted(lang_both + config['language_prefixes'], key=length_comparator)
    lang_suffixes = sorted(lang_both + config['language_suffixes'], key=length_comparator)
    weak_affixes = frozenset(config['weak_affixes'])

    rebulk = Rebulk(disabled=lambda context: (is_disabled(context, 'language') and
                                              is_disabled(context, 'subtitle_language')))

    rebulk.string(*subtitle_prefixes, name="subtitle_language.prefix", ignore_case=True, private=True,
                  validator=seps_surround, tags=['release-group-prefix'],
                  disabled=lambda context: is_disabled(context, 'subtitle_language'))
    rebulk.string(*subtitle_suffixes, name="subtitle_language.suffix", ignore_case=True, private=True,
                  validator=seps_surround,
                  disabled=lambda context: is_disabled(context, 'subtitle_language'))
    rebulk.string(*lang_suffixes, name="language.suffix", ignore_case=True, private=True,
                  validator=seps_surround, tags=['source-suffix'],
                  disabled=lambda context: is_disabled(context, 'language'))

    def find_languages(string, context=None):
        """Find languages in the string

        :return: list of tuple (property, Language, lang_word, word)
        """
        return LanguageFinder(context, subtitle_prefixes, subtitle_suffixes,
                              lang_prefixes, lang_suffixes, weak_affixes).find(string)

    rebulk.functional(find_languages,
                      properties={'language': [None]},
                      disabled=lambda context: not context.get('allowed_languages'))
    rebulk.rules(SubtitleExtensionRule,
                 SubtitlePrefixLanguageRule,
                 SubtitleSuffixLanguageRule,
                 RemoveLanguage,
                 RemoveInvalidLanguages(common_words))

    babelfish.language_converters['guessit'] = GuessitConverter(config['synonyms'])

    return rebulk
开发者ID:pymedusa,项目名称:SickRage,代码行数:54,代码来源:language.py

示例11: edition

# 需要导入模块: from rebulk import Rebulk [as 别名]
# 或者: from rebulk.Rebulk import string [as 别名]
def edition(config):  # pylint:disable=unused-argument
    """
    Builder for rebulk object.

    :param config: rule configuration
    :type config: dict
    :return: Created Rebulk object
    :rtype: Rebulk
    """
    rebulk = Rebulk(disabled=lambda context: is_disabled(context, 'edition'))
    rebulk = rebulk.regex_defaults(flags=re.IGNORECASE, abbreviations=[dash]).string_defaults(ignore_case=True)
    rebulk.defaults(name='edition', validator=seps_surround)

    rebulk.regex('collector', "collector'?s?-edition", 'edition-collector', value='Collector')
    rebulk.regex('special-edition', 'edition-special', value='Special',
                 conflict_solver=lambda match, other: other
                 if other.name == 'episode_details' and other.value == 'Special'
                 else '__default__')
    rebulk.string('se', value='Special', tags='has-neighbor')
    rebulk.string('ddc', value="Director's Definitive Cut")
    rebulk.regex('criterion-edition', 'edition-criterion', 'CC', value='Criterion')
    rebulk.regex('deluxe', 'deluxe-edition', 'edition-deluxe', value='Deluxe')
    rebulk.regex('limited', 'limited-edition', value='Limited', tags=['has-neighbor', 'release-group-prefix'])
    rebulk.regex(r'theatrical-cut', r'theatrical-edition', r'theatrical', value='Theatrical')
    rebulk.regex(r"director'?s?-cut", r"director'?s?-cut-edition", r"edition-director'?s?-cut", 'DC',
                 value="Director's Cut")
    rebulk.regex('extended', 'extended-?cut', 'extended-?version',
                 value='Extended', tags=['has-neighbor', 'release-group-prefix'])
    rebulk.regex('alternat(e|ive)(?:-?Cut)?', value='Alternative Cut', tags=['has-neighbor', 'release-group-prefix'])
    for value in ('Remastered', 'Uncensored', 'Uncut', 'Unrated'):
        rebulk.string(value, value=value, tags=['has-neighbor', 'release-group-prefix'])
    rebulk.string('Festival', value='Festival', tags=['has-neighbor-before', 'has-neighbor-after'])
    rebulk.regex('imax', 'imax-edition', value='IMAX')
    rebulk.regex('fan-edit(?:ion)?', 'fan-collection', value='Fan')
    rebulk.regex('ultimate-edition', value='Ultimate')
    rebulk.regex("ultimate-collector'?s?-edition", value=['Ultimate', 'Collector'])
    rebulk.regex('ultimate-fan-edit(?:ion)?', 'ultimate-fan-collection', value=['Ultimate', 'Fan'])

    return rebulk
开发者ID:SerhatG,项目名称:nzbToMedia,代码行数:41,代码来源:edition.py

示例12: container

# 需要导入模块: from rebulk import Rebulk [as 别名]
# 或者: from rebulk.Rebulk import string [as 别名]
def container():
    """
    Builder for rebulk object.
    :return: Created Rebulk object
    :rtype: Rebulk
    """
    rebulk = Rebulk().regex_defaults(flags=re.IGNORECASE).string_defaults(ignore_case=True)
    rebulk.defaults(
        name="container",
        formatter=lambda value: value[1:],
        tags=["extension"],
        conflict_solver=lambda match, other: other
        if other.name in ["format", "video_codec"] or other.name == "container" and "extension" not in other.tags
        else "__default__",
    )

    subtitles = ["srt", "idx", "sub", "ssa", "ass"]
    info = ["nfo"]
    videos = [
        "3g2",
        "3gp",
        "3gp2",
        "asf",
        "avi",
        "divx",
        "flv",
        "m4v",
        "mk2",
        "mka",
        "mkv",
        "mov",
        "mp4",
        "mp4a",
        "mpeg",
        "mpg",
        "ogg",
        "ogm",
        "ogv",
        "qt",
        "ra",
        "ram",
        "rm",
        "ts",
        "wav",
        "webm",
        "wma",
        "wmv",
        "iso",
        "vob",
    ]
    torrent = ["torrent"]

    if REGEX_AVAILABLE:
        rebulk.regex(r"\.\L<exts>$", exts=subtitles, tags=["extension", "subtitle"])
        rebulk.regex(r"\.\L<exts>$", exts=info, tags=["extension", "info"])
        rebulk.regex(r"\.\L<exts>$", exts=videos, tags=["extension", "video"])
        rebulk.regex(r"\.\L<exts>$", exts=torrent, tags=["extension", "torrent"])
    else:
        rebulk.regex(r"\." + build_or_pattern(subtitles) + "$", exts=subtitles, tags=["extension", "subtitle"])
        rebulk.regex(r"\." + build_or_pattern(info) + "$", exts=info, tags=["extension", "info"])
        rebulk.regex(r"\." + build_or_pattern(videos) + "$", exts=videos, tags=["extension", "video"])
        rebulk.regex(r"\." + build_or_pattern(torrent) + "$", exts=torrent, tags=["extension", "torrent"])

    rebulk.defaults(
        name="container",
        validator=seps_surround,
        formatter=lambda s: s.upper(),
        conflict_solver=lambda match, other: match
        if other.name in ["format", "video_codec"] or other.name == "container" and "extension" in other.tags
        else "__default__",
    )

    rebulk.string(*[sub for sub in subtitles if sub not in ["sub"]], tags=["subtitle"])
    rebulk.string(*videos, tags=["video"])
    rebulk.string(*torrent, tags=["torrent"])

    return rebulk
开发者ID:Hydrog3n,项目名称:SickRage,代码行数:79,代码来源:container.py

示例13: episodes

# 需要导入模块: from rebulk import Rebulk [as 别名]
# 或者: from rebulk.Rebulk import string [as 别名]
def episodes():
    """
    Builder for rebulk object.
    :return: Created Rebulk object
    :rtype: Rebulk
    """
    # pylint: disable=too-many-branches,too-many-statements
    rebulk = Rebulk()
    rebulk.regex_defaults(flags=re.IGNORECASE).string_defaults(ignore_case=True)
    rebulk.defaults(private_names=['episodeSeparator', 'seasonSeparator'])

    def season_episode_conflict_solver(match, other):
        """
        Conflict solver for episode/season patterns

        :param match:
        :param other:
        :return:
        """
        if match.name in ['season', 'episode'] and other.name in ['screen_size', 'video_codec',
                                                                  'audio_codec', 'audio_channels',
                                                                  'container', 'date']:
            return match
        elif match.name in ['season', 'episode'] and other.name in ['season', 'episode'] \
                and match.initiator != other.initiator:
            if 'x' in match.initiator.raw.lower():
                return match
            if 'x' in other.initiator.raw.lower():
                return other
        return '__default__'

    season_episode_seps = []
    season_episode_seps.extend(seps)
    season_episode_seps.extend(['x', 'X', 'e', 'E'])

    def season_episode_validator(match):
        """
        Validator for season/episode matches
        """
        if match.name in ['season', 'episode'] and match.initiator.start:
            return match.initiator.input_string[match.initiator.start] in season_episode_seps \
                   or match.initiator.input_string[match.initiator.start - 1] in season_episode_seps
        return True

    # 01x02, 01x02x03x04
    rebulk.chain(formatter={'season': int, 'episode': int},
                 tags=['SxxExx'],
                 abbreviations=[alt_dash],
                 children=True,
                 private_parent=True,
                 conflict_solver=season_episode_conflict_solver) \
        .defaults(validator=season_episode_validator) \
        .regex(r'S(?P<season>\d+)@?(?:xE|Ex|E|x)@?(?P<episode>\d+)') \
        .regex(r'(?:(?P<episodeSeparator>xE|Ex|E|x|-|\+|&)(?P<episode>\d+))').repeater('*') \
        .chain() \
        .regex(r'(?P<season>\d+)@[email protected]?(?P<episode>\d+)') \
        .regex(r'(?:(?P<episodeSeparator>x|-|\+|&)(?P<episode>\d+))').repeater('*') \
        .chain() \
        .regex(r'S(?P<season>\d+)') \
        .regex(r'(?:(?P<seasonSeparator>S|-|\+|&)(?P<season>\d+))').repeater('*')

    # episode_details property
    for episode_detail in ('Special', 'Bonus', 'Omake', 'Ova', 'Oav', 'Pilot', 'Unaired'):
        rebulk.string(episode_detail, value=episode_detail, name='episode_details')
    rebulk.regex(r'Extras?', name='episode_details', value='Extras')

    rebulk.defaults(private_names=['episodeSeparator', 'seasonSeparator'],
                    validate_all=True, validator={'__parent__': seps_surround}, children=True, private_parent=True)

    season_words = ['season', 'saison', 'serie', 'seasons', 'saisons', 'series']
    episode_words = ['episode', 'episodes', 'ep']
    of_words = ['of', 'sur']
    all_words = ['All']

    rebulk.chain(abbreviations=[alt_dash], formatter={'season': parse_numeral, 'count': parse_numeral}) \
        .defaults(validator=None) \
        .regex(build_or_pattern(season_words) + '@?(?P<season>' + numeral + ')') \
        .regex(r'' + build_or_pattern(of_words) + '@?(?P<count>' + numeral + ')').repeater('?') \
        .regex(r'@?(?P<seasonSeparator>-)@?(?P<season>\d+)').repeater('*') \
        .regex(r'@?(?P<seasonSeparator>\+|&)@?(?P<season>\d+)').repeater('*')


    rebulk.regex(build_or_pattern(episode_words) + r'-?(?P<episode>\d+)' +
                 r'(?:v(?P<version>\d+))?' +
                 r'(?:-?' + build_or_pattern(of_words) + r'?-?(?P<count>\d+))?',  # Episode 4
                 abbreviations=[dash], formatter=int,
                 disabled=lambda context: context.get('type') == 'episode')

    rebulk.regex(build_or_pattern(episode_words) + r'-?(?P<episode>' + numeral + ')' +
                 r'(?:v(?P<version>\d+))?' +
                 r'(?:-?' + build_or_pattern(of_words) + r'?-?(?P<count>\d+))?',  # Episode 4
                 abbreviations=[dash], formatter={'episode': parse_numeral, 'version': int, 'count': int},
                 disabled=lambda context: context.get('type') != 'episode')

    rebulk.regex(r'S?(?P<season>\d+)-?(?:xE|Ex|E|x)-?(?P<other>' + build_or_pattern(all_words) + ')',
                 tags=['SxxExx'],
                 abbreviations=[dash],
                 validator=None,
                 formatter={'season': int, 'other': lambda match: 'Complete'})

#.........这里部分代码省略.........
开发者ID:uguraba,项目名称:guessit,代码行数:103,代码来源:episodes.py

示例14: audio_codec

# 需要导入模块: from rebulk import Rebulk [as 别名]
# 或者: from rebulk.Rebulk import string [as 别名]
def audio_codec():
    """
    Builder for rebulk object.
    :return: Created Rebulk object
    :rtype: Rebulk
    """
    rebulk = Rebulk().regex_defaults(flags=re.IGNORECASE, abbreviations=[dash]).string_defaults(ignore_case=True)
    rebulk.defaults(name="audio_codec")

    rebulk.regex("MP3", "LAME", r"LAME(?:\d)+-?(?:\d)+", value="MP3")
    rebulk.regex("DolbyDigital", "Dolby-Digital", "DD", value="DolbyDigital")
    rebulk.regex("DolbyAtmos", "Dolby-Atmos", "Atmos", value="DolbyAtmos")
    rebulk.regex("AAC", value="AAC")
    rebulk.regex("AC3D?", value="AC3")
    rebulk.regex("Flac", value="FLAC")
    rebulk.regex("DTS", value="DTS")
    rebulk.regex("True-?HD", value="TrueHD")

    rebulk.defaults(name="audio_profile")
    rebulk.string("HD", value="HD", tags="DTS")
    rebulk.regex("HD-?MA", value="HDMA", tags="DTS")
    rebulk.string("HE", value="HE", tags="AAC")
    rebulk.string("LC", value="LC", tags="AAC")
    rebulk.string("HQ", value="HQ", tags="AC3")

    rebulk.defaults(name="audio_channels")
    rebulk.regex(r"(7[\W_]1)(?:[^\d]|$)", value="7.1", children=True)
    rebulk.regex(r"(5[\W_]1)(?:[^\d]|$)", value="5.1", children=True)
    rebulk.regex(r"(2[\W_]0)(?:[^\d]|$)", value="2.0", children=True)
    rebulk.string("7ch", "8ch", value="7.1")
    rebulk.string("5ch", "6ch", value="5.1")
    rebulk.string("2ch", "stereo", value="2.0")
    rebulk.string("1ch", "mono", value="1.0")

    rebulk.rules(DtsRule, AacRule, Ac3Rule, AudioValidatorRule, HqConflictRule)

    return rebulk
开发者ID:NigelRook,项目名称:superliminal,代码行数:39,代码来源:audio_codec.py

示例15: video_codec

# 需要导入模块: from rebulk import Rebulk [as 别名]
# 或者: from rebulk.Rebulk import string [as 别名]
def video_codec(config):  # pylint:disable=unused-argument
    """
    Builder for rebulk object.

    :param config: rule configuration
    :type config: dict
    :return: Created Rebulk object
    :rtype: Rebulk
    """
    rebulk = Rebulk()
    rebulk = rebulk.regex_defaults(flags=re.IGNORECASE, abbreviations=[dash]).string_defaults(ignore_case=True)
    rebulk.defaults(name="video_codec",
                    tags=['source-suffix', 'streaming_service.suffix'],
                    disabled=lambda context: is_disabled(context, 'video_codec'))

    rebulk.regex(r'Rv\d{2}', value='RealVideo')
    rebulk.regex('Mpe?g-?2', '[hx]-?262', value='MPEG-2')
    rebulk.string("DVDivX", "DivX", value="DivX")
    rebulk.string('XviD', value='Xvid')
    rebulk.regex('VC-?1', value='VC-1')
    rebulk.string('VP7', value='VP7')
    rebulk.string('VP8', 'VP80', value='VP8')
    rebulk.string('VP9', value='VP9')
    rebulk.regex('[hx]-?263', value='H.263')
    rebulk.regex('[hx]-?264', '(MPEG-?4)?AVC(?:HD)?', value='H.264')
    rebulk.regex('[hx]-?265', 'HEVC', value='H.265')
    rebulk.regex('(?P<video_codec>hevc)(?P<color_depth>10)', value={'video_codec': 'H.265', 'color_depth': '10-bit'},
                 tags=['video-codec-suffix'], children=True)

    # http://blog.mediacoderhq.com/h264-profiles-and-levels/
    # https://en.wikipedia.org/wiki/H.264/MPEG-4_AVC
    rebulk.defaults(name="video_profile",
                    validator=seps_surround,
                    disabled=lambda context: is_disabled(context, 'video_profile'))

    rebulk.string('BP', value='Baseline', tags='video_profile.rule')
    rebulk.string('XP', 'EP', value='Extended', tags='video_profile.rule')
    rebulk.string('MP', value='Main', tags='video_profile.rule')
    rebulk.string('HP', 'HiP', value='High', tags='video_profile.rule')

    # https://en.wikipedia.org/wiki/Scalable_Video_Coding
    rebulk.string('SC', 'SVC', value='Scalable Video Coding', tags='video_profile.rule')
    # https://en.wikipedia.org/wiki/AVCHD
    rebulk.regex('AVC(?:HD)?', value='Advanced Video Codec High Definition', tags='video_profile.rule')
    # https://en.wikipedia.org/wiki/H.265/HEVC
    rebulk.string('HEVC', value='High Efficiency Video Coding', tags='video_profile.rule')

    rebulk.regex('Hi422P', value='High 4:2:2')
    rebulk.regex('Hi444PP', value='High 4:4:4 Predictive')
    rebulk.regex('Hi10P?', value='High 10')  # no profile validation is required

    rebulk.string('DXVA', value='DXVA', name='video_api',
                  disabled=lambda context: is_disabled(context, 'video_api'))

    rebulk.defaults(name='color_depth',
                    validator=seps_surround,
                    disabled=lambda context: is_disabled(context, 'color_depth'))
    rebulk.regex('12.?bits?', value='12-bit')
    rebulk.regex('10.?bits?', 'YUV420P10', 'Hi10P?', value='10-bit')
    rebulk.regex('8.?bits?', value='8-bit')

    rebulk.rules(ValidateVideoCodec, VideoProfileRule)

    return rebulk
开发者ID:SerhatG,项目名称:nzbToMedia,代码行数:66,代码来源:video_codec.py


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