Last active
October 12, 2022 01:14
-
-
Save subzero79/87a347a07964390884c9 to your computer and use it in GitHub Desktop.
Sonarr post processing script to clean video files if the source is rar (packed) content
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
#!/bin/bash | |
#sonarr_episodefile_sourcefolder="/torrent/finish/tv-sonarr/Penny.Dreadful.S01E01.720p.HDTV.x264-2HD" | |
#sonarr_episodefile_sourcepath="/torrent/finish/tv-sonarr/Penny.Dreadful.S01E01.720p.HDTV.x264-2HD/penny.dreadful.s01e01.720p.hdtv.x264-2hd.mkv" | |
sonarr_label="tv-sonarr" | |
base_dir=$(basename $sonarr_episodefile_sourcefolder) | |
if [ "${base_dir}" == "${sonarr_label}" ];then | |
echo "Single file torrent" | |
exit | |
fi | |
find $sonarr_episodefile_sourcefolder -name \*.r[0-9][0-9] | egrep '.*' &>/dev/null | |
case $? in | |
0) | |
echo "Rar files present, deleting video files" | |
echo `rm -rv "${sonarr_episodefile_sourcepath}"` | |
;; | |
*) | |
echo "No rar files, nothing to clean" | |
;; | |
esac |
I also tried this script and it deleted the entire data folder where the torrents are downloaded. I am using Deluge client. How can I configure this script so that it deletes the video file and keeps the rar files? My downloads go under torrents/data and Sonarr moves the extracted video files to Media/TV.
I wish I'd realized you could fork a gist, but I suggest -iregex '.*\.r[0-9a][0-9r]$'
for your find argument. It accounts for (rare) files named like part01.rar
as well as numbered .r00
files. Though I suppose it could choke if the movie isn't really rar'd, but instead comes w/ a small .rar
file for some reason.
My version: https://gist.github.com/fryfrog/94716e7e27ba38dff57c7631d9f58bed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi subzero,
Just found this script, exactly what I need. I have a script that runs after unrar after Transmission is finished downloading.
Which then Sonarr or Radarr process and what is left is the folder with all the RAR-files and the unrar'ed file which I would like to remove, only to keep the rar-files for seeding.
From what I understand this is it.
I tried it out, set my Completed folder to this:
#sonarr_episodefile_sourcefolder=/pathtomycompletefolder/
and this #sonarr_episodefile_sourcepath=/pathtomycompletefolder/
What happened was that it removed the whole folder in that path.
How do I make it to only delete the movie/tv series files that are extracted? And only from Sonarr and Radarr?
Thank you!