mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-01-08 04:00:03 -08:00
bfb45c180a
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
46 lines
1.0 KiB
Python
46 lines
1.0 KiB
Python
from __future__ import annotations
|
|
|
|
import logging
|
|
|
|
from transmission_rpc.client import Client as TransmissionClient
|
|
|
|
log = logging.getLogger(__name__)
|
|
log.addHandler(logging.NullHandler())
|
|
|
|
HOST = None
|
|
PORT = None
|
|
USERNAME = None
|
|
PASSWORD = None
|
|
|
|
|
|
def configure_transmission(config):
|
|
global HOST
|
|
global PORT
|
|
global USERNAME
|
|
global PASSWORD
|
|
|
|
HOST = config['TransmissionHost'] # localhost
|
|
PORT = int(config['TransmissionPort'])
|
|
USERNAME = config['TransmissionUSR'] # mysecretusr
|
|
PASSWORD = config['TransmissionPWD'] # mysecretpwr
|
|
|
|
|
|
def configure_client():
|
|
agent = 'transmission'
|
|
host = HOST
|
|
port = PORT
|
|
user = USERNAME
|
|
password = PASSWORD
|
|
log.debug(f'Connecting to {agent}: http://{host}:{port}')
|
|
try:
|
|
client = TransmissionClient(
|
|
host=host or '127.0.0.1',
|
|
port=port or 9091,
|
|
username=user,
|
|
password=password,
|
|
)
|
|
except Exception:
|
|
log.error('Failed to connect to Transmission')
|
|
else:
|
|
return client
|