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 hidden or 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) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example setup:
rpc-enabledis set totruein 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.pysudo easy_install transmissionrpcconfig.pyin the same directory:which pythonsudo crontab -lPATH=/usr/sbin:/usr/bin:/sbin:/bin