Download torrent file with google colab with 2 lines of code

Have you ever thought of downloading a Torrent and saving it directly to Google Drive? I found one trick to do this using Google Colab and you will be able with 2 lines of code.

First open Google Colab and click ‘New Python 3 Notebook’. If you have ever used Jupyter Notebook you know what to do.
Open Runtime and change runtime type to GPU ( be sure that you are using Python 3).

image

after this you look at the right and press connect, choose hosted runtime

image

wait until ok

image

Go to left side bar and choose Files in menu and MOUNT DRIVE
Execute that script and you will get the link to auth your account. Click the link, select your account that you want to use as a google drive storage. Allow the permission and you will get the code to auth your Gdrive. Copy the code, back to your Notebook, paste the code in the box under the sentence ‘Enter your authorization code:’, then click enter.

image

If is ok you will see you will see your drive in the sidebar by expand ‘drive’ folder

Now install transmission-cli and you can download torrent with command line using transmission-cli. If you often use Linux and prefer to use other programs besides transmission-cli, go for it. Install transmission-cli by executing this command in block code.

line of code
!apt-get install transmission-cli

wait install complete

Now you are able to start your torrent download
Let’s see, ‘/content/drive/My Drive’ is your root Gdrive folder. If you want to download the file to subfolder, just add the name of the subfolder at the end.

Here is how to download torrent use this code and your torrent link

!transmission-cli -w ‘/content/drive/My Drive’ https://the place with torrent.any/download/name of file.torrent

Wait until your file is downloaded and you will see the file in your drive.

ps: you can change the location whre you will put the file, and you also can use magnet link

Very easy and also very fast

34 Likes

I would be grateful if you could show me the screenshot of an example through this code.

Hi, @jmpinto
I have tried this and it gives me an error saying that
transmission-cli 2.92 (14714) [2020-03-14 07:09:19.202] Couldn't create "/content/drive/Shared Drives": Operation not supported Unable to create download directory "/content/drive/Shared Drives/1st GDrive/Movies/3DBuzz": Operation not supported

You need to see how the Shared drive apears in the right side of the screen

Hi, can you please make a video demo for this? It will be very helpful.

2 Likes

Yes please!

Hello @jmpinto but how do you get 358 GB on google collab as I am only getting 68GB

Hi
Ok This I can help
When you call Google Colab, you have Runtime up, ok?
So you can go and press your mouse in it that will open some options, has one that says: Change Runtime type, when you get in this option you will see that you will open a window and there you need to put Python 3 and than in hadware acelarator you put GPU, and this is all that you need.

Hi,
First I do not have all this time, second I do not have an util to do that.
But this is simple thing, and I just saw it at internet and also I tryed and works, just read and look at the pictures an try you will be able as I was.

1 Like

@jmpinto I have already selected the gpu as the hardware accelerator with python 3 and I am still getting only 68GB

By any chance are you using colab pro?

1 Like

I will check and let me see if I can discover what happens
Tham I will post here

Nope,
I think that maybe Google made changes in what they are offering theses days, since has more than 6 months that I do not work with it.
Anyway later today I will check this

@NAehs_justn don’t connect to GPU and you will get about 108 GB.

I had uploaded and downloaded torrent using this trick

> https://colab.research.google.com/github/FKLC/Torrent-To-Google-Drive-Downloader/blob/master/Torrent_To_Google_Drive_Downloader.ipynb

It is similar to this only just run the code nd u got it

Also u can download torrent using .torrent file and also using magnet link

I have searched it on google nd find this just go nd download torrent using google drive

In this you can see i have downloaded one movie Onward using torrent

5 Likes

i’am getting this error

“/content/drive/Shared Drives”

I believe it’s “Team Drives” instead of Shared Drives.
Try Running this command:

from google.colab import drive
drive.mount('/content/gdrive')
!ls /content/gdrive

should output something like this:

'My Drive'  'Team Drives'

Source: Github Repo Issues Google Collab

2 Likes

Neat Trick!

1 Like

Guys, just to say, I used to use this method but Google simply restricts you after certain amount of usage (network usage). Even they won’t let you connect to the normal backend, let alone the GPU one. After around one month, they lifted my restriction. So be careful when using Colab to download torrent.

1 Like

try using in magnet link