Browse Source

:D

master
mirro-chan GitHub 5 years ago
parent
commit
0122b4a8c9
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 34 additions and 0 deletions
  1. +34
    -0
      trrt.py

+ 34
- 0
trrt.py View File

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

Loading…
Cancel
Save