Skip to content

Script to cleanup unrar'd files after torrent automatically removed

Notifications You must be signed in to change notification settings

Jarsky/qBitTorrent-Cleanup-Script

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 

Repository files navigation

qBitTorrent-Cleanup-Script

Script to cleanup unrar'd files after torrent automatically removed

Overview

Many torrent releases on private trackers are still in a .rar archive. For automation these need to be extracted. In qBitTorrent this can be done by using the external program with a command such as:

unrar x "%F/.r" "%F/"

When using a cleanup to automatically remove torrents, wether that be natively in qBitTorrent or using a script such as autoremove-torrents the UnRAR'd file and subsequently the sub folder are not removed.

If you're using other tools such as Sonarr, Radarr, Lidarr, etc...which automatically copy your files, and the extracted files are left in a temporary location then this isnt ideal.

This script will scrub the qBitTorrent log and delete leftover files.

image

Installation

New Script Install qbittorrent-cli Install jq (JSON processor)

sudo apt update && sudo apt install -y jq

Clone qBitTorrent-Cleanup

  git clone https://github.com/Jarsky/qBitTorrent-Cleanup-Script.git && chmod +x ./qBitTorrent-Cleanup-Script/qBitTorrent-Cleanup.sh

Configure defaults for qbittorrent-cli

qbt settings set url http://localhost:8000 #URL of qBitTorrent WebUI
qbt settings set username <username> #Only if you enabled user authentication
qbt settings set password <prompt> #Only if you enabled user authentication

Usage

General


Edit the path to your downloads and qbittorrent.log in the script

./qBitTorrent-Cleanup.sh --help for supported commands

image

./qBitTorrent-Cleanup.sh -legacy test for log only (no deletion)

image

./qBitTorrent-Cleanup.sh -legacy

image

CRON

qBt-mover can setup CRON for you.
Simply run ./qBitTorrent-Cleanup.sh -cron which will give you the commands.

image

Setting up the default using ./qBitTorrent-Cleanup.sh -cron legacy looks like below

image

## qBitTorrent-Cleanup cron
* 4 * * *      cd /home/jarsky/scripts/qBitTorrent-Cleanup-Script && ./qBitTorrent-Cleanup.sh -legacy

If you want to remove the CRON entries just use

./qBitTorrent-Cleanup.sh -cron remove

image

LOGGING

Default: /var/log/qBitTorrent-Cleanup.log

If you want to run the script as your user in this location, then:

sudo touch /var/log/qBitTorrent-Cleanup.log
sudo chmod 755 /var/log/qBitTorrent-Cleanup.log

It is good practice to configure a logrotate.
In most GNU you would do something like this

sudo touch /etc/logrotate.d/qBitTorrent-Cleanup
sudo nano /etc/logrotate.d/qBitTorrent-Cleanup

And put the below code into the file and save

    /var/log/qBitTorrent-Cleanup.log {
            size 20M
            rotate 5
            compress
            delaycompress
            missingok
            notifempty
    }

NOTE You should set a larger size, as the script relies on the log for legacy function

This will let the log grow to 20 Megabytes, then rotate.
It will rotate 5x and then delete the oldest.
The log files from 2 onwards will be compressed.

You can run do a dry-run by running this command

sudo logrotate -d /etc/logrotate.d/qBitTorrent-Cleanup

About

Script to cleanup unrar'd files after torrent automatically removed

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages