- This is for educational purposes only. Do everything at your own risk. Using bit torrent is not illegal, but downloading copyrighted materials are.
- Do not use this in a production environment. We are considering zero security in this case.
I see that this post gets a lot of attention. If this works/doesn’t work please let me know in the comment section, or email me at email@example.com.
What we are going to build:
An always on torrent box that periodically checks for new torrents as defined and download them.
What we will be using:
• Raspberry pi 3 model b with Raspbian Jessie installed.
• Official raspberry pi 3 PSU as third party PSU’s may not provide enough power
• External HDD
• USB fan or heatsink (Recommended, not necessary)
my current setup
• You have vnc / physical access with GUI to your pi
• You have a user named pi with sudo access (this available by default)
• You know the password of user pi
Note: We will be doing most of the configurations in a terminal.
1) Install and enable apache webserver
This will help to access the contents over a webserver. Install it by typing
sudo apt-get install apache2
Once installed, start and enable it
sudo systemctl enable apache2
sudo systemctl start apache2
Give everyone full permission to the documentroot. [This is not safe at all in a production environment.]
sudo chmod 777 /var/www/html
2) Connect the hard disk, create mountpoint and setup automount
• Connect your hard disk to the pi. Make sure that it works by accessing the contents. If you see a lightning bolt symbol on the top right corner of the screen, that means the pi is not getting enough power to work properly. Use the official PSU in this case.
• Open a terminal, and see where the hard disk is mounted, by using the following command
In this case, it is mounted in /var/www/html. This will not be your case. It will probably in something like /media/pi/xxx . Whatever it is take note of it. Let us call this value as initial_mount_point
• Get the block id of the hard disk. Take note of the value starting from UUID
• Configure fstab so that the hard disk will mount to a certain point after reboot
• This will open the fstab file in nano text editor in the terminal. Navigate to the end of the line, and type the following
UUID=”xxxxxxxx” /var/www/html ntfs defaults 0 0
Where “xxxxx” is the block id that you got from the previous step.
Type CTRL+O to save and CTRL+X to exit the editor.
• Unmount the hard disk from initial mount point
sudo umount initial_mount_point
where initial_mount_point is what you got from the first step, which is something like /media/pi/xxxx • Now mount the hard disk to the new mount point.
• Verify that it worked by typing the df command. You should get output like this.
3) Install and configure flexget
Felxget will be the tool that we use to download torrent files based on our preferences. The following information is from their website.(https://www.flexget.com/InstallWizard/Linux)
FlexGet requires Python 2.7, 3.3 or newer to run. You can check your version with command.
If it is not available, install it by using the following command in terminal
sudo apt-get install python3.5
Second piece of required software is python package manager called PIP. This can be usually found from operating system package repository under name python-pip or python3-pip. If you install python3-pip it may need to be used via command pip-3.5 or something similar.
Install it by using the following command
sudo apt-get install python-pip5
• Upgrade setuptools
Using latest setuptools will save headaches in some older installations, this can be achieved with
sudo pip install --upgrade setuptools
• Install in a virtualenv
This is the recommended way unless you want multiple accounts in the system to be able to use FlexGet without each having to install it themselves.
sudo pip install virtualenv
Create Virtualenv: This creates isolated python environment. You can create as many of these as you like for each python application you use.
Install FlexGet in the virtualenv:
bin/pip install flexget
Create a folder to save the torrent files that are downloaded.
sudo mkdir /home/torrents
sudo chmod 777 /home/torrents
• Configure flexget to download torrents automatically
This is the most important and confusing part. Here I am sharing only what I did and found to be working. You can find many other configurations from here and here.
We will configure only to download new Malayalam movies published in extratorrent.cc , English movies published in yts.ag and new episodes of Sherlock from anywhere.
To do that,
Navigate to the install directory
Create a configuration file using nano editor
Type the following:
Download english movies:
IMPORTANT: DO NOT USE TABS, INSTEAD USE SPACES. WATCH THE ABOVE VIDEO AND READ THROUGH THE SITE FOR MORE INFO ON HOW TO FILL THIS FILE
CTRL+O and CTRL+X to save and exit
Instead of typing the above, you may download my config file from here.
• Test the configuration
Navigate to the flexget install folder and make it executable
sudo chmod +x flexget
Test the configuration by following command:
If your output is similar to the following, there is something wrong with your config.
If everything is OK, you will get something like this:
Now let us execute flexget to download the torrent files.
This will download the torrent files to the folder we created earlier, to /home/torrents. Let us verify
There will be a lot of .torrent files. Mine has that .added name because all of them are already completed downloading.
4) Install and configure transmission to download the files using the torrent files already downloaded.
sudo apt-get install transmission-gtk
Open transmission from the start menu
Go to edit-preferences, Set the speed limits you want from Speed tab
In the downloading tab,
In automatically add .torrent files from, select /home/torrents folder Untick show the Torrent Options Dialog Tick Start added torrents In Save to Location, navigate to your hard disk mount point, which is /var/www/html and select the folder you want.
You can leave the other settings as it is, or change it if you need. Now wait a few minutes and you can see that the torrents start downloading.
5) Configure flexget to check for torrents periodically
We will setup flexget to check for new torrents every hour and download it if found. For that, we will use crontab, which is pre installed in the system.
Open crontab by following command:
This will open the crontab file in a text editor. Navigate to the end and add the following lines:
# to run flexget without generating log files
20 * * * * /home/pi/flexget/bin/./flexget execute
# start transmission-gtk version minimized if it is not already running
*/30 * * * * export DISPLAY=:0 && if pidof -x /usr/bin/transmission-gtk; then exit; else /usr/bin/transmission-gtk -m; fi &
CTRL+O and CTRL+X to save and exit
By now, you have your pi configured to check for new torrents every hour and download it to the hard disk connected to it. In the following steps, we will make it accessible via a web browser or as a network drive.
6) Configure a static ip address to the pi
sudo nano /etc/dhcpcd.conf
Go to the end of the file and add the following:
Here, you need edit based on your needs. My router address is 192.168.1.1 and I set my ip to be 192.168.1.200.
7) Configure apache web server.
We will use the default configuration settings here. To verify it,
sudo nano /etc/apache2/sites-enabled/000-default.conf
Just make sure that the DocumentRoot is set to be /var/www/html. If it is not, edit it. Mostly there is no need to edit.
Restart the web server
sudo systemctl restart apache2
Verify that it works by going to the webpage from a browser. Note that this device should be connected to your home network. You should be able to access the hard disk contents now.
You will be able to watch videos from your browser.
8) Install and configure samba for using as a network drive
sudo apt-get install samba
sudo nano /etc/samba/smb.conf
This will open samba configuration file in nano. Go to the end of the file and type the following, and save and exit.
path = /var/www/html/
public = yes
read only = yes
guest ok = yes
browseable = yes
Enable and restart samba.
sudo systemctl enable smbd
sudo systemctl restart smbd
Now you can map this as a network drive in your windows PC. To do this in windows 10, right click My PC, then click Map network drive.
Enter the ip address and share name as follows. Share name is movies as we configured earlier. Check connect using different credentials. Enter username as pi and the password to connect.
You should have it connected as a drive now.