LAST UPDATED: 7th February 2017
TESTED ON: Ubuntu 16.04.1 LTS / Flexget 2.9.15

Flexget & Deluge Setup on Ubuntu Server

Setup Ubuntu User

once you log in to your seedbox/vps for the first time with your root account, go ahead and create a new user called “djnitehawk” with the following commands. feel free to change “djnitehawk” to whatever you like. but if you do that, you should change each and every line of code where it says “djnitehawk” throughout the tutorial.

begin by entering the following commands in the terminal:

sudo adduser djnitehawk

sudo adduser djnitehawk sudo

exit


then re-login with the new user accound added above.

Install requisites

once logged in with your new user, issue the following commands to update/upgrade the repos and install a few requisites.

sudo apt-get update
sudo apt-get upgrade

sudo apt-get install nano curl unrar software-properties-common python-software-properties python-pip

Prepare the download folders

run the following commands to setup the folder structure inside your home folder.

mkdir /home/djnitehawk/Downloads

echo "dont delete this dir" > /home/djnitehawk/Downloads/.lock

mkdir /home/djnitehawk/Downloads/MOVIES

echo "dont delete this dir" > /home/djnitehawk/Downloads/MOVIES/.lock

mkdir /home/djnitehawk/Downloads/OTHER

echo "dont delete this dir" > /home/djnitehawk/Downloads/OTHER/.lock

mkdir /home/djnitehawk/Downloads/STORAGE

echo "dont delete this dir" > /home/djnitehawk/Downloads/STORAGE/.lock

mkdir /home/djnitehawk/Downloads/TV-SHOWS

echo "dont delete this dir" > /home/djnitehawk/Downloads/TV-SHOWS/.lock

mkdir /home/djnitehawk/Downloads/RATIO

echo "dont delete this dir" > /home/djnitehawk/Downloads/RATIO/.lock

 

mkdir /home/djnitehawk/Ready

echo "dont delete this dir" > /home/djnitehawk/Ready/.lock

mkdir /home/djnitehawk/Ready/Completed

echo "dont delete this dir" > /home/djnitehawk/Ready/Completed/.lock

mkdir /home/djnitehawk/Ready/MEDIA

echo "dont delete this dir" > /home/djnitehawk/Ready/MEDIA/.lock

mkdir /home/djnitehawk/Ready/MEDIA/MOVIES

echo "dont delete this dir" > /home/djnitehawk/Ready/MEDIA/MOVIES/.lock

mkdir /home/djnitehawk/Ready/MEDIA/STORAGE

echo "dont delete this dir" > /home/djnitehawk/Ready/MEDIA/STORAGE/.lock

mkdir /home/djnitehawk/Ready/MEDIA/TV-SHOWS

echo "dont delete this dir" > /home/djnitehawk/Ready/MEDIA/TV-SHOWS/.lock

chown -R djnitehawk:djnitehawk /home/djnitehawk/Downloads

chown -R djnitehawk:djnitehawk /home/djnitehawk/Ready

chmod 777 -R /home/djnitehawk/Downloads

chmod 777 -R /home/djnitehawk/Ready

Deluge Setup

run the following commands to install and configure deluge

sudo add-apt-repository ppa:deluge-team/ppa

sudo apt-get update

sudo apt-get install deluged

mkdir ~/.config

mkdir ~/.config/deluge

cd ~/.config/deluge

nano auth


then copy and paste the following code into nano:
(change: DELUGE_PASSWORD to a strong password)

djnitehawk:DELUGE_PASSWORD:10


then press CTRL+X > Y > ENTER to save and exit nano.

configure deluge daemon by entering the following command:

nano core.conf


then copy and paste the following code into nano:

{

  "file": 1,

  "format": 1

}{

  "info_sent": 0,

  "lsd": false,

  "send_info": true,

  "move_completed_path": "",

  "enc_in_policy": 1,

  "queue_new_to_top": false,

  "ignore_limits_on_local_network": true,

  "rate_limit_ip_overhead": true,

  "daemon_port": 54321,

  "natpmp": false,

  "max_active_limit": 30,

  "utpex": false,

  "max_active_downloading": 3,

  "max_active_seeding": 30,

  "allow_remote": true,

  "max_half_open_connections": 50,

  "download_location": "/home/djnitehawk/Downloads/RATIO",

  "compact_allocation": true,

  "max_upload_speed": 30720.0,

  "cache_expiry": 60,

  "prioritize_first_last_pieces": false,

  "auto_managed": true,

  "enc_level": 2,

  "max_connections_per_second": 10,

  "dont_count_slow_torrents": false,

  "random_outgoing_ports": false,

  "max_upload_slots_per_torrent": 30,

  "new_release_check": true,

  "enc_out_policy": 1,

  "outgoing_ports": [

    12346,

    12346

  ],

  "seed_time_limit": 0,

  "cache_size": 1024,

  "share_ratio_limit": 0.0,

  "max_download_speed": 30720.0,

  "geoip_db_location": "/usr/share/GeoIP/GeoIP.dat",

  "torrentfiles_location": "",

  "stop_seed_at_ratio": false,

  "peer_tos": "0x00",

  "listen_interface": "",

  "upnp": false,

  "max_download_speed_per_torrent": -1,

  "max_upload_slots_global": -1,

  "enabled_plugins": [

    "Execute"

  ],

  "random_port": false,

  "autoadd_enable": false,

  "max_connections_global": 300,

  "enc_prefer_rc4": true,

  "listen_ports": [

    12345,

    12345

  ],

  "dht": false,

  "stop_seed_ratio": 2.0,

  "seed_time_ratio_limit": 0.0,

  "max_upload_speed_per_torrent": -1,

  "copy_torrent_file": false,

  "del_copy_torrent_file": false,

  "move_completed": false,

  "proxies": {

    "peer": {

      "username": "",

      "password": "",

      "type": 0,

      "hostname": "",

      "port": 8080

    },

    "web_seed": {

      "username": "",

      "password": "",

      "type": 0,

      "hostname": "",

      "port": 8080

    },

    "tracker": {

      "username": "",

      "password": "",

      "type": 0,

      "hostname": "",

      "port": 8080

    },

    "dht": {

      "username": "",

      "password": "",

      "type": 0,

      "hostname": "",

      "port": 8080

    }

  },

  "add_paused": false,

  "max_connections_per_torrent": 100,

  "remove_seed_at_ratio": false,

  "autoadd_location": "",

  "plugins_location": "/home/djnitehawk/.config/deluge/plugins"

}


then press CTRL+X > Y > ENTER to save and exit nano.

run the following command to setup a service for the deluge daemon so that it will run in the background across system restarts:

sudo nano /etc/systemd/system/deluged.service


copy and paste the following into nano:

[Unit]

Description=Deluge Daemon

After=network-online.target

 

[Service]

Type=simple

User=djnitehawk

Group=djnitehawk

UMask=000

 

WorkingDirectory=/home/djnitehawk/.config/deluge

ExecStart=/usr/bin/deluged -d

 

Restart=always

RestartSec=3

 

[Install]

WantedBy=multi-user.target


then press CTRL+X > Y > ENTER to save and exit nano.

sudo systemctl start deluged

sudo systemctl enable deluged

sudo systemctl status deluged


at this point, your deluge daemon should be running and ready to accept connections on your server. install the deluge thin client app on your local desktop computer and connect to your deluge daemon at port “54321”.


after connecting to your deluge daemon with the thin client, click “EDIT” > “PREFERENCES”. once the preferences window pops up, click “EXECUTE” at the bottom in the left pane. if “EXECUTE” is not there, go to “PLUGINS” first and enable “EXECUTE”.

in the “EXECUTE” section, add a new command by selecting “TORRENT COMPLETE” as the “EVENT” and enter the following as the “COMMAND”:

/home/djnitehawk/tex/tex.sh


then click “ADD” and then “OK” to save the settings.


by doing the above, we instructed deluge daemon to extract/unrar downloaded torrents. if you skip the above step, downloaded torrents will not be unrar’ed automatically. also, if you plan to use the ‘automatic download manager’ found further down this tutorial, you should definitely not skip this step. otherwise, nothing will be placed inside the “Ready” folder from which the ‘download manager’ downloads from making the ‘download manager’ useless.

note: all downloaded original content lives inside: /home/djnitehawk/Downloads/ and the extracted content lives inside: /home/djnitehawk/Ready/

Torrent Auto Extractor Setup

enter the following commands in order to setup the auto extractor script.

cd ~/
mkdir tex

sudo chmod -R 777 tex

cd tex

echo "" > tex.sh; chmod 777 tex.sh; nano tex.sh


copy and paste the following into nano:
(change: PUSHBULLET_API_ACCESS_TOKEN with your own token from here)

#! /bin/bash

 

TR_TORRENT_DIR="$3"

TR_TORRENT_NAME="$2"

 

if [[ -z "$TR_TORRENT_DIR" ]] || [[ -z "$TR_TORRENT_NAME" ]]; then

    echo "Torrent Dir or Torrent Name undefined..."

    echo "Exiting..."

    exit 0

fi

 

OLD_IFS="$IFS"

IFS=$'\n'

sleep 10s

 

MOV_DIR="/home/djnitehawk/Ready/MEDIA/MOVIES"

XXX_DIR="/home/djnitehawk/Ready/MEDIA/STORAGE"

TVS_DIR="/home/djnitehawk/Ready/MEDIA/TV-SHOWS"

ELS_DIR="/home/djnitehawk/Ready/Completed"

LOG_FILE="/home/djnitehawk/tex/tex.log"

PB_KEY="PUSHBULLET_API_ACCESS_TOKEN"

 

SRC_DIR="$TR_TORRENT_DIR/$TR_TORRENT_NAME"

TMP_DIR="$SRC_DIR/tmp"

DST_DIR="$ELS_DIR/$TR_TORRENT_NAME"

 

if [[ "$TR_TORRENT_DIR" == *RATIO* ]] ; then

    #echo " " >> "$LOG_FILE"

    #echo "Skiped: $TR_TORRENT_NAME" >> "$LOG_FILE"

    exit 0

fi

 

if [[ "$TR_TORRENT_DIR" == *MOVIES* ]] ; then

  DST_DIR="$MOV_DIR/$TR_TORRENT_NAME"

fi

 

if [[ "$TR_TORRENT_DIR" == *STORAGE* ]] ; then

  DST_DIR="$XXX_DIR/$TR_TORRENT_NAME"

fi

 

if [[ "$TR_TORRENT_DIR" == *TV-SHOWS* ]] ; then

  DST_DIR="$TVS_DIR/$TR_TORRENT_NAME"

fi

 

cd "$TR_TORRENT_DIR"

 

if [ -d "$SRC_DIR" ]; then

 

  unset RAR_FILES i

  for RAR in $(find "$SRC_DIR" -type f -iname "*.rar"); do

    if [[ "$RAR" == *.part*.rar ]]; then

      if [[ "$RAR" =~ .*part0*1.rar ]] || [[ "$RAR" =~ .*part1.rar ]]; then

        RAR_FILES[i++]="$RAR"

      fi

    else

      RAR_FILES[i++]="$RAR"

    fi

  done

 

  rm -f -R "$DST_DIR"

  mkdir "$DST_DIR"

 

  if [ ${#RAR_FILES[@]} -gt 0 ]; then

    rm -f -R "$TMP_DIR"

    mkdir "$TMP_DIR"

    find "$SRC_DIR" -type f  ! -name "*.r??" -execdir cp {} "$TMP_DIR" \;

    for RAR_FILE in "${RAR_FILES[@]}"; do

      unrar x -o+ "$RAR_FILE" "$TMP_DIR"

      if [ $? -gt 0 ]; then

        rm -f -R "$TMP_DIR"

        echo " " >> "$LOG_FILE"

        echo "Error : $TR_TORRENT_NAME failed to unrar..." >> "$LOG_FILE"

        curl --header 'Access-Token: $PB_KEY' --header 'Content-Type: application/json' --data-binary '{"body":"Failed to unrar:\n\n $TR_TORRENT_NAME","title":"[TEX] Unrar Failed","type":"note"}' --request POST https://api.pushbullet.com/v2/pushes

        IFS="$OLD_IFS"

        rm -f -R "$DST_DIR"

        exit 0

      fi

    done

    sleep 10s

    mv --target-directory="$DST_DIR" "$TMP_DIR"/*

    rm -f -R "$TMP_DIR"

    chmod 777 -R "$DST_DIR"

    #echo " " >> "$LOG_FILE"

    #echo "Unrard: $TR_TORRENT_NAME" >> "$LOG_FILE"

  else

    cp -r --target-directory="$DST_DIR" "$SRC_DIR"/*

    chmod 777 -R "$DST_DIR"

    #echo " " >> "$LOG_FILE"

    #echo "Copied: $TR_TORRENT_NAME" >> "$LOG_FILE"

  fi

 

  find "$DST_DIR" -type f \( -name "*sample*.avi" -o -name "*sample*.mp4" -o -name "*sample*.mkv" \) -delete

fi

 

if [ -f "$SRC_DIR" ]; then

    cp --remove-destination "$SRC_DIR" "$DST_DIR"

    chmod 777 "$DST_DIR"

    #echo " " >> "$LOG_FILE"

    #echo "Copied: $TR_TORRENT_NAME" >> "$LOG_FILE"

fi

 

IFS="$OLD_IFS"

exit 0


then press CTRL+X > Y > ENTER to save and exit nano.

Flexget Setup

run the following commands to install and configure flexget.

cd ~/

sudo –H pip install --upgrade pip

sudo -H pip install flexget

sudo mkdir .flexget; sudo chown -R djnitehawk:djnitehawk .flexget; sudo chmod -R 777 .flexget; cd .flexget

echo "" > config.yml; sudo chmod 777 config.yml; nano config.yml


then copy and paste the following code into nano:
(change DELUGE_PASSWORD, PUSHBULLET_API_ACCESS_TOKEN, AN_RSS_FEED_OF_TORRENTS, A_BACKUP_RSS_FEED_OF_TORRENTS, TRAKT_USERNAME, IMDB_USER_ID with your info)

schedules:

  - tasks: [TV-SHOWS,MOVIES]

    interval:

      minutes: 15

  - tasks: [IMPORT-MOVIES]

    interval:

      minutes: 120   

 

templates:

  global:

    retry_failed:

      retry_time: 5 minutes

      retry_time_multiplier: 1

      max_retries: 12

  tv:

    deluge:

      host: localhost

      port: 54321

      username: djnitehawk

      password: DELUGE_PASSWORD

      path: /home/djnitehawk/Downloads/TV-SHOWS

    configure_series:

      settings:

        quality: webdl|hdtv|webrip h264 720p

        propers: no

      from:

        trakt_list:

          username: TRAKT_USERNAME

          list: watchlist

          type: shows

          strip_dates: yes

    regexp:

      from: title

      reject:

        - msd

        - afg

        - line

    content_size:

      min: 300

      max: 4000

      strict: no

    notify:

      entries:

        title: "[F] {{series_name}} {{series_id}}"

        message: "{{title}}\n\nSize: {{content_size}}MB"

        what: accepted

        via:

          - pushbullet:

              api_key: PUSHBULLET_API_ACCESS_TOKEN

    inputs:

      - rss:

          url: AN_RSS_FEED_OF_TORRENTS

          all_entries: no

      - rss:

          url: A_BACKUP_RSS_FEED_OF_TORRENTS

          all_entries: no

 

  movie:

    deluge:

      host: localhost

      port: 54321

      username: djnitehawk

      password: DELUGE_PASSWORD

      path: /home/djnitehawk/Downloads/MOVIES

    quality: bluray h264 720p|1080p

    imdb_lookup: yes

    list_match:

      from:

        - movie_list: mymovies

    regexp:

      from: title

      reject:

        - msd

        - afg

        - line

        - hc

        - korsub

    content_size:

      min: 3000

      max: 10000

      strict: no

    notify:

      entries:

        title: "[F] {{imdb_name}}"

        message: "{{title}}\n\n{{imdb_url}}\n\nSize: {{content_size}}MB"

        what: accepted

        via:

          - pushbullet:

              api_key: PUSHBULLET_API_ACCESS_TOKEN

    inputs:

      - rss:

          url: AN_RSS_FEED_OF_TORRENTS

          all_entries: no

      - rss:

          url: A_BACKUP_RSS_FEED_OF_TORRENTS

          all_entries: no

 

tasks:

  TV-SHOWS:

    template: tv

    priority: 1

   

  IMPORT-MOVIES:

    imdb_watchlist:

      user_id: IMDB_USER_ID #will be in the form of ur12345678

      list: watchlist

    accept_all: yes

    list_add:

      - movie_list: mymovies

    priority: 2

 

  MOVIES:

    template: movie

    priority: 3


then press CTRL+X > Y > ENTER to save and exit nano.

now, check the validity of your flexget config file by running the following command:

flexget check


if the last line says: “Config passed check.” then you’re ready to proceed. if not, go back and check your work.

then run the following commands to setup the flexget service so that flexget will run as a service/daemon, even across system restarts.

sudo nano /etc/systemd/system/flexget.service


then copy and paste the following code into nano:

[Unit]

Description=Flexget Daemon

After=network-online.target

 

[Service]

Type=simple

User=djnitehawk

Group=djnitehawk

UMask=000

 

WorkingDirectory=/home/djnitehawk/.flexget

ExecStart=/usr/local/bin/flexget daemon start

ExecStop=/usr/local/bin/flexget daemon stop

ExecReload=/usr/local/bin/flexget daemon reload

 

Restart=always

RestartSec=3

 

[Install]

WantedBy=multi-user.target


then press CTRL+X > Y > ENTER to save and exit nano.

sudo systemctl start flexget

sudo systemctl enable flexget

sudo systemctl status flexget


if all went well, flexget is now running as a background service and will download matching torrents and send them to deluge deamon. you can check and manage the torrents that have been added to deluge daemon by connecting to it with the desktop thin client as previously mentioned.

you can check what flexget has been doing in the background by looking at the log file with the following command:

cat ~/.flexget/flexget.log | more

Automated Download Manager Setup

if you have a linux machine on your local/home network, you can use the following procedure to setup an automated download manager that will download what has been extracted/copied out to /home/djnitehawk/Ready/ folder. when you get a pushbullet notification, you can simply turn on your local linux computer and let the download manager download all the files/folders inside your server’s “Ready” folder and delete the respective files/folders automatically from the “Ready” folder once they have been successfully downloaded to your local computer. the original content inside /home/djnitehawk/Downloads/ will never be automatically deleted which enables you to keep seeding them for as long as you like. once you’re done seeding, simply right click on the torrent name(s) using the deluge thin client and select “REMOVE TORRENT” > “REMOVE WITH DATA” in order to reclaim the disk space taken up by the downladed original content.

Setup the seedbox/vps/remote server

enter the following commands on the remote server to enable it to serve files from the “Ready” folder.

sudo apt-get install lighttpd php7.0-cgi

sudo lighty-enable-mod fastcgi-php

sudo lighty-enable-mod auth
sudo rm /etc/lighttpd/conf-enabled/05-auth.conf

sudo nano /etc/lighttpd/conf-enabled/05-auth.conf


then copy and paste the following code into nano:

server.modules += ( "mod_auth" )

  auth.debug = 0

  auth.backend = "plain"

  auth.backend.plain.userfile = "/etc/lighttpd/pass.txt"

  auth.require = ( "/" => (

    "method" => "basic",

    "realm" => "/",

    "require" => "user=djnitehawk"))


then press CTRL+X > Y > ENTER to save and exit nano.

sudo rm /etc/lighttpd/lighttpd.conf

sudo nano /etc/lighttpd/lighttpd.conf


then copy and paste the following code into nano:

server.document-root        = "/home/djnitehawk/Ready"

server.dir-listing          = "disable"

server.errorlog             = "/var/log/lighttpd/error.log"

server.pid-file             = "/var/run/lighttpd.pid"

server.username             = "www-data"

server.groupname            = "www-data"

server.port                 = 80

index-file.names            = ("index.php")

include_shell "/usr/share/lighttpd/create-mime.assign.pl"

include_shell "/usr/share/lighttpd/include-conf-enabled.pl"


then press CTRL+X > Y > ENTER to save and exit nano.

sudo nano /etc/lighttpd/pass.txt


then copy and paste the following code into nano:
(change: WEB_SERVER_PASSWORD with a strong password)

djnitehawk:WEB_SERVER_PASSWORD


then press CTRL+X > Y > ENTER to save and exit nano.

sudo chmod 777 /etc/lighttpd/pass.txt

sudo openssl req -new -x509 -keyout server.pem -out server.pem -days  36500 -nodes


just hit ENTER through all the prompts.

sudo chmod 777 server.pem

sudo mv server.pem /etc/lighttpd/

sudo lighty-enable-mod ssl
nano ~/Ready/index.php


then copy and paste the following code into nano:

<?php

 

$src = "/home/djnitehawk/Ready";

 

$del = $_GET['delete'];

$clean = $_GET['clean'];

 

if (!empty($del)){

    $file = "$src$del";

    unlink($file);

    echo "File Deleted: $file";

    exit;

}

 

if (!empty($clean)){

    if ($clean == 'yes') {

        RemoveEmptySubFolders($src);

        echo "Empty folders have been cleaned...";

    }

    exit;

}

 

$res = ListIn($src, "$src/");

echo implode('|',$res);

 

function RemoveEmptySubFolders($path)

{

  $empty=true;

  foreach (glob($path.DIRECTORY_SEPARATOR."*") as $file)

  {

     $empty &= is_dir($file) && RemoveEmptySubFolders($file);

  }

  return $empty && rmdir($path);

}

 

function ListIn($dir, $prefix) {

  $dir = rtrim($dir, '\\/');

  $result = array();

 

    foreach (scandir($dir) as $f) {

      if ($f !== '.' and $f !== '..' and $f !== '.lock' and $f !== 'index.php') {

        if (is_dir("$dir/$f")) {

          $result = array_merge($result, ListIn("$dir/$f", "$prefix$f/"));

        } else {

          $result[] = $prefix.$f;

        }

      }

    }

 

  return $result;

}

 

?>


then press CTRL+X > Y > ENTER to save and exit nano.

chmod 777 ~/Ready/index.php

sudo systemctl restart lighttpd


Setup the local linux computer

enter the following commands on the local machine where you would like to setup the auto download manager.

cd ~/

sudo apt-get update

sudo apt-get install aria2 curl screen

nano ./downer


then copy and paste the following code into nano:
(change: FOLDER_TO_DOWNLOAD_INTO, REMOTE_SERVER_ADDRESS, WEB_SERVER_PASSWORD with your info)

#!/bin/bash

 

clear

 

SRC_DIR="/home/djnitehawk/Ready"

DST_DIR="/FOLDER_TO_DOWNLOAD_INTO"

HTTP="https://REMOTE_SERVER_ADDRESS"

USR="djnitehawk"

PASS="WEB_SERVER_PASSWORD"

 

SHUTDOWN="no"

BW="0"

LIST="no"

 

if [ -n "$1" ]; then

    if [ "$1" == "list" ]; then

        LIST="yes"

    elif [ "$1" == "shut" ]; then

        SHUTDOWN="yes"

        SHUTMODE="\e[101m>>> IN SHUT DOWN MODE <<<\e[0m"

    elif [ $1 -gt 0 ]; then

        BW="${1}K"

    fi

fi

 

trap 'chmod 777 -R $DST_DIR;echo "Exiting...";exit;' SIGTERM SIGINT

 

shutcomputer(){

    echo " "

    echo "Shutting down computer in 1 min..."

    echo " "

    echo "CTRL+C to abort shutdown!"

    echo " "

    sleep 60s

    /usr/bin/shut

    exit

}

 

download(){

    echo " "

    echo "Getting a list of files to download from server..."

    echo " "

 

    false

    while [ $? -ne 0 ]; do

        RES=$(wget --timeout=60 --waitretry=10 --tries=10 --no-check-certificate --user=$USR --password=$PASS -q -O - $HTTP)

        if [ $? -ne 0 ]; then

          echo "Unable to contact server, retrying in 1 minute..."

          echo " "    

          sleep 60

          false

        else

          true

        fi

    done

 

    OLDIFS="$IFS"

        IFS='|' read -a LST <<< "$RES"

    IFS="$OLDIFS"

 

    unset i

    for F in "${LST[@]}";do

        F=${F/$SRC_DIR/$HTTP}

        LST[i++]="$F"

    done

 

    if [ ${#LST[@]} -eq 0 ]; then

 

        echo " "

        echo " "

        echo " "

        echo "No files to download on server..."

        if [ $SHUTDOWN == "yes" ]; then

            shutcomputer

        else

            echo "Press any key to exit..."

            read sdlkdjf

            exit 0

        fi

    fi

 

    if [ $LIST == "yes" ]; then

        clear

        echo " "

        echo "The list of files to be downloaded from the server:"

        echo "==================================================="

                unset i

        for FL in "${LST[@]}";do

            FL=${FL/$HTTP/}

            MD="/MEDIA/"

            FL=${FL/$MD/}

            FL=$(dirname "$FL")

            GET_LST[i++]="$FL"

        done

        printf '\v\t%s\n' "${GET_LST[@]}" | sort -u

        echo " "

        read dfhs

        exit 0

    fi

 

    false

 

    while [ $? -ne 0 ]; do

        ALL_OK=false

        c=1

        for FILE in "${LST[@]}";do

 

            DEST=${FILE/$HTTP/$DST_DIR}

            DEST=${DEST/"MEDIA/"/""} #mod for removing /MEDIA from destination path

            DEST=$(dirname "$DEST")

            echo " "

            echo " "

            echo -e "Downloading file $c of ${#LST[@]}... ${SHUTMODE}"

            echo " "

            echo "File: $FILE"

            echo " "

            echo " "

            echo " "

            aria2c -d "$DEST" -c -k 1M -s 16 -x 16 -m 60 --retry-wait=60 --max-overall-download-limit=$BW --summary-interval=0 --check-certificate=false --http-user=$USR --http-passwd=$PASS "$FILE"

            if [ $? -ne 0 ]; then

                echo " "

                echo " "

                echo "Error: Something went wrong. Gonna retry..."

                echo " "

                TIME=$(date +%R)

                echo " " >> downer.log

                echo "$TIME - Failed: $FILE" >> downer.log

                break

            else

                ALL_OK=true

                echo " "

                echo " "

                echo "File downloaded fine. Deleting from server now..."

                echo " "

                DEL=${FILE/$HTTP\//}

                DEL_URL="$HTTP/?delete=/$DEL"

                echo " "

                wget --timeout=60 --waitretry=10 --tries=10 --no-check-certificate --user=$USR --password=$PASS -q -O - "$DEL_URL"

                echo " "

                echo " "

            fi

            c=$(($c+1))

        done

        if $ALL_OK ; then

            echo " "

            echo "Cleaning up empty folders from server. Please wait..."

            echo " "

            CLEAN="$HTTP/?clean=yes"

            wget --timeout=60 --waitretry=10 --tries=10 --no-check-certificate --user=$USR --password=$PASS -q -O - $CLEAN

            echo " "

            echo " "

            echo " "

            echo "Files from this batch downloaded and empty folders cleaned from server."

            echo " "

            echo "Checking for new files on server..."

            chmod 777 -R $DST_DIR

            true

        else

            false

        fi

    done

    download

}

download


then press CTRL+X > Y > ENTER to save and exit nano.

chmod +x downer


if there were no issues with the work done so far, you are now ready to initiate the automated downloading from your remote server by issueing the following command on your local machine:

./downer


you can see a list of the folders available for downloading on the remote server by using the following command:

./downer list


download bandwidth can be limited by specifying a value in KB/s as follows:

./downer 1024


if you’d like for the download manager to keep downloading files in the background so that you can close the terminal session, you can use as follows:

screen -R x ./downer


you can then re-attach to the download manager session at any time by using:

screen -R x


that’s it…
your torrenting has now been automated…

flexget and deluge will now keep an eye out 24x7 and download the movies you have added to your imdb watchlist; as well as new episodes of the tv shows you have watchlisted on trakt as they become available on the torrent trackers you have setup above.

Feedback/ Help

if you have any feedback or require some explanation of what something in this tutorial does, please send me a message via my fb page: https://fb.me/dj.nitehawk.official and i’ll try my best to reply in a timely manner.

Seedbox/ VPS Recommendation

if you’re in the market for a good VPS provider for setting up a torrent/seed box, I can highly recommend RamNode. I’ve been using them for over 6 years now and couldn’t be happier. if you’d like to give them a try, please sign up using my affiliate link: https://clientarea.ramnode.com/aff.php?aff=1682 as a token of your appreciation :-)