Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import rtorrent_xmlrpc
- import os, sys
- if len(sys.argv) != 2:
- print "This script takes the torrent hash as the first and only parameter."
- print "All completed files will be replicated using hardlinks in a directory called verified_complete_files in the current directory"
- exit(1)
- torrent = sys.argv[1]
- server = rtorrent_xmlrpc.SCGIServerProxy('scgi://localhost:5000/')
- print str(server.d.size_files(torrent)) + " " + server.d.name(torrent)
- print "Directory " + server.d.get_directory(torrent)
- completed = 0
- for i in range(0, server.d.size_files(torrent)) :
- fileid = torrent+":f"+str(i)
- if server.f.completed_chunks(fileid) == server.f.get_size_chunks(fileid):
- print "Found completed file: " + server.f.get_path(fileid)
- filepath = 'verified_complete_files/' + server.f.get_path(fileid)
- filedir = os.path.abspath(os.path.join(filepath, ".."))
- try:
- os.makedirs(filedir)
- except:
- pass
- os.link(server.d.get_directory(torrent) + '/' + server.f.get_path(fileid), filepath)
- completed += 1
- print "Found " + str(completed) + " completed files"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement