A python script for queuing torrents. Just moves files into the watch directory based on what rtorrent reports, and not merely by using the directories as an indication. You’re expected to have setup SCGI with rtorrent. So that requires compiling with XML-RPC which many distros will not do, and have the option enabled in the
.rtorrent.rc. xmlrpc2scgi is also needed.
import xmlrpc2scgi as xs import os import glob import stat import time import shutil # scgi host and port rtorrent_host="scgi://localhost:5000" # watch and queue folders watch = "/home/USERNAME/.rtorrent/watch" queue = "/home/USERNAME/.rtorrent/queue" # total number of downloads allowed max_downloads = 4 # download rate in kbp/s max_download_rate = 50000 # how often to recheck to add more (in seconds) recheck_time = 25 rtc = xs.RTorrentXMLRPCClient(rtorrent_host) while True: infohashes = rtc.download_list('incomplete') if (len(infohashes) < max_downloads) or (rtc.get_down_rate() < max_download_rate): download =  for file in glob.glob(queue + '/*.torrent'): download.append((os.stat(file)[stat.ST_MTIME], file)) if len(download) > 0: download.sort() if os.path.exists(watch + '/' + str(download).split('/')[-1]): print "%s already exists, deleting from queue folder" % (download) os.remove(download) else: print "%s -> %s" % (download, watch) shutil.move(download, watch) time.sleep(recheck_time)
It only goes by incomplete torrents
, but you can check by other views or maybe even upload or download speed. If you want to do something like max download/upload speed you can check get_upload_rate/get_download_rate and maybe start torrents that way to try max out the connection.