Skip to content

Commit

Permalink
i commit
Browse files Browse the repository at this point in the history
  • Loading branch information
tommy144 committed Aug 5, 2014
0 parents commit d0b50f9
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
Empty file added README.md
Empty file.
37 changes: 37 additions & 0 deletions torrent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import libtorrent
import time
import sys

ses = libtorrent.session()
ses.listen_on(6881, 6891)
tracker_type = sys.argv[1]

torrent_info = libtorrent.torrent_info(sys.argv[1])
savepath = './'
params = {'ti' : torrent_info, 'save_path': savepath}
if sys.argv[1] is "--magnet":
params = {'ti' : torrent_info, 'save_path': savepath}
link = sys.argv[2]
handle = libtorrent.add_magnet_uri(ses, link, params)
else:
torrent_info = libtorrent.torrent_info(sys.argv[1])
t = ses.add_torrent(params)
print "starting", t.name()
print '\n'

while (not t.is_seed()):
s = t.status()
tstates = ['queued', 'checking', 'downloading metadata', 'downloading', \
'finished', 'seeding', 'allocating', 'checking fastresume']

print 'Completed', s.progress * 100
print ' | Down speed:', s.download_rate / 1000
print ' | Up speed:', s.upload_rate / 1000
print ' | Peers:', s.num_peers
print ' | state:', tstates[s.state]
print '\n'
sys.stdout.flush()

time.sleep(1)

print t.name(), 'complete'

0 comments on commit d0b50f9

Please sign in to comment.