Last active
April 19, 2023 18:12
-
-
Save onedr0p/8170117d43873c18c34139b7c5904c14 to your computer and use it in GitHub Desktop.
rtorrent - remove specific torrents (set on a cron)
This file contains 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
# Python 2.7 | |
import re | |
import xmlrpclib | |
import httplib, urllib | |
# rTorrent URL | |
server_url = 'http://localhost:6000' | |
rtorrent = xmlrpclib.Server(server_url) | |
# Get all the torrents in rtorrent | |
torrents = rtorrent.download_list('', 'main') | |
for torrent in torrents: | |
# Delete Unregistered torrents in the sonarr category | |
torrent_tracker_status = rtorrent.d.get_message(torrent) | |
torrent_label = rtorrent.d.get_custom1(torrent) | |
# Remove torrents where they are deleted from trackers | |
text = re.search("Unregistered", torrent_tracker_status) | |
# Only remove ones that are in the sonarr or couchpotato label | |
if text and (torrent_label == 'sonarr' or torrent_label == 'couchpotato'): | |
torrent_hash = rtorrent.d.get_hash(torrent) | |
torrent_name = rtorrent.d.get_name(torrent) | |
rtorrent.d.delete_tied(torrent_hash) | |
rtorrent.d.erase(torrent_hash) |
It's been a long time since I made this, and I don't use rtorrent anymore. Maybe something change with rtorrents RPC? I am not sure but it did work 3 years ago.
My suggestion would be to search the internet and see if you can come up with anything.
I know this is pretty old but I ran into a similar problem as @Feriman22. If you run print(rtorrent.system.listMethods())
it will list all the commands accepted by the server. The rtorrent server I have has different commands than the one is the code example.
Some of the differences I found were:
torrent_label = rtorrent.d.custom1(torrent)
torrent_hash = rtorrent.d.hash(torrent)
torrent_name = rtorrent.d.name(torrent)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
I tried to run it, but I'm getting this below error: