nzbToMedia/nzb2media/qbittorrent.py
Labrys of Knossos bfb45c180a Lots of refactoring.
Remove version checks and update logic
Remove extraneous constants: SOURCE_ROOT, SYS_ARGV, APP_FILENAME, CONFIG_MOVIE_FILE, MY_APP, CONFIG_TV_FILE, GIT_*
Remove nzb2media.utils.processes
Update requirements
Flatten project structure
Keep settings close to code
Refactor NZBget, torrent configs, torrents, transcoder, tools, constants and forks
Refactor `nzbToMedia.main` to `nzb2media.app.main`
Fix flake/lint issues
2023-01-03 16:40:36 -05:00

42 lines
955 B
Python

from __future__ import annotations
import logging
from qbittorrent import Client as qBittorrentClient
log = logging.getLogger(__name__)
log.addHandler(logging.NullHandler())
HOST = None
PORT = None
USERNAME = None
PASSWORD = None
def configure_qbittorrent(config):
global HOST
global PORT
global USERNAME
global PASSWORD
HOST = config['qBittorrentHost'] # localhost
PORT = int(config['qBittorrentPort']) # 8080
USERNAME = config['qBittorrentUSR'] # mysecretusr
PASSWORD = config['qBittorrentPWD'] # mysecretpwr
def configure_client():
agent = 'qbittorrent'
host = HOST
port = PORT
user = USERNAME
password = PASSWORD
log.debug(f'Connecting to {agent}: http://{host}:{port}')
client = qBittorrentClient(f'http://{host}:{port}/')
try:
client.login(user, password)
except Exception:
log.error('Failed to connect to qBittorrent')
else:
return client