This is a fully automatic torrent rotator, intended to be used in a server that has small space.
We recommend its usage in the following scenarios:
- You have a seedbox with a fast connection but small space.
- You have a RaspberryPi home server, or any other low-power Single Board Computer, with small space.
Besides the small-space server you already have, you will need a service with large storage-space that the software can transfer the completed downloads to. This can be either:
- A cloud storage account.
- Another server, SSH-accessible server, with large space to store the files.
Just put the torrent files you want to download in a directory. The rotator will download and synchronize them to the large storage space service.
The script manages and rotates a directory of torrents. Adds them to rtorrent when they can fit. Syncs completed files to a storage service once they reach the target ratio. Prioritizes the smallest torrents first. You can use it alongside unmanaged torrents but it won't factor these into space calculations. Once no more torrents will fit, it downloads individual files within torrents and syncs these as well. Only one torrent can be handled in this mode.
It will sync the complete torrents to virtually any cloud storage service, thanks to the powerful Rclone backend. If the destination is a remote server, it must be accessible via SSH.
You will need to have Python 3.6+ and Rtorrent 0.9.7+ installed. Older versions will not work.
If you want use the cloud sync feature, you must have Rclone installed. Don't forget to configure Rclone first!
Your rtorrent will need to be configured for XMLRPC access over SCGI. To enable
this, add the following lines to ~/.rtorrent.rc
:
network.scgi.open_local = /home/amoe/.rtorrent.sock
encoding_list = UTF-8
You need the encoding specification in order to prevent problems when files in torrents have non-ASCII names. Obviously you can put the socket file wherever you would like.
You need to create a config file under ~/.rtorrent_low_space_driver.cf
. Base
it on this template:
[main]
managed_torrents_directory = /home/amoe/managed_torrents
space_limit = 3221225472
required_ratio = 1.0
socket_url = scgi:///home/amoe/.rtorrent.sock
remote_sync_service = rsync
rsync_host = somehost
rsync_path = /home/amoe/place-with-space
All paths need to be absolute. The value for space_limit
is in bytes. The
value for socket_url
needs to match the value in .rtorrent.rc
, but with the
scgi://
prefix.
If you want to use Rclone, look at the examples in /templates
.
Run it from cron with a lock. Every hour is quite appropriate. Although the transfer will often take longer, so the lock is essential if you don't want to fill up your process table with rsync instances.
LANG=en_US.UTF-8
0 * * * * lckdo /var/lock/rtorrent_low_space_driver.lock /usr/local/bin/rtorrent-low-space-driver
The LANG setting is required, otherwise some attempts to format output will
fail, despite UTF-8 being hardcoded in many places. This is to be considered a
bug. (The failing call is subprocess.check_call
in Rsync's sync_path
.)
If space on the remote runs out, the rsync process can hang in a repeated retry.
Please run the command with the flag --help to check for other supported options.
Many thanks to Roger Que for the SCGI module, and the authors of Pyroscope for a bit of inspiration.
License GPLv2