nzbToMedia/nzb2media/deluge.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
898 B
Python

from __future__ import annotations
import logging
from deluge_client import DelugeRPCClient
log = logging.getLogger(__name__)
log.addHandler(logging.NullHandler())
HOST = None
PORT = None
USERNAME = None
PASSWORD = None
def configure_deluge(config):
global HOST
global PORT
global USERNAME
global PASSWORD
HOST = config['DelugeHost'] # localhost
PORT = int(config['DelugePort']) # 8084
USERNAME = config['DelugeUSR'] # mysecretusr
PASSWORD = config['DelugePWD'] # mysecretpwr
def configure_client():
agent = 'deluge'
host = HOST
port = PORT
user = USERNAME
password = PASSWORD
log.debug(f'Connecting to {agent}: http://{host}:{port}')
client = DelugeRPCClient(host, port, user, password)
try:
client.connect()
except Exception:
log.error('Failed to connect to Deluge')
else:
return client