Advertisement
iklio

Untitled

Apr 8th, 2014
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.16 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. import rtorrent_xmlrpc
  4. import os, sys
  5.  
  6. if len(sys.argv) != 2:
  7.     print "This script takes the torrent hash as the first and only parameter."
  8.     print "All completed files will be replicated using hardlinks in a directory called verified_complete_files in the current directory"
  9.     exit(1)
  10.  
  11. torrent = sys.argv[1]
  12.  
  13. server = rtorrent_xmlrpc.SCGIServerProxy('scgi://localhost:5000/')
  14.  
  15. print str(server.d.size_files(torrent)) + " " + server.d.name(torrent)
  16. print "Directory " + server.d.get_directory(torrent)
  17. completed = 0
  18. for i in range(0, server.d.size_files(torrent)) :
  19.     fileid = torrent+":f"+str(i)
  20.     if server.f.completed_chunks(fileid) == server.f.get_size_chunks(fileid):
  21.         print "Found completed file: " + server.f.get_path(fileid)
  22.         filepath = 'verified_complete_files/' + server.f.get_path(fileid)
  23.         filedir = os.path.abspath(os.path.join(filepath, ".."))
  24.         try:
  25.             os.makedirs(filedir)
  26.         except:
  27.             pass
  28.         os.link(server.d.get_directory(torrent) + '/' + server.f.get_path(fileid), filepath)
  29.         completed += 1
  30.  
  31. print "Found " + str(completed) + " completed files"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement