nzbToMedia/nzb2media/utorrent.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

38 lines
824 B
Python

from __future__ import annotations
import logging
from utorrent.client import UTorrentClient
log = logging.getLogger(__name__)
log.addHandler(logging.NullHandler())
HOST = None
USERNAME = None
PASSWORD = None
def configure_utorrent(config):
global HOST
global USERNAME
global PASSWORD
HOST = config['uTorrentWEBui'] # http://localhost:8090/gui/
USERNAME = config['uTorrentUSR'] # mysecretusr
PASSWORD = config['uTorrentPWD'] # mysecretpwr
def configure_client():
agent = 'utorrent'
web_ui = HOST
user = USERNAME
password = PASSWORD
log.debug(f'Connecting to {agent}: {web_ui}')
try:
client = UTorrentClient(web_ui, user, password)
except Exception:
log.error('Failed to connect to uTorrent')
return None
else:
return client