flexget.plugins.filter.regexp module#

class flexget.plugins.filter.regexp.FilterRegexp[source]#

Bases: object

All possible forms.

Configuration options:

regexp:
  [operation]:           # operation to perform on matches
    - [regexp]           # simple regexp
    - [regexp]: <path>   # override path
    - [regexp]:
        [path]: <path>   # override path
        [not]: <regexp>  # not match
        [from]: <field>  # search from given entry field
    - [regexp]:
        [path]: <path>   # override path
        [not]:           # list of not match regexps
          - <regexp>
        [from]:          # search only from these fields
          - <field>
  [operation]:
    - <regexp>
  [rest]: <operation>    # non matching entries are
  [from]:                # search only from these fields for all regexps
    - <field>

Possible operations: accept, reject, accept_excluding, reject_excluding

filter(entries, operation, regexps)[source]#

Return set of entries that matched regexps.

Parameters:
  • entries – entries to filter

  • operation – one of accept reject accept_excluding and reject_excluding accept and reject will be called on the entry if any of the regexps match *_excluding operations will be called if any of the regexps don’t match

  • regexps – list of {compiled_regexp: options} dictionaries

matches(entry, regexp, find_from=None, not_regexps=None)[source]#

Check if :entry: has any string fields or strings in a list field that match :regexp:.

Parameters:
  • entry – Entry instance

  • regexp – Compiled regexp

  • find_from – None or a list of fields to search from

  • not_regexps – None or list of regexps that can NOT match

Returns:

Field matching

on_task_filter(task, config)[source]#
prepare_config(config)[source]#

Return the config in standard format.

All regexps are turned into dictionaries in the form of {compiled regexp: options}

Parameters:

config – Dict that can optionally contain the following keys path: will be attached to entries that match set: a dict of values to be attached to entries that match via set plugin from: a list of fields in entry for the regexps to match against not: a list of compiled regexps that if matching, will disqualify the main match

Returns:

New config dictionary

schema = {'$defs': {'regex_list': {'items': {'oneOf': [{'format': 'regex', 'type': 'string'}, {'additionalProperties': {'oneOf': [{'format': 'path', 'type': 'string'}, {'additionalProperties': False, 'properties': {'from': {'oneOf': [{'items': {'title': 'single value', 'type': 'string'}, 'minItems': 1, 'title': 'multiple values', 'type': 'array', 'uniqueItems': False}, {'title': 'single value', 'type': 'string'}]}, 'not': {'oneOf': [{'items': {'format': 'regex', 'title': 'single value', 'type': 'string'}, 'minItems': 1, 'title': 'multiple values', 'type': 'array', 'uniqueItems': False}, {'format': 'regex', 'title': 'single value', 'type': 'string'}]}, 'path': {'format': 'path', 'type': 'string'}, 'set': {'type': 'object'}}, 'type': 'object'}]}, 'type': 'object'}]}, 'type': 'array'}}, 'additionalProperties': False, 'properties': {'accept': {'$ref': '#/$defs/regex_list'}, 'accept_excluding': {'$ref': '#/$defs/regex_list'}, 'from': {'oneOf': [{'items': {'title': 'single value', 'type': 'string'}, 'minItems': 1, 'title': 'multiple values', 'type': 'array', 'uniqueItems': False}, {'title': 'single value', 'type': 'string'}]}, 'reject': {'$ref': '#/$defs/regex_list'}, 'reject_excluding': {'$ref': '#/$defs/regex_list'}, 'rest': {'enum': ['accept', 'reject'], 'type': 'string'}}, 'type': 'object'}#
flexget.plugins.filter.regexp.register_plugin()[source]#