Last active
April 5, 2019 15:45
-
-
Save pettazz/65ef6ce2a8c8a00ec3d95a923329c4f2 to your computer and use it in GitHub Desktop.
Delete and remove files for any seeding torrents that have been idle for some number of days
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
import datetime | |
import transmissionrpc | |
from config import TRANSMISSION | |
daemon = transmissionrpc.Client( | |
address=TRANSMISSION.server, | |
port=TRANSMISSION.port, | |
user=TRANSMISSION.user, | |
password=TRANSMISSION.password) | |
for torrent in daemon.get_torrents(): | |
if torrent.status == 'seeding': | |
idle_time = datetime.datetime.now() - torrent.date_active | |
if idle_time > datetime.timedelta(days=2): | |
print 'Removing %s after %s inactivity' % (torrent.name, idle_time) | |
daemon.remove_torrent(torrent.hashString, delete_data=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example setup:
rpc-enabled
is set totrue
in your transmission-daemon config and that RPC is up and running (if you have something like Sonarr using it, you're all set already)/home/tvrobot/transmission-cleanup/run.py
sudo easy_install transmissionrpc
config.py
in the same directory:which python
sudo crontab -l
PATH=/usr/sbin:/usr/bin:/sbin:/bin