├── README.md └── torrents_to_one_drive.ipynb /README.md: -------------------------------------------------------------------------------- 1 | # torrent-to-one-drive 2 | Download torrents directly to Microsoft One Drive using Google Colab 3 | 4 | ### Why using this method? 5 | 1. The download speed is fast because of Google and Microsoft Servers speed. 6 | 2. You can access files from anywhere because they are in One Drive. 7 | 3. You can bypass any restrictions on torrenting set by your ISP or your office and access your files through drive (neat isn't it!). 8 | 9 | ### How to? 10 | https://youtu.be/dwV2HY8gErw 11 | 12 | ## *** This is purely for education purpose *** 13 | -------------------------------------------------------------------------------- /torrents_to_one_drive.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "nbformat": 4, 3 | "nbformat_minor": 0, 4 | "metadata": { 5 | "colab": { 6 | "name": "torrents to one drive.ipynb", 7 | "provenance": [], 8 | "collapsed_sections": [] 9 | }, 10 | "kernelspec": { 11 | "name": "python3", 12 | "display_name": "Python 3" 13 | } 14 | }, 15 | "cells": [ 16 | { 17 | "cell_type": "markdown", 18 | "metadata": { 19 | "id": "aQuWDmfm9YOi", 20 | "colab_type": "text" 21 | }, 22 | "source": [ 23 | "# Torrents To Microsft One Drive Downloader" 24 | ] 25 | }, 26 | { 27 | "cell_type": "markdown", 28 | "metadata": { 29 | "id": "FexiyATtNwTG", 30 | "colab_type": "text" 31 | }, 32 | "source": [ 33 | "###Install Dependencies\n", 34 | "https://www.libtorrent.org/
\n", 35 | "https://rclone.org/" 36 | ] 37 | }, 38 | { 39 | "cell_type": "code", 40 | "metadata": { 41 | "colab_type": "code", 42 | "id": "m6hF0emftx4h", 43 | "colab": {} 44 | }, 45 | "source": [ 46 | "!python -m pip install --upgrade pip setuptools wheel\n", 47 | "!python -m pip install lbry-libtorrent\n", 48 | "!wget https://downloads.rclone.org/v1.52.1/rclone-v1.52.1-linux-amd64.deb\n", 49 | "!apt install ./rclone-v1.52.1-linux-amd64.deb" 50 | ], 51 | "execution_count": 0, 52 | "outputs": [] 53 | }, 54 | { 55 | "cell_type": "markdown", 56 | "metadata": { 57 | "id": "u6b8Q4EjIowT", 58 | "colab_type": "text" 59 | }, 60 | "source": [ 61 | "### Authenticate One Drive" 62 | ] 63 | }, 64 | { 65 | "cell_type": "code", 66 | "metadata": { 67 | "id": "dT1VHtxSIu8g", 68 | "colab_type": "code", 69 | "colab": {} 70 | }, 71 | "source": [ 72 | "!rclone config" 73 | ], 74 | "execution_count": 0, 75 | "outputs": [] 76 | }, 77 | { 78 | "cell_type": "markdown", 79 | "metadata": { 80 | "id": "gi5Cx03cLWYE", 81 | "colab_type": "text" 82 | }, 83 | "source": [ 84 | "### Mount One Drive\n", 85 | "To stream files we need to mount One Drive." 86 | ] 87 | }, 88 | { 89 | "cell_type": "code", 90 | "metadata": { 91 | "id": "dWSuoVQ-LU4M", 92 | "colab_type": "code", 93 | "colab": {} 94 | }, 95 | "source": [ 96 | "!mkdir onedrive\n", 97 | "!nohup rclone --vfs-cache-mode writes mount onedrive: ./onedrive &" 98 | ], 99 | "execution_count": 0, 100 | "outputs": [] 101 | }, 102 | { 103 | "cell_type": "markdown", 104 | "metadata": { 105 | "id": "_3OSW_tBVrz6", 106 | "colab_type": "text" 107 | }, 108 | "source": [ 109 | "###Just check the drive is mounted" 110 | ] 111 | }, 112 | { 113 | "cell_type": "code", 114 | "metadata": { 115 | "id": "rvxk-3S5Uwo3", 116 | "colab_type": "code", 117 | "colab": {} 118 | }, 119 | "source": [ 120 | "!ls ./onedrive" 121 | ], 122 | "execution_count": 0, 123 | "outputs": [] 124 | }, 125 | { 126 | "cell_type": "markdown", 127 | "metadata": { 128 | "id": "j-ILSl_YOGRS", 129 | "colab_type": "text" 130 | }, 131 | "source": [ 132 | "### Paste the Magnet Link here and press enter to start download\n", 133 | "Variable **link** stores the link string." 134 | ] 135 | }, 136 | { 137 | "cell_type": "code", 138 | "metadata": { 139 | "colab_type": "code", 140 | "id": "b09BxnANO2ep", 141 | "colab": {} 142 | }, 143 | "source": [ 144 | "!mkdir Torrent\n", 145 | "\n", 146 | "link = input(\"PASTE TORRENT/MAGNET LINK HERE \\n\") # PASTE TORRENT/MAGNET LINK HERE\n", 147 | "\n", 148 | "import libtorrent as lt\n", 149 | "import time\n", 150 | "import datetime\n", 151 | "\n", 152 | "ses = lt.session()\n", 153 | "ses.listen_on(6881, 6891)\n", 154 | "params = {\n", 155 | " 'save_path': './Torrent/',\n", 156 | " 'storage_mode': lt.storage_mode_t(2)}\n", 157 | "\n", 158 | "print(link)\n", 159 | "\n", 160 | "handle = lt.add_magnet_uri(ses, link, params)\n", 161 | "ses.start_dht()\n", 162 | "\n", 163 | "begin = time.time()\n", 164 | "print(datetime.datetime.now())\n", 165 | "\n", 166 | "print ('Downloading Metadata...')\n", 167 | "while (not handle.has_metadata()):\n", 168 | " time.sleep(1)\n", 169 | "print ('Got Metadata, Starting Torrent Download...')\n", 170 | "\n", 171 | "print(\"Starting\", handle.name())\n", 172 | "\n", 173 | "while (handle.status().state != lt.torrent_status.seeding):\n", 174 | " s = handle.status()\n", 175 | " state_str = ['queued', 'checking', 'downloading metadata', \\\n", 176 | " 'downloading', 'finished', 'seeding', 'allocating']\n", 177 | " print ('%.2f%% complete (down: %.1f kb/s up: %.1f kB/s peers: %d) %s ' % \\\n", 178 | " (s.progress * 100, s.download_rate / 1000, s.upload_rate / 1000, \\\n", 179 | " s.num_peers, state_str[s.state]))\n", 180 | " time.sleep(5)\n", 181 | "\n", 182 | "end = time.time()\n", 183 | "print(handle.name(), \"COMPLETE\")\n", 184 | "\n", 185 | "print(\"Elapsed Time: \",int((end-begin)//60),\"min :\", int((end-begin)%60), \"sec\")\n", 186 | "\n", 187 | "print(datetime.datetime.now())" 188 | ], 189 | "execution_count": 0, 190 | "outputs": [] 191 | }, 192 | { 193 | "cell_type": "markdown", 194 | "metadata": { 195 | "id": "RCbkGqNIdrP-", 196 | "colab_type": "text" 197 | }, 198 | "source": [ 199 | "###Copy the downloaded torrent to One Drive" 200 | ] 201 | }, 202 | { 203 | "cell_type": "code", 204 | "metadata": { 205 | "id": "r_1hfrLYcbSa", 206 | "colab_type": "code", 207 | "colab": {} 208 | }, 209 | "source": [ 210 | "!cp -r Torrent/* onedrive/" 211 | ], 212 | "execution_count": 0, 213 | "outputs": [] 214 | } 215 | ] 216 | } 217 | --------------------------------------------------------------------------------