<jupyter_start><jupyter_text>Torrent To Google Drive Downloader  **IMPORTANT: MAKE YOUR OWN COPY OF THIS FILE SO AS NOT TO REVEAL ANY INFORMATION WITH REGARDS TO YOUR DOWNLOAD.**

Go to Goto **File** > **Save a copy in Drive**... (a new tab opens with the copy of this notebook).  Mount Google DriveTo stream files we need to mount Google Drive.<jupyter_code>from google.colab import drive
drive.mount('/content/drive')<jupyter_output><empty_output><jupyter_text>Dependencyhttps://www.libtorrent.org/<jupyter_code>!apt install python3-libtorrent<jupyter_output><empty_output><jupyter_text>Code to download torrentVariable **link** stores the link string.By default, files will be saved in the path "My Drive/Torrents"If you want to change the save path, click the folder icon on the left side. Navigate to the folder of your choice. Select the folder and **Right Click** > **Copy Path**Paste the copied path 4 inside the provided space below. Make sure to end the path with a "/".<jupyter_code>import libtorrent as lt
import time
import datetime

ses = lt.session()
ses.listen_on(6881, 6891)
params = {
    'save_path': '/content/drive/My Drive/Torrent/',  # Change the save path by modifying the variable.
    'storage_mode': lt.storage_mode_t(2),
    'paused': False,
    'auto_managed': True,
    'duplicate_is_error': True}
link = "MAGNET_LINK" # PASTE TORRENT/MAGNET LINK HERE
print(link)

handle = lt.add_magnet_uri(ses, link, params)
ses.start_dht()

begin = time.time()
print(datetime.datetime.now())

print ('Downloading Metadata...')
while (not handle.has_metadata()):
    time.sleep(1)
print ('Got Metadata, Starting Torrent Download...')

print("Starting", handle.name())

while (handle.status().state != lt.torrent_status.seeding):
    s = handle.status()
    state_str = ['queued', 'checking', 'downloading metadata', \
            'downloading', 'finished', 'seeding', 'allocating']
    print ('%.2f%% complete (down: %.1f kb/s up: %.1f kB/s peers: %d) %s ' % \
            (s.progress * 100, s.download_rate / 1000, s.upload_rate / 1000, \
            s.num_peers, state_str[s.state]))
    time.sleep(5)

end = time.time()
print(handle.name(), "COMPLETE")

print("Elapsed Time: ",int((end-begin)//60),"min :", int((end-begin)%60), "sec")

print(datetime.datetime.now())<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1369330453563715, 'fraction_numerical': 0.013390928725701945, 'mean_word_length': 4.501187648456057, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 7, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '336536', 'license': 'MIT', 'n_tokens_mistral': 786, 'n_tokens_neox': 754, 'n_words': 233, 'path': 'Torrent_to_GDrive_Downloader.ipynb', 'repo_name': 'DemonTheLemon/Save-Torrent-to-Google-Drive', 'size': '2315'}