Last active
November 13, 2024 18:15
-
-
Save zatricky/9587a1ecf754b067ad5a578a6868510f to your computer and use it in GitHub Desktop.
custom script to remove file types from being downloaded using transmission-rpc python lib
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
#!/usr/bin/env python3 | |
""" Custom remote transmission server configurations | |
""" | |
from transmission_rpc import Client | |
# See https://transmission-rpc.readthedocs.io/ | |
PROTOCOL="https" | |
USERNAME="user" | |
PASSWORD="password" | |
HOST="remote.server.example.net" | |
PORT=9091 | |
RPC_PATH="/transmission/rpc" | |
media_paths = ( | |
"/home/downloads/isos", | |
"/home/downloads/pdfs" | |
) | |
banned_extensions = ( | |
".acm", | |
".ax", | |
".cpl", | |
".dll", | |
".drv", | |
".efi", | |
".exe", | |
".lnk" | |
".msstyles", | |
".mui", | |
".mun", | |
".ocx", | |
".scr", | |
".sys", | |
".tsp", | |
".txt", | |
) | |
client = Client(protocol=PROTOCOL, username=USERNAME, password=PASSWORD, host=HOST, port=PORT, path=RPC_PATH) | |
torrent_list = client.get_torrents() | |
for torrent in torrent_list: | |
if torrent.download_dir in media_paths: | |
if len(torrent.file_stats) > 1: | |
banned_file_extension_matches=[file.id for file in torrent.get_files() if file.name.lower().endswith(tuple(banned_extensions))] | |
if len(banned_file_extension_matches) > 0: | |
client.change_torrent( | |
torrent.hashString, | |
files_unwanted=banned_file_extension_matches | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment