Skip to content

Instantly share code, notes, and snippets.

@brokkr
Created June 30, 2015 08:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brokkr/981e3316e631eaaf7f88 to your computer and use it in GitHub Desktop.
Save brokkr/981e3316e631eaaf7f88 to your computer and use it in GitHub Desktop.
Remove finished torrents from Transmission BitTorrent client daemon
#! /usr/bin/python2
import transmissionrpc
## connection paramters - change to match your own settings
creds = {'address':'localhost', 'port':9091 'user':'my_user_name_here', 'password':'my_password_here'}
## establishing contact
tm_client = transmissionrpc.Client(creds['address'], creds['port'], creds['user'], creds['password'])
torrents_lst = tm_client.list()
## going through torrents, removing and trashing old ones
## set to only remove finished and stopped torrents that have at least a ration of 1.2
for torrent_no in torrents_lst:
torrent = torrents_lst[torrent_no]
if torrent.progress < 100 \
or torrent.status != 'stopped' \
or torrent.ratio < 1.2:
continue
tm_client.remove_torrent(torrent_no, delete_data=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment