flexget.entry module#

exception flexget.entry.EntryUnicodeError(key, value)[source]#

Bases: Exception

Thrown when trying to set non-unicode compatible field value to entry.

Parameters:

key (str)

Return type:

None

class flexget.entry.Entry(*args, **kwargs)[source]#

Bases: LazyDict, Serializer

Represents one item in task. Must have url and title fields.

Stores automatically original_url key, which is necessary because plugins (eg. urlrewriters) may change url into something else and otherwise that information would be lost.

Entry will also transparently convert all ascii strings into unicode and raises EntryUnicodeError if conversion fails on any value being set. Such failures are caught by Task and trigger abort().

classmethod deserialize(data, version)[source]#

Return an instance of the original class, recreated from the serialized form.

Return type:

Entry

classmethod serialize(entry)[source]#

Return a plain python datatype which is json serializable.

Parameters:

entry (Entry)

Return type:

dict

accept(reason=None, **kwargs)[source]#
Parameters:

reason (str | None)

Return type:

None

add_hook(action, func, **kwargs)[source]#

Add a hook for action to this entry.

Parameters:
  • action (string) – One of: ‘accept’, ‘reject’, ‘fail’, ‘complete’

  • func (Callable) – Function to execute when event occurs

  • kwargs – Keyword arguments that should be passed to func

Raises:

ValueError when given an invalid action

Return type:

None

add_lazy_fields(lazy_func, fields, args=None, kwargs=None)[source]#

Add lazy fields to an entry.

Parameters:
  • lazy_func (Callable[[Entry], None] | str) – should be a function previously registered with the register_lazy_func decorator, or the name it was registered under.

  • fields (Iterable[str]) – list of fields this function will fill

  • args (Sequence | None) – Arguments that will be passed to the lazy lookup function when called.

  • kwargs (Mapping | None) – Keyword arguments which will be passed to the lazy lookup function when called.

complete(**kwargs)[source]#
fail(reason=None, **kwargs)[source]#
Parameters:

reason (str | None)

isvalid()[source]#

Return True if entry is valid. Return False if this cannot be used.

Return type:

bool

on_accept(func, **kwargs)[source]#

Register a function to be called when this entry is accepted.

Parameters:
  • func (Callable) – The function to call

  • kwargs – Keyword arguments that should be passed to the registered function

Return type:

None

on_complete(func, **kwargs)[source]#

Register a function to be called when a Task has finished processing this entry.

Parameters:
  • func (Callable) – The function to call

  • kwargs – Keyword arguments that should be passed to the registered function

Return type:

None

on_fail(func, **kwargs)[source]#

Register a function to be called when this entry is failed.

Parameters:
  • func (Callable) – The function to call

  • kwargs – Keyword arguments that should be passed to the registered function

Return type:

None

on_reject(func, **kwargs)[source]#

Register a function to be called when this entry is rejected.

Parameters:
  • func (Callable) – The function to call

  • kwargs – Keyword arguments that should be passed to the registered function

Return type:

None

register_lazy_func(func, keys)[source]#

Do not use this anymore as it is DEPRECATED.

Use add_lazy_fields instead.

reject(reason=None, **kwargs)[source]#
Parameters:

reason (str | None)

Return type:

None

render(template, native=False)[source]#

Render a template string based on fields in the entry.

Parameters:
  • template (str | FlexGetTemplate) – A template string or FlexGetTemplate that uses jinja2 or python string replacement format.

  • native (bool) – If True, and the rendering result can be all native python types, not just strings.

Returns:

The result of the rendering.

Raises:

RenderError – If there is a problem.

Return type:

str

run_hooks(action, **kwargs)[source]#

Run hooks that have been registered for given action.

Parameters:
  • action (str) – Name of action to run hooks for

  • kwargs – Keyword arguments that should be passed to the registered functions

Return type:

None

safe_str()[source]#
Return type:

str

trace(message, operation=None, plugin=None)[source]#

Add trace message to the entry which should contain useful information about why plugin did not operate on entry.

Accept and Reject messages are added to trace automatically.

Parameters:
  • message (string) – Message to add into entry trace.

  • operation (string) – None, reject, accept or fail

  • plugin (str | None) – Uses task.current_plugin by default, pass value to override

Return type:

None

update_using_map(field_map, source_item, ignore_none=False)[source]#

Populate entry fields from a source object using a dictionary that maps from entry field names to attributes (or keys) in the source object.

Parameters:
  • field_map (dict) – A dictionary mapping entry field names to the attribute in source_item (or keys, if source_item is a dict)(nested attributes/dicts are also supported, separated by a dot,) or a function that takes source_item as an argument

  • source_item (dict | object) – Source of information to be used by the map

  • ignore_none (bool) – Ignore any None values, do not record it to the Entry

_abc_impl = <_abc._abc_data object>#
property accepted: bool#
property failed: bool#
property rejected: bool#
property state: EntryState#
property undecided: bool#
class flexget.entry.EntryState(*values)[source]#

Bases: Enum

ACCEPTED = 'accepted'#
FAILED = 'failed'#
REJECTED = 'rejected'#
UNDECIDED = 'undecided'#
property color: str#
property log_markup: str#
class flexget.entry.LazyFunc(lazy_func_name)[source]#

Bases: object

Parameters:

lazy_func_name (str)

property function: Callable#
flexget.entry.register_lazy_lookup#

alias of LazyFunc