flexget.components.ftp.sftp module#

class flexget.components.ftp.sftp.SftpConfig(host, port, username, password, private_key, private_key_pass, host_key)[source]#

Bases: NamedTuple

Parameters:
classmethod _make(iterable)#

Make a new SftpConfig object from a sequence or iterable

_asdict()#

Return a new dict which maps field names to their values.

_replace(**kwds)#

Return a new SftpConfig object replacing specified fields with new values

_field_defaults = {}#
_fields = ('host', 'port', 'username', 'password', 'private_key', 'private_key_pass', 'host_key')#
host: str#

Alias for field number 0

host_key: HostKey#

Alias for field number 6

password: str#

Alias for field number 3

port: int#

Alias for field number 1

private_key: str#

Alias for field number 4

private_key_pass: str#

Alias for field number 5

username: str#

Alias for field number 2

class flexget.components.ftp.sftp.SftpDownload[source]#

Bases: object

Download files from a SFTP server.

This plugin requires the pysftp Python module and its dependencies.

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.

recursive

Indicates whether to download directory contents recursively.

delete_origin

Indicates whether to delete the remote files(s) once they’ve been downloaded.

socket_timeout_sec

Socket timeout in seconds

connection_tries

Number of times to attempt to connect before failing (default 3).

Example:

sftp_download:
    to: '/Volumes/External/Drobo/downloads'
    delete_origin: False
classmethod _get_sftp_config(entry)[source]#

Parse a url and return a hashable config, source path, and destination path.

Parameters:

entry (Entry)

classmethod download_entry(entry, config, sftp)[source]#

Download the file(s) described in entry.

Parameters:
Return type:

None

classmethod on_task_download(task, config)[source]#

Task handler for sftp_download plugin.

Parameters:
Return type:

None

classmethod on_task_output(task, config)[source]#

Register this as an output plugin.

Parameters:
Return type:

None

schema = {'additionalProperties': False, 'properties': {'connection_tries': {'default': 3, 'type': 'integer'}, 'delete_origin': {'default': False, 'type': 'boolean'}, 'recursive': {'default': True, 'type': 'boolean'}, 'socket_timeout_sec': {'default': 15, 'type': 'integer'}, 'to': {'format': 'path', 'type': 'string'}}, 'required': ['to'], 'type': 'object'}#
class flexget.components.ftp.sftp.SftpList[source]#

Bases: object

Generate entries from SFTP. This plugin requires the pysftp Python module and its dependencies.

Configuration options

Option

Description

host

Host to connect to.

port

Port the remote SSH server is listening on (default 22).

username

Username to log in as.

password

The password to use. Optional if a private key is provided.

private_key

Path to the private key (if any) to log into the SSH server.

private_key_pass

Password for the private key (if needed).

recursive

Indicates whether the listing should be recursive.

get_size

Indicates whetern to calculate the size of the remote file/directory. WARNING: This can be very slow when computing the size of directories!

files_only

Indicates whether to omit diredtories from the results.

dirs_only

Indicates whether to omit files from the results.

dirs

List of directories to download.

socket_timeout_sec

Socket timeout in seconds (default 15 seconds).

connection_tries

Number of times to attempt to connect before failing (default 3).

host_key

Specifies a host key not already in known_hosts

Example:

sftp_list:
    host: example.com
    username: Username
    private_key: /Users/username/.ssh/id_rsa
    recursive: False
    get_size: True
    files_only: False
    dirs:
        - '/path/to/list/'
        - '/another/path/'
classmethod on_task_input(task, config)[source]#

Input task handler.

Parameters:
Return type:

list[Entry]

static prepare_config(config)[source]#

Set defaults for the provided configuration.

Parameters:

config (dict)

Return type:

dict

schema = {'additionalProperties': False, 'properties': {'connection_tries': {'default': 3, 'type': 'integer'}, 'dirs': {'oneOf': [{'items': {'title': 'single value', 'type': 'string'}, 'minItems': 1, 'title': 'multiple values', 'type': 'array', 'uniqueItems': False}, {'title': 'single value', 'type': 'string'}]}, 'dirs_only': {'default': False, 'type': 'boolean'}, 'files_only': {'default': True, 'type': 'boolean'}, 'get_size': {'default': True, 'type': 'boolean'}, 'host': {'type': 'string'}, 'host_key': {'additionalProperties': False, 'properties': {'key_type': {'enum': ['ssh-rsa', 'ssh-ed25519'], 'type': 'string'}, 'public_key': {'type': 'string'}}, 'required': ['key_type', 'public_key'], 'type': 'object'}, 'password': {'type': 'string'}, 'port': {'default': 22, 'type': 'integer'}, 'private_key': {'type': 'string'}, 'private_key_pass': {'type': 'string'}, 'recursive': {'default': False, 'type': 'boolean'}, 'socket_timeout_sec': {'default': 15, 'type': 'integer'}, 'username': {'type': 'string'}}, 'required': ['host', 'username'], 'type': 'object'}#
class flexget.components.ftp.sftp.SftpUpload[source]#

Bases: object

Upload files to a SFTP server. This plugin requires the pysftp Python module and its dependencies.

Option

Description

host

Host to connect to

port

Port the remote SSH server is listening on. Defaults to port 22.

username

Username to log in as

password

The password to use. Optional if a private key is provided.

private_key

Path to the private key (if any) to log into the SSH server

private_key_pass

Password for the private key (if needed)

to

Path to upload the file to; 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.

delete_origin

Indicates whether to delete the original file after a successful upload.

socket_timeout_sec

Socket timeout in seconds

connection_tries

Number of times to attempt to connect before failing (default 3).

host_key

Specifies a host key not already in known_hosts

Example:

sftp_list:
    host: example.com
    username: Username
    private_key: /Users/username/.ssh/id_rsa
    to: /TV/{{series_name}}/Series {{series_season}}
    delete_origin: False
classmethod handle_entry(entry, sftp, config)[source]#
Parameters:
classmethod on_task_output(task, config)[source]#

Upload accepted entries to the specified SFTP server.

Parameters:
Return type:

None

static prepare_config(config)[source]#

Set defaults for the provided configuration.

Parameters:

config (dict)

Return type:

dict

schema = {'additionalProperties': False, 'properties': {'connection_tries': {'default': 3, 'type': 'integer'}, 'delete_origin': {'default': False, 'type': 'boolean'}, 'host': {'type': 'string'}, 'host_key': {'additionalProperties': False, 'properties': {'key_type': {'enum': ['ssh-rsa', 'ssh-ed25519'], 'type': 'string'}, 'public_key': {'type': 'string'}}, 'required': ['key_type', 'public_key'], 'type': 'object'}, 'password': {'type': 'string'}, 'port': {'default': 22, 'type': 'integer'}, 'private_key': {'type': 'string'}, 'private_key_pass': {'type': 'string'}, 'socket_timeout_sec': {'default': 15, 'type': 'integer'}, 'to': {'type': 'string'}, 'username': {'type': 'string'}}, 'required': ['host', 'username'], 'type': 'object'}#
flexget.components.ftp.sftp.register_plugin()[source]#
Return type:

None

flexget.components.ftp.sftp.sftp_connect(sftp_config, socket_timeout_sec, connection_tries)[source]#
Parameters:
Return type:

SftpClient

flexget.components.ftp.sftp.task_config_to_sftp_config(config)[source]#

Create an SFTP connection from a Flexget config object.

Parameters:

config (dict)

Return type:

SftpConfig