Cord Cutting

Deluge Auto Extract Torrents Settings
Create a Deluge directory structure as follows: 

 

 deluge 

 --> incoming (for in-progress downloads) 

 --> complete (for completed downloads) 

 --> torrent (for manual torrents) 

 

 Under Deluge --> Preferences --> Downloads --> Download to set it to your "incoming" directory from directory structure above 

 Under Deluge --> Preferences --> Downloads --> Move completed to set it to your "complete" directory from directory structure above 

 Under Deluge --> Preferences --> Downloads --> Autoadd .torrent files from set it to your "torrent" directory from directory structure above ( Figure 1 ) 

 

 Figure 1 

 

 

 Under Deluge --> Preferences -->Plugins enable the Execute plugin 

 Click " Apply " and " Ok " ( Figure 2 ). 

 

 Figure 2 

 

 

 Go back under Deluge --> Preferences -->Execute and click the " Add " button 

 In the Add Command window, select " Torrent Complete " in the Event dropdown and enter the path to your script in the Command input field and then click the Add button ( Figure 3 ). 

 

 Figure 3 

 

 

 Click the " Apply " and then " Ok " button ( Figure 4 ) 

 

 Figure 4 

 

 

 Create the extract.sh script in the path specified on step 9 above above and paste the following the contents of this script . 

 Save the script and make it executable: 

 

 chmod +x /scripts/extract.sh 

 

 Ensure unrar is installed: 

 

 sudo apt install unrar 

   

  

extract.sh
#!/bin/bash

formats=(zip rar)

commands=([zip]="unzip -u" [rar]="unrar -o- e")

extraction_subdir=''

torrentid=$1

torrentname=$2

torrentpath=$3

log()

{

 logger -t deluge-extractarchives "$@"

}

log "Torrent complete: $@"

cd "${torrentpath}"

for format in "${formats[@]}"; do

 while read file; do

 log "Extracting \"$file\""

 cd "$(dirname "$file")"

 file=$(basename "$file")

 # if extraction_subdir is not empty, extract to subdirectory

 if [[ ! -z "$extraction_subdir" ]] ; then

 mkdir "$extraction_subdir"

 cd "$extraction_subdir"

 file="../$file"

 fi

 ${commands[$format]} "$file"

 done < <(find "$torrentpath/$torrentname" -iname "*.${format}" )

done