Created
June 20, 2020 21:42
-
-
Save gileri/91928df4444561e5f944da897d7ed173 to your computer and use it in GitHub Desktop.
Move rTorrent torrent download directories via XMLRPC
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env python3 | |
import logging | |
import sys | |
import xmlrpc.client | |
logging.basicConfig(level=logging.INFO) | |
def move_all_torrents(server: str, old_prefix: str, new_prefix: str): | |
with xmlrpc.client.ServerProxy(server) as proxy: | |
for torrent in proxy.download_list(): | |
directory = proxy.d.directory(torrent) | |
if directory.find(old_prefix) != 0: | |
logging.warning("Prefix %s doesn't match %s", old_prefix, directory) | |
continue | |
new_directory = directory.replace(old_prefix, new_prefix) | |
logging.info("%s : Moving %s to %s", torrent, directory, new_directory) | |
proxy.d.directory_base.set(torrent, new_directory) | |
if __name__ == "__main__": | |
move_all_torrents( | |
server=sys.argv[1], | |
old_prefix=sys.argv[2], | |
new_prefix=sys.argv[3], | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Move all torrents from a mount point to another (such as /mnt/source and /mnt/dest) :
python3 main.py http://localhost/RPC2 /mnt/source /mnt/dest