├── demo.jpg ├── README.md └── downloader.ipynb /demo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tarunk04/Google-Drive-Downloader/HEAD/demo.jpg -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Google-Drive-Downloader 2 | Download any files directly to the google drive. It uses Google Colab to download files. If you need to save the files from some website to drive then you have to download it and then uplaod it. This becomes very difficult when the file size is too large. This method solves the issue by directly downloading the file to drive, also at very high speed. 3 | 4 | # Setup: 5 | * Open [Google Colab](https://colab.research.google.com/notebooks). 6 | * Create a new notebook. 7 | * Connect to the Drive and create a mount point. For that, authentication is required. 8 | ``` Python 9 | from google.colab import drive 10 | drive.mount('/content/drive', force_remount = True) 11 | ``` 12 | For authentication, choose an account to link then allow access to the Drive. It will generate the auth key, which needs to be entered in the Colab notebook. 13 | ![demo](demo.jpg) 14 | * Use Linux bash commands to create a folder in our Drive. Colab or Jupyter notebook can run all the bash commands directly through the notebook. The below code will create a **folder "Download"** in the root directory of Drive. **Remember not to change "My Drive", it is the root directory of Google Drive.** 15 | ``` python notebook 16 | !mkdir "/content/drive/My Drive/Download" 17 | ``` 18 | * Use wget command to download the file to **Download** folder. 19 | ``` python notebook 20 | !wget -O '/content/drive/My Drive/Download/img1.jpg' "https://unsplash.com/photos/u159a2eL6UE/download?force=true" 21 | ``` 22 | general syntax to download: 23 | ``` python notebook 24 | !wget -O '/content/drive/My Drive/Download/file_name.ext' "download_url" 25 | ``` 26 | where `file_name.ext` is the required name of the file and .ext represent the respective extention. Example: 27 | ``` 28 | Img.jpg 29 | my_pic.png 30 | software.exe 31 | my_collection.zip 32 | ``` 33 | and replace `download_url` with the url of the file. 34 | 35 | **Note: If you can get a download link, which is in most of the cases, you will able to download the file. But sometime it may be challenging to get the download link.** 36 | 37 | # Example 38 | In this repo, find `downloader.ipynb` as an example notebook. You can check more details of `wget` command [here](https://www.computerhope.com/unix/wget.htm#syntax). 39 | -------------------------------------------------------------------------------- /downloader.ipynb: -------------------------------------------------------------------------------- 1 | {"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"name":"downloader.ipynb","version":"0.3.2","provenance":[],"collapsed_sections":[]},"kernelspec":{"name":"python3","display_name":"Python 3"}},"cells":[{"metadata":{"id":"J0gkAQ4lTus-","colab_type":"text"},"cell_type":"markdown","source":["# Connecting to google Drive\n","Run the cell to authenticate with your drive and create a mount point as ''/content/drive'"]},{"metadata":{"id":"s6pPw9eMloRk","colab_type":"code","outputId":"6cdc045c-3e97-4e5f-c526-fca79a3c15b4","executionInfo":{"status":"ok","timestamp":1551258711926,"user_tz":-330,"elapsed":210748,"user":{"displayName":"Tarun Kumar","photoUrl":"","userId":"11955429719906489496"}},"colab":{"base_uri":"https://localhost:8080/","height":122}},"cell_type":"code","source":["from google.colab import drive\n","drive.mount('/content/drive', force_remount = True)"],"execution_count":1,"outputs":[{"output_type":"stream","text":["Go to this URL in a browser: https://accounts.google.com/o/oauth2/auth?client_id=947318989803-6bn6qk8qdgf4n4g3pfee6491hc0brc4i.apps.googleusercontent.com&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&scope=email%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdocs.test%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive.photos.readonly%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fpeopleapi.readonly&response_type=code\n","\n","Enter your authorization code:\n","··········\n","Mounted at /content/drive\n"],"name":"stdout"}]},{"metadata":{"id":"nHS2AXPFUSDP","colab_type":"text"},"cell_type":"markdown","source":["# Create directory \n","Run this cell to download to create a directory on your Drive\n","
**make sure not to remove My Drive from path**"]},{"metadata":{"id":"X36ReP6iUuIq","colab_type":"code","colab":{}},"cell_type":"code","source":["!mkdir \"/content/drive/My Drive/Download\""],"execution_count":0,"outputs":[]},{"metadata":{"id":"OhXo7wwgV6ss","colab_type":"text"},"cell_type":"markdown","source":["# Download First file\n","To downlad file to your drive just add the url of file to download\n","
**Note:** Wait for a while for file to be reflected on your Drive"]},{"metadata":{"id":"PAODBZ73lruv","colab_type":"code","outputId":"0746aa57-176b-4af7-bcce-bc54df74ef60","executionInfo":{"status":"ok","timestamp":1551262164898,"user_tz":-330,"elapsed":3383,"user":{"displayName":"Tarun Kumar","photoUrl":"","userId":"11955429719906489496"}},"colab":{"base_uri":"https://localhost:8080/","height":289}},"cell_type":"code","source":["!wget -O '/content/drive/My Drive/Download/img1.jpg' \"https://unsplash.com/photos/u159a2eL6UE/download?force=true\""],"execution_count":17,"outputs":[{"output_type":"stream","text":["--2019-02-27 10:09:24-- https://unsplash.com/photos/u159a2eL6UE/download?force=true\n","Resolving unsplash.com (unsplash.com)... 151.101.65.181, 151.101.193.181, 151.101.1.181, ...\n","Connecting to unsplash.com (unsplash.com)|151.101.65.181|:443... connected.\n","HTTP request sent, awaiting response... 302 Found\n","Location: https://images.unsplash.com/photo-1519068737630-e5db30e12e42?ixlib=rb-1.2.1&q=85&fm=jpg&crop=entropy&cs=srgb&dl=arthur-aldyrkhanov-566135-unsplash.jpg [following]\n","--2019-02-27 10:09:24-- https://images.unsplash.com/photo-1519068737630-e5db30e12e42?ixlib=rb-1.2.1&q=85&fm=jpg&crop=entropy&cs=srgb&dl=arthur-aldyrkhanov-566135-unsplash.jpg\n","Resolving images.unsplash.com (images.unsplash.com)... 151.101.2.208, 151.101.66.208, 151.101.130.208, ...\n","Connecting to images.unsplash.com (images.unsplash.com)|151.101.2.208|:443... connected.\n","HTTP request sent, awaiting response... 200 OK\n","Length: 3792110 (3.6M) [image/jpeg]\n","Saving to: ‘/content/drive/My Drive/Download/img1.jpg’\n","\n","\r /content/ 0%[ ] 0 --.-KB/s \r/content/drive/My D 100%[===================>] 3.62M --.-KB/s in 0.1s \n","\n","2019-02-27 10:09:25 (28.0 MB/s) - ‘/content/drive/My Drive/Download/img1.jpg’ saved [3792110/3792110]\n","\n"],"name":"stdout"}]}]} --------------------------------------------------------------------------------