Skip to content

qBittorrent Unrar Script

Michael Higgins edited this page May 3, 2021 · 4 revisions

Custom shell script that will extract files before executing

You will need to provide a binary for unrarall and update the relevant environment variables including pythonpath, smapath, pathextraction, pathconversion, and unrarpath.

#!/bin/sh

torrentid=$6
torrentname=$5
torrentpath=$4
torrentrootpath=$3
torrenttracker=$2
torrentcategory=$1

pathextraction=/dwnldr/tor/extracted
pathconversion=/dwnldr/tor/converted

pythonpath=/usr/local/sma/venv/bin/python3
smapath=/usr/local/sma
unrarpath=/opt/qbittorrent/unrarall/unrarall

if [ "$torrentcategory" = "bypass" ]; then
	#echo "skipping this since it's in the bypass category"
	exit 0
fi

if [[ -d "$torrentrootpath" ]]; then
	#echo "$torrentrootpath" + " is a directory"
	mkdir "$pathextraction/$torrentname"
	mkdir "$pathconversion/$torrentname"
	"$unrarpath" -v -o "$pathextraction/$torrentname" "$torrentrootpath"
	extracted=$?
	wait $!
	if [ $extracted -eq 0 ]; then
		if [[ -n $(find "$pathextraction/$torrentname" -type f -size +50M) ]]; then
			"$pythonpath" "$smapath/qBittorrentPostProcess.py" "$torrentcategory" "$torrenttracker" "$pathextraction/$torrentname" "$pathextraction/$torrentname" "$torrentname" "$torrentid"
		else
			"$pythonpath" "$smapath/qBittorrentPostProcess.py" "$torrentcategory" "$torrenttracker" "$torrentrootpath" "$torrentpath" "$torrentname" "$torrentid"
		fi
	else
		"$pythonpath" "$smapath/qBittorrentPostProcess.py" "$torrentcategory" "$torrenttracker" "$torrentrootpath" "$torrentpath" "$torrentname" "$torrentid"
	fi
	rm -rf "$pathextraction/$torrentname"
elif [[ -f "$torrentpath" ]]; then
	#echo "$torrentpath" + " is a file"
	"$pythonpath" "$smapath/qBittorrentPostProcess.py" "$torrentcategory" "$torrenttracker" "$torrentrootpath" "$torrentpath" "$torrentname" "$torrentid"
fi

exit 0

Relevant Settings

qbit_downloads_config

Thanks to @johnwchambers

Clone this wiki locally