I just finished migrating over my torrents from the depreciated binhex rutorrent container. I did have to pip install qbittorrent-api to simplify using the qbittorrent api. I am not a programmer and so my process is super clunky but I was able to migrate about 3.4k torrents successfully. I am not running unraid but I am using the same containers.
Rather than downloading the torrent files via "get .torrent" in rutorrent, I downloaded the torrents in the session directory of rtorrent which are named with the hash. I had a bunch of torrents with custom directories set and without the torrent name added to the path so I could not import all of my torrents and point them at a certain directory.
I had manually moved some torrents over so I ended up making a python script to compare the torrents loaded in qbittorrent to those in rtorrent and for those missing, output the torrent name, hash, and save path to a .csv. Using the csv list of torrents and the torrent files from the rtorrent session directory I made another script to go through the .csv of torrents not in qbittorrent to add them using the save path from rtorrent for each torrent without creating subfolders.
To generate the .csv of missing torrents:
import csv
import xmlrpc.client
from qbittorrentapi import Client
# qBittorrent API Configuration
QB_USERNAME = 'USERNAME' #change
QB_PASSWORD = 'PASSWORD' #change
QB_HOST = '192.168.1.123' # Modify with qbittorrent ip address
QB_PORT = 9081 # Modify qbittorrent iport
# ruTorrent Configuration
RUTORRENT_RPC_URL = 'http://USERNAME:
[email protected]:9080/RPC2' # Modify with your rutorrent credentials
# Connect to qBittorrent
qb_client = Client(host=QB_HOST, port=QB_PORT)
qb_client.auth_log_in(QB_USERNAME, QB_PASSWORD)
# Connect to ruTorrent
ru_client = xmlrpc.client.Server(RUTORRENT_RPC_URL)
# Get list of torrents in qBittorrent
qb_torrents = qb_client.torrents_info()
# Get list of torrents in ruTorrent
ru_torrents = ru_client.download_list("","main")
# Compare the torrents and find missing ones
missing_torrents = []
for ru_torrent in ru_torrents:
ru_torrent_hash = ru_client.d.get_hash(ru_torrent).lower()
found = False
for qb_torrent in qb_torrents:
if ru_torrent_hash.lower() == qb_torrent['hash'].lower():
found = True
break
if not found:
ru_torrent_name = ru_client.d.get_name(ru_torrent)
print("Missing Torrent found! " + ru_torrent_name)
ru_torrent_path = ru_client.d.get_directory(ru_torrent)
missing_torrents.append({
'name': ru_torrent_name,
'path': ru_torrent_path,
'hash': ru_torrent_hash
})
# Export missing torrents to a CSV file
csv_file = 'missing_torrents.csv'
with open(csv_file, 'w', encoding="utf-8", newline='') as file:
writer = csv.writer(file)
writer.writerow(['Torrent Name', 'Path', 'Torrent Hash'])
for torrent in missing_torrents:
writer.writerow([torrent['name'], torrent['path'], torrent['hash']])
print(f"List of missing torrents exported to {csv_file}")
Take the csv and add the torrents to qbittorrent using the downloaded torrent files from the session directory
import qbittorrentapi
import os
import csv
def add_torrent(username, password, url, torrent_file_path, save_path):
# Connect to the qBittorrent client
client = qbittorrentapi.Client(host=url, username=username, password=password)
client.auth_log_in()
try:
# Read the .torrent file as binary
with open(torrent_file_path, 'rb') as file:
torrent_data = file.read()
# Set the request parameters
parameters = {
'savepath': save_path,
'paused': True, # Set all torrents to be added as paused
'autoTMM': False # Disable subfolder creation
}
# Add the .torrent file
client.torrents_add(torrent_files=torrent_data, savepath=save_path, category='', parameters=parameters)
print("Torrent added successfully!")
except qbittorrentapi.LoginFailed as e:
print("Authentication failed. Please check your credentials.")
except Exception as e:
print(f"Error: {e}")
# Provide your qBittorrent's API URL, username, and password
api_url = 'http://192.168.1.123:9081' # Replace with your qBittorrent's API URL and port
api_username = 'USERNAME' # Replace with your qBittorrent's API username
api_password = 'PASSWORD' # Replace with your qBittorrent's API password
# Provide the path to the CSV file
csv_file_path = 'C:\\Users\\user\\Desktop\\rtorrent\\missing_torrents.csv' # Replace with the path to your CSV file of missing torrents generated by the previous script
# Read the CSV file and add the torrents
with open(csv_file_path, 'r') as file:
csv_reader = csv.DictReader(file)
for row in csv_reader:
try:
torrent_file_path = 'C:\\Users\\user\\Desktop\\rtorrent\\session_torrent_files\\' + row['Torrent Hash'].upper() + '.torrent'
save_path = row['Path']
add_torrent(api_username, api_password, api_url, torrent_file_path, save_path)
except Exception as e:
print(row)
continue
All torrents will be added in as paused. I did a force recheck and once that was done everything was migrated over. You could modify this to do it all on the server and in a single script with less code but this is what I got to work.