Skip to main content

CI PyPI - Python Version Code size License Version

ggdrive

A command-line script for Google Drive, for downloading and uploading files directly from the terminal.

Pre-requisites

Important note: This project requires Google API credentials. That credential file enables the use of Google APIs by this application, and allows the user to login and allow (or deny) the application to access the user's Google Drive files. At this moment, we're not providing the credentials.json needed for this to work, so if you want to use this code, you need to go to Google's Developer Console, create a project, and create the OAuth credentials for it, allowing for scopes "drive" and "drive.metadata". You can download the credentials.json and use it here.

After downloading your credentials.json, go to to your home folder, create a directory called .gdrive, and put your credentials.json file in there.

The first time you're executing this, a Google page will open and ask for your account, so it can integrate with your Google Drive account, and then it will ask if you give permission to the app. Once you agree, you're all set.

Installation

python3 -m pip install ggdrive

That's it! You can advance to Usage

... Or install manually

This project requires:

  1. Python 3.6 or greater.
  2. Google Client Library

1. Clone this repository

git clone git@github.com:DiscordTime/ggdrive.git

or

git clone https://github.com/DiscordTime/ggdrive.git

2. Install dependencies

We created a requirements.txt where you can execute the following to install the needed libs:

pip install --upgrade -r requirements.txt

or

python3 -m pip install --upgrade -r requirements.txt

3. If the script gdrive doesn't have execution permission, give it to it.

chmod +x gdrive

You can add this repo folder to you path, so you can execute gdrive from anywhere on your terminal. Open your .bashrc or similar and add one of the following options:

export PATH=$PATH:'<path-to-repo-folder>'

or

alias gdrive='<path-to-repo-folder>/gdrive

Usage

Available functions:

1. Upload

gdrive upload --help
gdrive upload <file-to-upload>

2. Download

gdrive download --help

You can download a file passing either the id, or the name of your file

gdrive download <(fileId/filename)-to-download>

To explicitly download via the id, use one of the following:

gdrive download -i <id-of-file-to-download>
gdrive download --id <id-of-file-to-download>

To download a file via its name, use one of the following:

gdrive download -n <name-of-file-to-download>
gdrive download --name <name-of-file-to-download>

If you're sure that the file that you want to download is the last one that was modified, just use one of the following:

gdrive download -l
gdrive download --last

If the file is a compressed one, you can try extracting it as soon as it finished downloading by using the extract option (This option is to be used in combination with one of the above):

gdrive download -le
gdrive download -ei <id-of-file-to-download>
gdrive download -en <name-of-file-to-download>
gdrive download --last --extract

NOTE

The extract function needs some extra programs to execute. We implement a mechanism that tries to guess the extension of the file you're downloading and use the program you define to extract it. So, the first time you try to download a file of a certain type, when it's time to extract the file, our program will ask you which program you want to choose. After that, if you download a file with this same extension, it will extract it automatically (if you added the --extract option).

Those configurations are located with your other files that we need in the .gdrive in your HOME directory. The file is called data_config.json

Sample

{
  "configs": [
    {
      "ext": "application/x-tar",
      "encoding": "gzip",
      "prog": "tar",
      "attrs": "xzvf"
    },
    {
      "ext": null,
      "encoding": "gzip",
      "prog": "gunzip",
      "attrs": null
    },
    {
      "ext": "application/x-tar",
      "encoding": null,
      "prog": "tar",
      "attrs": "xvf"
    }
  ]
}

3. List

gdrive list
gdrive list --help

Metadata

Release files for ggdrive 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ggdrive 0.1.4
File Size Uploaded Provenance Actions
ggdrive-0.1.4.tar.gz 16.3 kB Without provenance Details for ggdrive-0.1.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ggdrive 0.1.4
File Interpreter ABI Platform Actions
ggdrive-0.1.4-py3-none-any.whl Python 3 none any Details for ggdrive-0.1.4-py3-none-any.whl

Total release size: 35.1 kB

Release files / ggdrive-0.1.4.tar.gz

Download URL ggdrive-0.1.4.tar.gz
Size 16.3 kB
Tags Source
SHA-256 checksum
How to use checksums
2d1671189135b0888ac8bc0beded03e129150b2447287c0479366c12b32db441
BLAKE2b-256 checksum
How to use checksums
1481ff15bcb3b1b4694255d184937bb31c6044c5e5f1faaf6fca1d10d3c09272
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.8.5

Release files / ggdrive-0.1.4-py3-none-any.whl

Download URL ggdrive-0.1.4-py3-none-any.whl
Size 18.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
822fb4fcae62e792786a6dc471786cc7c005fa60532f85ea8a3e69b6bda43c96
BLAKE2b-256 checksum
How to use checksums
763cddf869693b987f56aabba71c2865cff64403d2bbc23cd9bd5d616a601b85
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.8.5

Security for ggdrive 0.1.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page