
I have a cron job that purges each server. See my previous post on how to automatically add items using an RSS feed.
The script below connects to the transmission server and scans the torrent list removing items that are 100% ie done.
The count of files removed is written to a log file. The program outputs the items deleted though this is not logged for brevity.
#!/usr/bin/python
import sys, os
import feedparser
import transmissionrpc
import argparse
import datetime
# Read the torrents on the server...
kc=0
tc=transmissionrpc.Client('192.168.0.143',port=9091)
t=tc.get_torrents()
for key in t:
#for torrent in tc.items():
if key.isFinished:
print 'Removing Seed Complete', key.name
tc.remove_torrent(key.id)
else:
if key.percentDone == 1:
print 'Removing Download Complete',key.name
kc=kc+1
tc.remove_torrent(key.id) #Retains data. Torrent is removed
sttime = datetime.datetime.now().strftime('%Y%m%d_%H:%M:%S - ')
le = "Purge run. " + str(kc) +" file(s) removed."
log = '/root/purgeloft.log'
with open(log, 'a') as logfile:
logfile.write(sttime + le + '\n')