TorrentCleaner is a Python script that automates the process of identifying and removing torrents that contain suspicious files (like .zipx
or .lnk
) from your qBittorrent download client. This ensures that unwanted or potentially harmful files are filtered out and deleted during the download process, keeping your system clean.
- Fetches the list of torrents from Sonarr's queue.
- Identifies torrents managed by qBittorrent.
- Inspects torrent contents to find suspicious file extensions (
.zipx
or.lnk
). - Automatically removes torrents containing suspicious files.
- Deletes associated files on disk using qBittorrent's API.
- Sonarr API key and URL
- qBittorrent URL and credentials (if required)
- Python 3.x
- Python packages:
requests
python-qbittorrent
-
Clone the repository:
git clone https://github.com/fischy667/torrentcleaner.git cd TorrentCleaner
-
Install the required dependencies:
pip install requests python-qbittorrent
-
Set up your environment variables (or hardcode the values in the script):
- Sonarr API key
- qBittorrent username and password (if authentication is required)
- Hostnames and ports for Sonarr and qBittorrent
sonarr_host = 'XXXX' # Update with your actual Sonarr host (e.g., 'localhost', '192.168.1.10', etc.) sonarr_port = '8989' # Update with the actual port where Sonarr is running sonarr_url = f'http://{sonarr_host}:{sonarr_port}/api/v3/queue' sonarr_api_key = 'XXXX' # Replace with your actual Sonarr API key qbit_url = 'http://xxxx:8080' # Replace with your qBittorrent host and port qbit_password_needed = False # Is password needed? e.g. bypass localhost, ... qbit_username = 'username' # If qBittorrent has authentication qbit_password = 'password'
Once configured, you can run the script to automatically check for torrents with .zipx
or .lnk
files and remove them from qBittorrent.
-
Run the script:
python sonarr_queue_clearner.py
-
The script will:
- Fetch all torrents from Sonarr's queue.
- Inspect the files in each torrent.
- If any
.zipx
or.lnk
files are found, the torrent will be removed and the files deleted.
Checking torrent contents for: TVShow.S02E08
Identified suspicious file: TVShow.S02E08/TVShow.S02E08.zipx. Marking download for removal...
Successfully removed download XXXX from Sonarr's queue.
You can modify the file types that trigger removal by editing the filename.endswith()
checks in the script:
if filename.endswith('.zipx') or filename.endswith('.lnk'):
Feel free to contribute by submitting a pull request or opening an issue. All contributions and suggestions are welcome.
This project is licensed under the MIT License - see the LICENSE file for details.