Scripts to download files and folders programmatically from Google Drive

Overview

Google Drive Downloader Scripts

Every time I need to download a lot of files from Google Drive (e.g. a dataset), it's always incredibly frustrating and slow to get that done. The browser UI very often fails mysteriously and when it does work, it is slow. So here are two scripts to download a file and download a folder programmatically, in case they are more broadly useful.

Prereqs

You would need to do the prerequisites here and in particular Create credentials. The scripts expect you to put the OAuth file you create as client_secret.json in the same folder as the script (obviously you can change this in the script). I also needed to pip install oauth2client in addition to the 3 libraries they list, so e.g.

pip install --upgrade google-api-python-client google-auth-httplib2 google-auth-oauthlib oauth2client

Running

Run them with the --noauth_local_webserver option, e.g. python3 download_folder.py --noauth_local_webserver This will spit out a link and then pause and wait for input. Copy and paste the link to a browser where you are logged in to a Google account with access to the folder. It will give you a prompt to authorize the app/project/whatever it's called thing you created when creating your credentials. After you allow it (as best as I can tell this is one time and not a permanent permission), it will give you a code that you can copy and paste as a response to the script.

Both scripts prompt you for a file id/folder id on the command line. You can find these in the URL from the web UI, e.g https://drive.google.com/drive/folders/

Outputs

Obviously, feel free to change where the scripts write but the download_file.py one spits out the file in the same folder as the script and download_folder.py spits them out in a downloaded/ subfolder (but it does not create it).

Misc

Some of this code was originally given in the Python Google Drive API Quickstart That code is available in a Google repo and it carries an Apache license. It is also useful to refer to the docs for the functions

Similar Tools

I also heard there are two other tools that get this job done. They are probably more bug-free and better maintained, so here they are:

You might also like...
Using Youtube downloader is the fast and easy way to download and save any YouTube video.
Using Youtube downloader is the fast and easy way to download and save any YouTube video.

Youtube video downloader using Django Using Django as a backend along with pytube module to create Youtbue Video Downloader. https://yt-videos-downloa

Advance Image Downloader/Extractor (Job) is a Python-Flask web-based app, which will help the user download the any kind of Images at any date and time over the internet. These images will get downloaded as a job and then let user know that the images have been downloaded by sending them a link over an email.
Download and save Bing wallpapers and set as background for GNOME desktop

Save Bing wallpapers and set as background for GNOME desktop This script downloads the Bing wallpaper and sets it in the background of your gnome desk

Command-line program to download videos from YouTube.com and other video sites

youtube-dl - download videos from youtube.com or other video platforms

The free and open-source Download Manager written in pure Python
The free and open-source Download Manager written in pure Python

The free and open-source Download Manager written in pure Python

A Udemy downloader that can download DRM protected videos and non-DRM protected videos.
A Udemy downloader that can download DRM protected videos and non-DRM protected videos.

Udemy Downloader with DRM support NOTE This program is WIP, the code is provided as-is and i am not held resposible for any legal repercussions result

Python script designed to search and fetch direct download links from nxbrew.com
Python script designed to search and fetch direct download links from nxbrew.com

SwitchGamesDownloader Only for windows nxbrew.com is a website, accessible only using a proxy, where the majority of games for the Nintendo Switch are

Download history data from binance and save to dataframe or csv file

Binance history data downloader Download history data from binance and save to dataframe or csv file

A toolkit to automatically crawl the paper list and download paper pdfs of ACL Ahthology.

ACL-Anthology-Crawler A toolkit to automatically crawl the paper list and download paper pdfs of ACL Anthology

Comments
  • folder downloader NameError

    folder downloader NameError

    Hi, I just want to try your code to download a folder and I got a name error:

    Traceback (most recent call last):
      File "folder_down.py", line 30, in <module>
        pageToken=list_of_files['nextPageToken']
    NameError: name 'list_of_files' is not defined
    
    opened by gabboraron 1
Owner
Ivan Evtimov
University of Washington Allen School of CSE PhD student. Lafayette College Computer Science alum.
Ivan Evtimov
Archivist - Easily archive 📦 Download folder to Google Drive ☁️

Archivist Script for archiving Download folder by uploading unmodified files to a Google Drive folder. Modified files will remain in the Download fold

Timing Liu 3 Sep 30, 2022
Jocomol 16 Dec 12, 2022
PyDownloader - Downloads files and folders at high speed (based on your interent speed).

PyDownloader - Downloads files and folders at high speed (based on your interent speed).

Armen._.G 4 Feb 24, 2022
Downloads files and folders

PyDownloader Downloads files and folders at high speed (based on your interent speed). This is very useful to transfer big files from one computer to

ArmenG 4 Feb 24, 2022
Stremio addon for fetching videos from your google drive.

stremio-gdrive Instructions: There are two ways to go about: Method 1 is hard and long but might give you better performance and you need to make your

null 72 Dec 31, 2022
This package helps you to directly download an APK from Google Play by providing the package id of the app

Apk Downloader About | Features | Technologies | Requirements | Starting | License | Author ?? About This package helps you to directly download an AP

Daniel Agyapong 9 Dec 11, 2022
FireDM is a python open source (Internet Download Manager) with multi-connections, high speed engine, it downloads general files and videos from youtube and tons of other streaming websites .

python open source (Internet Download Manager) with multi-connections, high speed engine, based on python, LibCurl, and youtube_dl https://github.com/firedm/FireDM

null 1.6k Apr 12, 2022
Download YOUR files, documents from vk.

vk-documents-downloader Кароч эта симпл херня качает все ВАШИ документы с вк. Или я еблан, но в гх и тмб гугле я подобного не нашел. py main.py Login:

null 4 Jun 10, 2022
Simple python script to download .mp3 formatted files from YouTube video URLs

Introduction: Simple python script to download .mp3 formatted files from YouTube video URLs Requirements: Requires: youtube_dl module Requires: ffmpeg

Pat 2 Aug 18, 2022
A Python script to download PDB files associated with a Portable Executable (PE)

A Python script to download PDB files associated with a Portable Executable (PE)

Podalirius 33 Jan 3, 2023