|
|
@@ -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) |