From 0122b4a8c9e4accffacc69731bd97263183e3913 Mon Sep 17 00:00:00 2001 From: mirro-chan Date: Thu, 31 Jan 2019 17:16:21 +0100 Subject: [PATCH] :D --- trrt.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 trrt.py diff --git a/trrt.py b/trrt.py new file mode 100644 index 0000000..111bda4 --- /dev/null +++ b/trrt.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python3 +import libtorrent as lt +import time +import sys + +ses = lt.session() +ses.listen_on(6881, 6891) +save_path = None +info = None +try: + info = lt.torrent_info(sys.argv[1]) +except IndexError: + print("You need to specify a torrent file.") + exit(0) + +try: + save_path = sys.argv[2]; +except IndexError: + print("No directory specified, defaulting to the current directory.") + save_path = "./" + +h = ses.add_torrent({'ti': info, 'save_path': save_path}) +print ('starting', h.name()) + +while (not h.is_seed()): + s = h.status() + + state_str = ['queued', 'checking', 'downloading metadata', \ + 'downloading', 'finished', 'seeding', 'allocating', 'checking fastresume'] + print ('\r%.2f%% complete (down: %.1f kb/s up: %.1f kB/s)' % (s.progress * 100, s.download_rate / 1000, s.upload_rate / 1000)) + sys.stdout.write('\r') + time.sleep(1) +print (h.name(), 'complete') +exit(0)