flexget.components.archives.decompress module#

class flexget.components.archives.decompress.Decompress[source]#

Bases: object

Extract files from Zip or RAR archives.

By default this plugin will extract to the same directory as the source archive, preserving directory structure from the archive.

This plugin requires the rarfile Python module and unrar command line utility to extract RAR archives.

Configuration options

Option

Description

to

Destination path; supports Jinja2 templating on the input entry. Fields such as series_name must be populated prior to input into this plugin using metainfo_series or similar. If no path is specified, archive contents will be extracted in the same directory as the archive itself.

keep_dirs

[yes|no] (default: yes) Indicates whether to preserve the directory structure from within the archive in the destination path.

mask

Shell-style file mask; any matching files will be extracted. When used, this field will override regexp.

regexp

Regular expression pattern; any matching files will be extracted. Overridden by mask if specified.

unrar_tool

Specifies the path of the unrar tool. Only necessary if its location is not defined in the operating system’s PATH environment variable.

delete_archive

[yes|no] (default: no) Delete this archive after extraction is completed.

Example:

decompress:
  to: '/Volumes/External/TV/{{series_name}}/Season {{series_season}}/'
  keep_dirs: yes
  regexp: '.*s\d{1,2}e\d{1,2}.*\.mkv'
static handle_entry(entry, config, test=False)[source]#

Extract matching files into the directory specified.

Optionally delete the original archive if config.delete_archive is True

static prepare_config(config)[source]#

Prepare config for processing.

on_task_output(task, config)[source]#

Task handler for archive_extract.

on_task_start(task, config)[source]#
schema = {'anyOf': [{'type': 'boolean'}, {'additionalProperties': False, 'properties': {'delete_archive': {'type': 'boolean'}, 'keep_dirs': {'type': 'boolean'}, 'mask': {'type': 'string'}, 'regexp': {'format': 'regex', 'type': 'string'}, 'to': {'type': 'string'}, 'unrar_tool': {'type': 'string'}}, 'type': 'object'}]}#
flexget.components.archives.decompress.extract_info(info, archive, to, keep_dirs, test=False)[source]#

Extract ArchiveInfo object.

Parameters:

to (Path)

flexget.components.archives.decompress.fail_entry_with_error(entry, error)[source]#

Log error message at error level and fail the entry.

flexget.components.archives.decompress.get_destination_path(info, to, keep_dirs)[source]#

Generate the destination path for a given file.

Parameters:

to (Path)

Return type:

Path

flexget.components.archives.decompress.get_output_path(to, entry)[source]#

Determine which path to output to.

Parameters:

to (str)

Return type:

Path

flexget.components.archives.decompress.is_match(info, pattern)[source]#

Return whether an info record matches the supplied regex.

flexget.components.archives.decompress.open_archive_entry(entry)[source]#

Return an archive.Archive object.

Convenience function for opening archives from entries.

flexget.components.archives.decompress.register_plugin()[source]#