flexget.plugins.metainfo.nfo_lookup module#

exception flexget.plugins.metainfo.nfo_lookup.BadXmlFile[source]#

Bases: Exception

Exception that is raised if the nfo file can’t be parsed due to some invalid nfo file.

class flexget.plugins.metainfo.nfo_lookup.NfoLookup[source]#

Bases: object

Retrieves information from a local ‘.nfo’ info file.

The read metadata will be add as ‘nfo_something’ in the entry. Also, if an ‘id’ is found in the ‘.nfo’ file then the ‘imdb_id’ field will be set to its value. This means that if the imdb_lookup plugin is used in addition to this plugin it will be able to use the ID from ‘.nfo’ file to get the correct movie.

The nfo file is used by Kodi.

Example:

nfo_lookup: yes

WARNING: This plugin will read a file with extension ‘.nfo’ and the same name as the entry filename as an XML file using xml.etree.ElementTree from the standard python library. As such, it is vulnerable to XML vulnerabilities described in the link below https://docs.python.org/3/library/xml.html#xml-vulnerabilities

Use this only with nfo files you have created yourself.

get_nfo_filename(entry)[source]#

Get the filename of the nfo file from the ‘location’ in the entry.

Returns#

str

The file name of the ‘nfo’ file, or None it there is no ‘nfo’ file.

lookup(entry, nfo_filename)[source]#
on_task_metainfo(task, config)[source]#
nfo_file_extension = '.nfo'#
schema = {'type': 'boolean'}#
class flexget.plugins.metainfo.nfo_lookup.NfoReader(filename)[source]#

Bases: object

Class in charge of parsing the ‘.nfo’ file and getting a dictionary of fields.

The ‘.nfo’ file is an XML file. Some fields can only appear once, such as ‘title’, ‘id’, ‘plot’, etc., while other fields can appear multiple times (with different values), such as ‘thumb’, ‘genre’, etc. These fields are listed in the _fields attribute.

static _composite_elem_getter_func(x)[source]#

Get XML elements that have children as a dictionary.

static _single_elem_getter_func(x)[source]#

Get the text value of simple XML element that does not contain child nodes.

_extract_multiple_field(name, getter_func)[source]#

Use this method to get fields from the root XML tree that can appear more than once, such as ‘actor’, ‘genre’, ‘director’, etc.

The result will be a list of values.

_extract_single_field(name, getter_func)[source]#

Get fields from the root XML tree that only appear once, such as ‘title’, ‘year’, etc.

get_fields_from_nfo_file()[source]#

Return a dictionary with all firlds read from the ‘.nfo’ file.

The keys are named as ‘nfo_something’.

flexget.plugins.metainfo.nfo_lookup.register_plugin()[source]#