Skip to content

Instantly share code, notes, and snippets.

@bindi
Last active July 10, 2024 11:05
Show Gist options
  • Save bindi/5b78c87476e87c2c28168fcd9307b0ca to your computer and use it in GitHub Desktop.
Save bindi/5b78c87476e87c2c28168fcd9307b0ca to your computer and use it in GitHub Desktop.
Remove unregistered torrents in transmission-daemon (à la chatgpt)
#! /usr/bin/env python3
import transmission_rpc # pip install transmission-rpc
# Connect to the Transmission server
client = transmission_rpc.Client(
host='localhost', # Change this to your server's address if it's remote
port=9091, # Default Transmission RPC port
username='transmission', # Your Transmission username
password='transmission' # Your Transmission password
)
# Fetch all torrents
torrents = client.get_torrents()
# Loop through each torrent and remove those with an error status
for torrent in torrents:
if torrent.error and torrent.error_string == "Unregistered torrent": # Check if there's an error and it's "Unregistered torrent"
print(f"Removing torrent: {torrent.name} (ID: {torrent.id}) - Error: {torrent.error_string}")
client.remove_torrent(torrent.id, delete_data=False) # Set delete_data to True if you want to delete the data (you probably do, if it's hard linked to your Plex library)
print("All error torrents have been removed.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment