Skip to content

[feature] Add SSL options to qBittorrent plugin#2074

Merged
cvium merged 4 commits intoFlexget:developfrom
wimex:qbittorrent-ssl
Feb 5, 2018
Merged

[feature] Add SSL options to qBittorrent plugin#2074
cvium merged 4 commits intoFlexget:developfrom
wimex:qbittorrent-ssl

Conversation

@wimex
Copy link
Copy Markdown
Contributor

@wimex wimex commented Feb 2, 2018

Motivation for changes:

The qBittorrent plugin is currently unable to add torrents over a secure web interface

Detailed changes:

This commit adds two new options to the qBittorrent plugin configuration:

  • use_ssl: if set to True, the plugin connects to the API using https (default: False)
  • verify_cert: if set to False, skips SSL certificate verification (for self-signed certificates) (default: True)

Config usage if relevant (new plugin or updated schema):

For example:
qbittorrent:
host: 192.168.1.2
port: 8080
use_ssl: yes
verify_cert: no

self.session = Session()
self.url = 'http://{}:{}'.format(config['host'], config['port'])
self.url = '{}://{}:{}'.format('http' if config['use_ssl']==False else 'https', config['host'], config['port'])
if config.get('username') and config.get('password'):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. You probably meant the opposite, https if use_ssl is True.
  2. Explicitly checking if a statement is True should be made with the is comparator: if var is True:
  3. It's more python to check for truthiness directly:
    'https' if config['use_ssl'] else 'http'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forget about 1, misread

self._request('post', self.url + '/command/upload', msg_on_fail='Failed to add file to qBittorrent',
files=multipart_data)
log.debug('Added torrent file %s to qBittorrent', file_path)
log.debug('Added torrent file %s to qBittorrent', file_path, verify=config['verify_cert'])
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you wanna add verify status in here, fix the message as well

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the insights!
This one was a mistake, I wanted to add the parameter to the previous line.
Everything else has been fixed.

entry.fail("Downloaded temp file '%s' doesn't exist!?" % entry['file'])
continue
self.add_torrent_file(entry['file'], form_data)
self.add_torrent_file(entry['file'], form_data, config)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't pass the whole config if you just need it for the verify cert, pass just that

data = {'username': config['username'],
'password': config['password']}
self._request('post', self.url + '/login', data=data, msg_on_fail='Authentication failed.')
self._request('post', self.url + '/login', data=data, msg_on_fail='Authentication failed.', verify=config['verify_cert'])
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is 14 chars too long.

multipart_data['torrents'] = f
self._request('post', self.url + '/command/upload', msg_on_fail='Failed to add file to qBittorrent',
files=multipart_data)
files=multipart_data, verify=verify_cert)
Copy link
Copy Markdown
Contributor

@cvium cvium Feb 5, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pep8 alignment issues here. The start of the second line inside parentheses should line up with the opening parenthesis ie.

self._request('post', self.url + '/command/upload', msg_on_fail='Failed to add file to qBittorrent',
                      files=multipart_data, verify=verify_cert)

Fix that here and on line 94 and it should be good to go.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also fixed it in line 74

@cvium cvium merged commit e072188 into Flexget:develop Feb 5, 2018
@cvium
Copy link
Copy Markdown
Contributor

cvium commented Feb 5, 2018

Thanks. Can you update the wiki as well?

@wimex
Copy link
Copy Markdown
Contributor Author

wimex commented Feb 6, 2018

I have updated the wiki

@wimex wimex deleted the qbittorrent-ssl branch February 6, 2018 10:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants