2016-01-23

Synopsis: This guide will detail how to configure your server and personal computer to promote the automation of downloads using Internet Download Manager. For those who suffer terrible speeds with FTP, this guide will be a godsend.

Summary of how it works: An email is sent to your email address each time a download is completed. Outlook receives the email and launches a macro to download the file(s).

Prerequisites:

1. Seedbox with root access

2. Rutorrent/rtorrent

3. Autotools rutorrent plugin

4. Apache Web Server

5. Internet Download Manager

6. Microsoft Outlook

7. Internet browser - preferably not your main browser (I'm using firefox)

8. A macro creation program. I recommend: http://www.softpedia.com/get/PORTABL...Portable.shtml

This guide is comprised of the following sections:

Section 1: Autotools configuration

Section 2: Email configuration

Section 3: Free domain name configuration

Section 4: IDM configuration

Section 5: Macro creation

Section 6: Batch creation

Section 7: Outlook configuration

Section 1: Autotools Configuration

Navigate to your autools settings within rutorrent and enable "automove if torrent's label matches".

Change the operation type to: Move

Check "add torrent's label to path"

See my settings in the spoiler.

Spoiler Alert!



In your terminal type the following lines:

Code:

cd /var/www/rutorrent/plugins/autotools

touch queue.sh

chmod +x queue.sh

sudo chmod +x check.php

Now edit check.php by typing the following command:

Code:

sudo nano check.php

Copy and paste the code below to the begining of the file (below <?php):

Code:

$linecount = count(file("queue.sh")) - 1;

if ($linecount != 0) {

$fh = fopen("queue.sh", 'a');

$string = "sleep 125 && sed -i '1d' queue.sh\n";

fwrite($fh, $string);

fclose($fh);

$outcome = shell_exec("sh /var/www/rutorrent/plugins/autotools/queue.sh > /dev/null 2>&1 &");

} else {

sleep (125);

$fh = fopen("queue.sh", 'a');

$string = "sleep 125 && sed -i '1d' queue.sh\n";

fwrite($fh, $string);

fclose($fh);

$outcome = shell_exec("sh /var/www/rutorrent/plugins/autotools/queue.sh > /dev/null 2>&1 &");

}

Section 2: Email Configuration

I suggest creating a throwaway gmail account as your password will be saved on your server.

We need to install and configure the mutt email client. To proceed, type the following in your terminal:

Code:

sudo apt-get install mutt

Create the following directories/files by typing the following lines in your terminal:

Code:

mkdir -p ~/.mutt/cache/headers

mkdir ~/.mutt/cache/bodies

touch ~/.mutt/certificates

touch ~/.mutt/muttrc

Open muttrc by typing the following in your terminal:

Code:

nano ~/.mutt/muttrc

Copy and paste the following into muttrc, ensuring that you edit the fields to match your particulars.

All yellow font must be changed to reflect your own details.

Code:

set ssl_starttls=yes

set ssl_force_tls=yes

set imap_user = 'youremail@gmail.com'

set imap_pass = 'yourpassword'

set from='youremail@gmail.com'

set realname='rTorrent'

set folder = imaps://imap.gmail.com/

set spoolfile = imaps://imap.gmail.com/INBOX

set postponed="imaps://imap.gmail.com/[Gmail]/Drafts"

set header_cache = "~/.mutt/cache/headers"

set message_cachedir = "~/.mutt/cache/bodies"

set certificate_file = "~/.mutt/certificates"

set smtp_url = 'smtps://youremail@gmail.com:password@smtp.gmail.com:465/'

set move = no

set imap_keepalive = 900

To test that you have configured mutt correctly, type the following in your terminal:

Code:

echo "This is a test" | mutt -s "Test email" youremail@gmail.com

If successful, lets move on. Type the following in your terminal:

Code:

cd ~/rtorrent

touch rtorrent_idm.sh

chmod +x rtorrent_idm.sh

Now open rtorrent_idm.sh by typing the following:

Code:

nano rtorrent_idm.sh

And paste the following code:

Orange text represents text you must change if you're using different named labels to mine.

Yellow text represents text that require modification.

Code:

#!/bin/bash

if [[ "$1" =~ "/sync" ]]

then

echo "Synchronizing"

else

exit

fi

if [[ -f "$1/$2" ]] && [[ "$1" =~ "/sync_movies" ]]

then

echo "Movie File"

touch -am "$1/$2"

echo "Sync initiated." | mutt -s "Syncing Movie File: $2" youremail@gmail.com

exit

fi

if [[ -f "$1/$2" ]] && [[ "$1" =~ "/sync_tv" ]]

then

echo "TV File"

touch -am "$1/$2"

echo "Sync initiated." | mutt -s "Syncing TV File: $2" youremail@gmail.com

exit

fi

if [[ -d "$1" ]] && [[ "$1" =~ "/sync_movies" ]]

then

echo "Movie Folder"

touch -am "$1/$2"

echo "Sync initiated." | mutt -s "Syncing Movie Folder: $2" youremail@gmail.com

exit

fi

if [[ -d "$1" ]] && [[ "$1" =~ "/sync_tv" ]]

then

echo "TV Folder"

touch -am "$1/$2"

echo "Sync initiated." | mutt -s "Syncing TV Folder: $2" youremail@gmail.com

exit

fi

Edit your rtorrent.rc by typing the following in your terminal:

Code:

nano ~/.rtorrent.rc

Copy and paste the following at the beginning of the file:

Yellow text - modify to reflect your own path

Code:

system.method.set_key = event.download.finished,move_complete,"execute=/home/user/rtorrent/rtorrent_idm.sh,$d.get_directory=,$d.get_name="

Restart rtorrent

Section 3: Free Domain Name Configuration

It is essential to create a domain for each folder that you want your downloads from your server saved to.

Example: If you want to have movies downloaded to a movie folder and TV shows downloaded to a TV folder, you will need to create 2 domains.

Go to Freenom.com to secure your free domain(s). See spoiler if you're uncertain of what settings to select & adjust.

Spoiler Alert!



Once you have created your domain(s), you need to edit your apache configuration file.

Type the following in your linux terminal. I am using Ubuntu 14, if you're using a different distro, your config file may be in a different location. Use google to locate it if the code below doesn't work.

Code:

sudo nano /etc/apache2/sites-available/000-default.conf

Now you need to input the following code for each domain name you have. So if you created 2 domains you need to edit the below code and paste it twice.

Paste the code at the beginning of your configuration file.

Yellow text is what needs to be changed.

Code:

<VirtualHost *:80>

ServerAdmin webmaster@localhost

ServerName myfirstdomain.tk

ServerAlias www.myfirstdomain.tk

DocumentRoot /var/www

<Directory />

Options FollowSymLinks

AllowOverride None

</Directory>

<Directory /var/www/>

Options Indexes FollowSymLinks MultiViews

AllowOverride None

Order allow,deny

allow from all

</Directory>

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

<Directory "/usr/lib/cgi-bin">

AllowOverride None

Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch

Order allow,deny

Allow from all

</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log

# Possible values include: debug, info, notice, warn, error, crit,

# alert, emerg.

LogLevel warn

CustomLog ${APACHE_LOG_DIR}/access.log combined

<Location /rutorrent>

AuthType Digest

AuthName "rutorrent"

AuthDigestProvider file

AuthUserFile /etc/apache2/htpasswd

Require valid-user

SetEnv R_ENV "/var/www/rutorrent"

Options -Indexes

</Location>

</VirtualHost>

For your changes to come into being, type the following in your terminal:

Code:

sudo service apache restart

Section 5: IDM Configuration

1.Navigate to your IDM options.

2. Once the window appears click on the "Save to" tab.

3.Create a new category for each domain you created. Refer to my screenshot in the spoiler to see how I set mine up.

Spoiler Alert!



I also recommend changing your settings in the "Downloads" tab to reflect mine. This will prevent the macro from being interrupted.

Spoiler Alert!

Section 6: Macro Creation

I recommend using a freeware program called Pulover's Macro Creator. A portable version can be downloaded from:

http://www.softpedia.com/get/PORTABL...Portable.shtml

You will need to create two macros, one for folders and one for files.

If you'd rather modify my macros instead of creating your own, you can download them from here:

http://www.filedropper.com/macrofile
http://www.filedropper.com/macrofolder

You need to begin the macro from your servers download page with the login prompt in sight. See the spoiler for a screenshot of what I mean.

Spoiler Alert!

Here are screenshots of my folder and file macros:

Spoiler Alert!

File macro:

Folder macro:

The process for the file macro is as followed:

1. Enter - to pass the login screen

2. Tab 6 times to highlight the file

3. Enter to select the file and begin downloading.

The folder process is a bit more complicated, it involves:

1. Repeating the above process twice

2. Shift+F10 (simulates a right click) to open the context menu

3. A few tab presses to highlight "Download all links with IDM"

4. Enter to select

5.Tab 6 times to highlight the "Check all" button

6. Enter to select

7. Tab 2 times to highlight "OK"

8. Enter to select

9. Tab 5 times to highlight "OK"

10. Enter to select & begin downloading.

Important note: Ensure that "Start queue processing" & "Hide HTML files" are checked. You only need to select these once as IDM will remember your choice in the future. So don't include performing these selections in your macro. Refer to the spoiler below if you can't locate these buttons.

Spoiler Alert!

After you have created your macro, with Macro Creator open, click on file (top left of the window) and select export to AHK. When the new window prompts, you need to delete the F3 underneath play then you may click export.

We need to covert the AHK file(s) to exe. To do this download Ahk2Exe from here:

https://autohotkey.com/download/ahk2exe.zip

The process is straightforward. Open the application and convert.

Step 7: Batch Creation

You will need to create two batch scripts per label/domain.

Example: I have two labels one named sync_movies & one named sync_tv. I must create 4 batch scripts. 2 for folder & file macros for sync_movies. Another 2 for folder & file macros for sync_tv.

Open notepad and paste the following

Ensure you leave /?C=M;O=D at the end of your domain name(s)

Yellow text must be modified

Orange text must be modified if you're not using firefox.

Code:

start firefox https://yourdomain.tk/yourdirectory/?C=M;O=D

"C:\point this to where your macro is located/macrofile.exe"

taskkill /f /im firefox.exe

Save it as something.bat

My four batch examples in case you're lost:

Spoiler Alert!

For TV files:

Code:

start firefox https://tvdownload.tk/downloads/completed/sync_tv/?C=M;O=D

"C:\Users/Administrator/Desktop/AUTOMATED/macrofile.exe"

taskkill /f /im firefox.exe

For TV folders:

Code:

start firefox https://tvdownload.tk/downloads/completed/sync_tv/?C=M;O=D

"C:\Users/Administrator/Desktop/AUTOMATED/macrofolder.exe"

taskkill /f /im firefox.exe

For Movie files:

Code:

start firefox https://moviedownload.tk/downloads/completed/sync_movies/?C=M;O=D

"C:\Users/Administrator/Desktop/AUTOMATED/macrofile.exe"

taskkill /f /im firefox.exe

For Movie folders:

Code:

start firefox https://moviedownload.tk/downloads/completed/sync_movies/?C=M;O=D

"C:\Users/Administrator/Desktop/AUTOMATED/macrofolder.exe"

taskkill /f /im firefox.exe

Section 7: Outlook Configuration

Link your throwaway gmail with outlook.

You need to add rules. To do this click the rules button (located in the home table for 2013 users). Refer to the spoiler.

Spoiler Alert!

You need to define 2 rules for each label, one for folders and another for files. Refer to my screenshots.

Step 1: Condition - enable "with specific words in the subject". Insert the appropriate phrase. Refer to my screenshots below.

Step 2: Action selection - enable "start application" and select your appropriate batch script.

Step 3: Turn on the rule.

Spoiler Alert!

The final step is to make outlook update its send/receive process every minute. To do this click on the file tab (top left) and then click options on the left hand side. Select advanced on the left hand side. Scroll down and click on send/receive. Change "schedule an automatic send/receive" to 1 minute. Refer to my screenshots if this is troubling.

Spoiler Alert!

Show more