From 2c99d877656bed8ea78d626c2e2a616198c7dc3b Mon Sep 17 00:00:00 2001 From: Stiofain Fordham Date: Wed, 23 Nov 2022 22:56:47 +0000 Subject: [PATCH] Changed to using command class --- cli.py | 21 ++++++++------------- methods.py | 2 +- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/cli.py b/cli.py index 8de8414..9c836b1 100644 --- a/cli.py +++ b/cli.py @@ -5,8 +5,7 @@ from pathlib import Path from typing import Optional -from .torrent import TorrentData -from .methods import find_files, add_to_transmission +from transmission import TransmissionCommand def main( @@ -28,18 +27,14 @@ def main( continue tf.find_data(data_files) if tf.data: - print(f"Torrent file @ {tf.path}") - print(f" from tracker {tf.tracker}") + print(f"Torrent file @ {tf.path}\n from tracker {tf.tracker}") if len(tf.data) == 1: - print(f"matched data @ {tf.data[0].parent}") - print(f"Adding to transmission...") - res = add_to_transmission( - add=tf.path, - download_dir=tf.data[0].parent, - username=username, - password=password, - ) - print("Response:", res) + download_dir = tf.data[0].parent + print(f"matched data @ {download_dir}\nAdding to transmission...") + cmd = TransmissionCommand() + cmd.add(tf.path).download_dir(download_dir) + res = cmd.auth(username, password).exec() + print("Transmission response:", res) time.sleep(sleep) elif len(tf.data) > 1: uniq_parents = {f.parent for f in tf.data} diff --git a/methods.py b/methods.py index 4a18130..4f7fb3b 100644 --- a/methods.py +++ b/methods.py @@ -3,7 +3,7 @@ from pathlib import Path from typing import Optional -from .transmission import TransmissionRow +from transmission import TransmissionRow def find_files(