All Projects → googleworkspace → Pydrive

googleworkspace / Pydrive

Licence: other
Google Drive API Python wrapper library

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Pydrive

Drive Zipextractor
Extract (decompress) ZIP files into Google Drive using the Google Drive API
Stars: ✭ 425 (-63.98%)
Mutual labels:  gsuite, google-drive
Google Drive Recursive Ownership
Tool to recursively give away file and document ownership to another user.
Stars: ✭ 176 (-85.08%)
Mutual labels:  gsuite, google-drive
Drive Utils
Google Drive API utility functions.
Stars: ✭ 149 (-87.37%)
Mutual labels:  gsuite, google-drive
code
Google Apps Script - Code Snippets 👩🏻‍💻
Stars: ✭ 108 (-90.85%)
Mutual labels:  gsuite, google-drive
drive-zipextractor
Extract (decompress) ZIP files into Google Drive using the Google Drive API
Stars: ✭ 432 (-63.39%)
Mutual labels:  gsuite, google-drive
drive-music-player
Fully client side Music Player for Google Drive
Stars: ✭ 567 (-51.95%)
Mutual labels:  gsuite, google-drive
Gam
command line management for Google Workspace
Stars: ✭ 2,558 (+116.78%)
Mutual labels:  gsuite, google-drive
google-backup
Drive/Gmail/Calendar backups
Stars: ✭ 31 (-97.37%)
Mutual labels:  gsuite, google-drive
Drive Music Player
Fully client side Music Player for Google Drive
Stars: ✭ 554 (-53.05%)
Mutual labels:  gsuite, google-drive
Multipart Related
MIME multipart/related as defined in RFC 2387
Stars: ✭ 10 (-99.15%)
Mutual labels:  google-drive
Node Google Drive
Library to operate with Google Drive API v3 from Node.js, using system user tokens or personal keys
Stars: ✭ 42 (-96.44%)
Mutual labels:  google-drive
Drivebackupv2
Uploads Minecraft backups to Google Drive/OneDrive or by (S)FTP
Stars: ✭ 26 (-97.8%)
Mutual labels:  google-drive
Openly Rails
"GitHub" for Google Drive [inactive]
Stars: ✭ 20 (-98.31%)
Mutual labels:  google-drive
Heroku Google Drive
Remote Google Drive client on Heroku using Rclone and Aria2
Stars: ✭ 44 (-96.27%)
Mutual labels:  google-drive
Elodie
An EXIF-based photo assistant, organizer, manager and workflow automation tool.
Stars: ✭ 840 (-28.81%)
Mutual labels:  google-drive
Gdrivedownloader
Just enter the direct URL of the file and it will upload it to Google Drive and print download link of it.
Stars: ✭ 60 (-94.92%)
Mutual labels:  google-drive
Forge View.googledrive.models
View models from Google Drive: Sample Viewer application that displays files of supported formats from Google Drive, and generates them in the Viewer
Stars: ✭ 18 (-98.47%)
Mutual labels:  google-drive
Ct gdrive
Lustre/HSM Google Drive copytool
Stars: ✭ 16 (-98.64%)
Mutual labels:  google-drive
Torrent To Google Drive Downloader
Simple notebook to stream torrent files to Google Drive using Google Colab and python3.
Stars: ✭ 63 (-94.66%)
Mutual labels:  google-drive
Holysheet
A program to store arbitrary files in Google Sheets
Stars: ✭ 59 (-95%)
Mutual labels:  google-drive

PyDrive

PyDrive is a wrapper library of google-api-python-client <https://github.com/google/google-api-python-client>_ that simplifies many common Google Drive API tasks.

Project Info

  • Homepage: https://pypi.python.org/pypi/PyDrive <https://pypi.python.org/pypi/PyDrive>_
  • Documentation: Official documentation on GitHub pages <https://googleworkspace.github.io/PyDrive/docs/build/html/index.html>_
  • GitHub: https://github.com/googleworkspace/PyDrive <https://github.com/googleworkspace/PyDrive>_

Features of PyDrive

  • Simplifies OAuth2.0 into just few lines with flexible settings.
  • Wraps Google Drive API <https://developers.google.com/drive/>_ into classes of each resource to make your program more object-oriented.
  • Helps common operations else than API calls, such as content fetching and pagination control.

How to install

You can install PyDrive with regular pip command.

::

$ pip install PyDrive

To install the current development version from GitHub, use:

::

$  pip install git+https://github.com/googleworkspace/PyDrive.git#egg=PyDrive

OAuth made easy

Download client_secrets.json from Google API Console and OAuth2.0 is done in two lines. You can customize behavior of OAuth2 in one settings file settings.yaml.

.. code:: python

from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive

gauth = GoogleAuth()
gauth.LocalWebserverAuth()

drive = GoogleDrive(gauth)

File management made easy

Upload/update the file with one method. PyDrive will do it in the most efficient way.

.. code:: python

file1 = drive.CreateFile({'title': 'Hello.txt'})
file1.SetContentString('Hello')
file1.Upload() # Files.insert()

file1['title'] = 'HelloWorld.txt'  # Change title of the file
file1.Upload() # Files.patch()

content = file1.GetContentString()  # 'Hello'
file1.SetContentString(content+' World!')  # 'Hello World!'
file1.Upload() # Files.update()

file2 = drive.CreateFile()
file2.SetContentFile('hello.png')
file2.Upload()
print('Created file %s with mimeType %s' % (file2['title'],
file2['mimeType']))
# Created file hello.png with mimeType image/png

file3 = drive.CreateFile({'id': file2['id']})
print('Downloading file %s from Google Drive' % file3['title']) # 'hello.png'
file3.GetContentFile('world.png')  # Save Drive file as a local file

# or download Google Docs files in an export format provided.
# downloading a docs document as an html file:
docsfile.GetContentFile('test.html', mimetype='text/html')

File listing pagination made easy

PyDrive handles file listing pagination for you.

.. code:: python

# Auto-iterate through all files that matches this query
file_list = drive.ListFile({'q': "'root' in parents"}).GetList()
for file1 in file_list:
    print('title: {}, id: {}'.format(file1['title'], file1['id']))

# Paginate file lists by specifying number of max results
for file_list in drive.ListFile({'maxResults': 10}):
    print('Received {} files from Files.list()'.format(len(file_list))) # <= 10
    for file1 in file_list:
        print('title: {}, id: {}'.format(file1['title'], file1['id']))

Concurrent access made easy

All calls made are thread-safe. The underlying implementation in the google-api-client library is not thread-safe <https://developers.google.com/api-client-library/python/guide/thread_safety>_, which means that every request has to re-authenticate an http object. You can avoid this overhead by creating your own http object for each thread and re-use it for every call.

This can be done as follows:

.. code:: python

# Create httplib.Http() object.
http = drive.auth.Get_Http_Object()

# Create file object to upload.
file_obj = drive.CreateFile()
file_obj['title'] = "file name"

# Upload the file and pass the http object into the call to Upload.
file_obj.Upload(param={"http": http})

You can specify the http-object in every access method which takes a param parameter.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].