A command line interface for accessing google drive

Overview

Briefly-logo

Drive Cli

PyPI version Python version Build Status License: MIT

Get the ability to access Google Drive without leaving your terminal.


Inspiration

  • Google Drive has become a vital part of our day to day life. As much as non-programmers use it, so do programmers in several situations, where we need not use git/github.

  • Drive-CLI is a command-line utility for google drive which helps you access, sync, download, upload, etc. directly to your drive without leaving the command-line. The best part being the commands are similar to git CLI so that you can easily remember them 💆


Features

  • view-files: list your files; filter them by name, type.
  • clone: download file/folder from drive using sharing link or file ID and get it linked.
  • add-remote: upload existing local file to drive and get it linked.
  • cat: view files contents of text format without actually downloading them.
  • rm: remove particular file or folder.
  • ls: list all the files present in the drive of equivalent current directory.
  • status: list changes made to local files since last push or pull.
  • pull: get latest changes from drive to local files.
  • push: push the local changes to drive.

Demo


Installation

  • For Usage
    #install using pip 
    $ pip install drive-cli
  • For Development
    • clone the repo
        $ git clone https://github.com/nurdtechie98/drive-cli.git
    • get your client_secret.json from Oauth. Make sure to enable Drive Api for the project.
    • rename the client secret to oauth.json and place it in the drive_cli directory.
    • install the package:
        # move into package directory
        $ cd drive-cli
        # install package in edit mode
        $ pip install -e . #note the dot

Usage

Clone

Download a file or folder present in drive using its file id or its sharing link. In case it is a folder it gets tracked.

# using file id note: since it is google doc it will be asked for a choice to select from
$ drive clone 1syTNkfXoc3pzpJSL0Z5LDioTFc46_LjzHjDDUvk90ks
Choose type to export to
 (ENTER to select, s to stop):

 => pdf
    txt
    doc
    zip
    html
    rtf
    odt
Preparing: watson script for download
downloading file  [####################################]  100%
completed download of watson script

# using file sharing link
$ drive clone https://docs.google.com/document/d/1syTNkfXoc3pzpJSL0Z5LDioTFc46_LjzHjDDUvk90ks
Choose type to export to
 (ENTER to select, s to stop):

 => pdf
    txt
    doc
    zip
    html
    rtf
    odt
Preparing: watson script for download
downloading file  [####################################]  100%
completed download of watson script

for further in depth documetation checkout our wiki.


Uninstalling

    $ pip uninstall drive-cli

Contributing

  • We're are open to enhancements & bug-fixes 😄 . Take a look here to get started
  • Feel free to add issues and submit patches

Author

Chirag Shetty - nurdtechie98

See also the list of contributors who participated in this project.


License

This project is licensed under the MIT - see the LICENSE file for details.

Comments
  • add revisions functionality

    add revisions functionality

    History

    I have written a function history() in actions.py, which prints history (that is information about previously used commands). This function has two flags

    1. --date: User has to pass date as an argument and it will filter out the history.
    2. --clear: This flag deletes the entire history.

    Output of drive history


    Screenshot from 2019-03-13 23-36-42

    Output of drive history --clear


    Screenshot from 2019-03-13 23-24-51

    Output od drive history --date <date>


    Screenshot from 2019-03-14 00-02-48

    Log

    I have written a function get_revision() in actions.py which take file id/ link as a mandatory argument and print all the revisions related to that file. This function has three flags and all the flags take revision_id as an argument:

    1. --get: it provides more information about that particular revision 2)--delete: this flag deletes the revision 3)--save: This flag keep revision forever, even if it is no longer the head revision. If not set, the revision will be automatically purged 30 days after newer content is uploaded.

    Screenshot from 2019-03-16 01-03-39 Fixes #40 Fixes #16

    opened by raghav-dalmia 9
  • add file/folder sharing feature

    add file/folder sharing feature

    I write a function a function name share() in action.py, which take file id as mandatory argument and role, type and message are it's optional arguments.

    Following image show result of drive share --help

    drive share --help

    If type is anyone, it will generate a share link and print it, otherwise, it will take email id as an argument and share the link directly to grantee/user.

    @inishchith @nurdtechie98, please review.

    Fixes #15

    opened by raghav-dalmia 9
  • probot stale

    probot stale

    issue #64 I have created a .yml file with suitable configuration to remove stale issues. I have limited it only to pull request so it wont check for opened issues. After 15 days of inactivity the pull request becomes stale and after further 7 days it will be closed.

    opened by ahegde3 7
  • add drive info functionality

    add drive info functionality

    Using the command by either specifying the sharing link or the file id one should be able to view relevant information of the file/folder like size of it, members / owners, mimetype , creation date, last modified date, parent folder etc. Note: The data displayed regarding the same should be organised and layout should be clean enough to read.

    enhancement medium gssoc19 up for grab 
    opened by nurdtechie98 7
  • Modularize dcli.py and Fix a bug in view-files command

    Modularize dcli.py and Fix a bug in view-files command

    Modularize dcli.py

    I have created two modules auth.py and actions.py.

    auth.py contains all the functions related to authentication of eamil i.e. login() and logout() function. actions.py contains all the functions related to subcommands like view-files, ls, clone and others.

    Also, I put all the other helper functions in utils.py and import them into actions.py

    Fix a bug in view-file command

    Following code is written twice in the view-file function due to which there is modification the query. I have deleted one of them.

        if pid:
            parent = click.prompt('enter the fid of parent or  sharing link')
            fid = utils.get_fid(parent)
            if (name != False) or (types != False):
            query += " and "
            query += "'" + fid + "' in parents"`
    

    @nurdtechie98 @inishchith please review the changes.

    opened by raghav-dalmia 7
  • add requirements.txt or Pipfile

    add requirements.txt or Pipfile

    currently, the only option to install and manage the dependencies is by using the setup.py. It'll be easier to manage the dependencies by having a requirements.txt or Pipfile

    enhancement easy gssoc19 
    opened by adtya 7
  • Google sign in not working

    Google sign in not working

    Using the latest pip version with any command will lead me to the following error message by google after signing in:

    grafik

    Subsequently, there will be no response back to the app to tell it something failed and it gets stuck until manually sending an arbitrary request to localhost:8080

    opened by luftj 4
  • add .driveignore functionality

    add .driveignore functionality

    There are two ways to untrack a file/folder. First one is create a .driveignore file in the tracked directory and then add name of files to be untracked.

    Second is to use drive ignore command. Enter the file names(with extensions) as an argument. We can use -l flag to list out all the untracked files.

    OUTPUT


    Screenshot from 2019-04-05 03-32-00

    Screenshot from 2019-04-05 03-32-03

    Screenshot from 2019-04-05 03-34-43

    Screenshot from 2019-04-05 03-42-25

    Fixes #9 @nurdtechie98 @inishchith please review this PR.

    opened by raghav-dalmia 4
  • Change

    Change "add_remote" to "add-remote"

    In the command view-files, the separator between the words view and files is a hyphen. It'll be nice if add_remote follows the same convention for consistency.

    So, we need to change the command add_remote to add-remote and update the README accordingly.

    good first issue gssoc19 Beginner up for grab 
    opened by sauravchirania 3
  • Requirement.parse('pyasn1<0.5.0,>=0.4.1')

    Requirement.parse('pyasn1<0.5.0,>=0.4.1')

    I tried using the application.When I try drive login or any other command it gives me an error.The traceback is as follow.

    Traceback (most recent call last): File "/home/ahegde3/anaconda3/lib/python3.5/site-packages/pkg_resources/init.py", line 666, in _build_master ws.require(requires) File "/home/ahegde3/anaconda3/lib/python3.5/site-packages/pkg_resources/init.py", line 984, in require needed = self.resolve(parse_requirements(requirements)) File "/home/ahegde3/anaconda3/lib/python3.5/site-packages/pkg_resources/init.py", line 875, in resolve raise VersionConflict(dist, req).with_context(dependent_req) pkg_resources.ContextualVersionConflict: (pyasn1 0.1.9 (/home/ahegde3/anaconda3/lib/python3.5/site-packages), Requirement.parse('pyasn1<0.5.0,>=0.4.1'), {'pyasn1-modules'})

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last): File "/home/ahegde3/anaconda3/bin/drive", line 6, in from pkg_resources import load_entry_point File "/home/ahegde3/anaconda3/lib/python3.5/site-packages/pkg_resources/init.py", line 3144, in @_call_aside File "/home/ahegde3/anaconda3/lib/python3.5/site-packages/pkg_resources/init.py", line 3128, in _call_aside f(*args, **kwargs) File "/home/ahegde3/anaconda3/lib/python3.5/site-packages/pkg_resources/init.py", line 3157, in _initialize_master_working_set working_set = WorkingSet._build_master() File "/home/ahegde3/anaconda3/lib/python3.5/site-packages/pkg_resources/init.py", line 668, in _build_master return cls._build_from_requirements(requires) File "/home/ahegde3/anaconda3/lib/python3.5/site-packages/pkg_resources/init.py", line 681, in _build_from_requirements dists = ws.resolve(reqs, Environment()) File "/home/ahegde3/anaconda3/lib/python3.5/site-packages/pkg_resources/init.py", line 875, in resolve raise VersionConflict(dist, req).with_context(dependent_req) pkg_resources.ContextualVersionConflict: (pyasn1 0.1.9 (/home/ahegde3/anaconda3/lib/python3.5/site-packages), Requirement.parse('pyasn1<0.5.0,>=0.4.1'), {'pyasn1-modules'})

    Didnt find any solution .

    opened by ahegde3 3
  • add unit tests

    add unit tests

    Unit tests can help save a lot of time when during testing. Without it, testing seems to be difficult and time consuming as we have to run the whole program through different scenarios manually every time.

    opened by adtya 3
  • Better implementation for .driveignore

    Better implementation for .driveignore

    New possibility on .driveignore file:

    • insert files in subdirectories (subdir/file.ext)
    • insert universal identifiers (* and **), similar to .gitignore
    • insert negation (!)
    opened by giacoliva 0
  • CLI ? Unusable from terminal. Need GUI.

    CLI ? Unusable from terminal. Need GUI.

    I don't get it the point of calling it CLI as the first step is literally login thru browser, which throw error because of Js not enabled, while login it from terminal

    opened by tonywtrd 0
  • Drive API requires updates to your code before Sep 13, 2021

    Drive API requires updates to your code before Sep 13, 2021

    Received this message from Google. Can drive-cli be modified to work?

    We have identified you as a Developer who has used the Drive API in the last 30 days. We are writing to let you know that on September 13, 2021, Drive will apply a security update that will change the links used to share some files, and may lead to some new file access requests. Access to files won’t change for people who have already viewed or modified these files.

    Please update your code as detailed below before September 13, 2021, to avoid failing requests.

    What do I need to know?

    Items that have a Drive API permission with type=domain or type=anyone, where withLink=true (v2) or allowFileDiscovery=false (v3), will be affected by this security update.

    In addition to the item ID, your application may now also need a resource key to access these items. Without a resource key, requests for these items may result in a 404 Not Found error (See below for details). Note that access to items that are directly shared with the user or group are not affected.

    Will this change affect me?

    If your application uses the Drive API to access files which have been shared with a user through link sharing, your application may be affected by this change.

    What do I need to do?

    To avoid errors accessing files, you must update your code for accessing files to include the appropriate resource keys. Details on how to do this for each of the affected Drive APIs is included below:

    Changes to the Drive API

    The resource key of an item is returned on the resourceKey field of the file metadata in the Drive API response.

    If the file is a shortcut file, then the resource key for the target of the shortcut can be read from the shortcutDetails.targetResourceKey field of the same resource. URL type fields such as exportLinks, webContentLink, and webViewLink will include the resourceKey. Requests to the Drive API can specify one or more resource keys with the X-Goog-Drive-Resource-Keys HTTP request header. Learn more about this change from the Drive API guide.

    Changes to Apps Script

    The DriveApp from Apps Script has been updated to return the resource key of a file or folder with the getResourceKey method.

    Note: When fetching a file or folder, the resource key can be specified on the getFileByIdAndResourceKey or getFolderByIdAndResourceKey methods. Changes to Drive UI Integrations

    If your application is integrated with the Drive UI to create or open items, it will receive resource keys when your application is invoked from the Drive UI.

    The state information for a New URL will contain folderResourceKey, which is the resource key of the folder where the new item should be created. The state for an Open URL will contain a mapping of file ID to resource key in the resourceKeys field. Learn more about integrating with the Drive UI on our website.

    opened by hansgv 0
  • drive push doens't sync files

    drive push doens't sync files

    As the title says , whenever i clone the directory from my drive via '>>drive clone id-of-this-directory' , it gets downloaded normally . however when i change the directory into it , and then make adjustment to any of the files contained within , the try pushing the new modifications , it doesn't make any change to the google drive directory ,it only outputs this message checking for changes in 'text_files' .... Working directory is clean

    opened by z0xyz 2
Owner
Chirag Shetty
Software Engineer @browserstack
Chirag Shetty
A powerful bot to copy your google drive data to your team drive

⚛️ Clonebot - Heroku version ⚡ CloneBot is a telegram bot that allows you to copy folder/team drive to team drives. One of the main advantage of this

MsGsuite 269 Dec 23, 2022
A simple telegram Bot, Upload Media File| video To telegram using the direct download link. (youtube, Mediafire, google drive, mega drive, etc)

URL-Uploader (Bot) A Bot Upload file|video To Telegram using given Links. Features: ?? Only Auth Users (AUTH_USERS) Can Use The Bot ?? Upload YTDL Sup

Hash Minner 18 Dec 17, 2022
DB-Drive-CSV - This is app is can be used to access CSV file as JSON from Google Drive.

DB Drive CSV This is app is can be used to access CSV file as JSON from Google Drive. How To Use Create file/ upload file to Google Drive There's 2 fi

Hartawan Bahari M. 5 Oct 20, 2022
First Party data integration solution built for marketing teams to enable audience and conversion onboarding into Google Marketing products (Google Ads, Campaign Manager, Google Analytics).

Megalista Sample integration code for onboarding offline/CRM data from BigQuery as custom audiences or offline conversions in Google Ads, Google Analy

Google 76 Dec 29, 2022
Deepak Clouds Torrent is a multipurpose Telegram Bot writen in Python for mirroring files on the Internet to our beloved Google Drive.

Deepak Clouds Torrent is a multipurpose Telegram Bot writen in Python for mirroring files on the Internet to our beloved Google Drive.

Deepak Clouds 37 Oct 28, 2022
A python based all-in-one tool for Google Drive

gdrive-tools A python based all-in-one tool for Google Drive Uses For Gdrive-Tools ✓ generate SA ✓ Add the SA and Add them to TD automatically ✓ Gener

XcodersHub 32 Feb 9, 2022
This Mirror Bot is a multipurpose Telegram Bot writen in Python for mirroring files on the Internet to our beloved Google Drive.

MIRROR HUNTER This Mirror Bot is a multipurpose Telegram Bot writen in Python for mirroring files on the Internet to our beloved Google Drive. Repo la

anime republic 130 May 28, 2022
Slam Mirror Bot is a multipurpose Telegram Bot written in Python for mirroring files on the Internet to our beloved Google Drive.

Slam Mirror Bot is a multipurpose Telegram Bot written in Python for mirroring files on the Internet to our beloved Google Drive.

Abinash939 1 Oct 10, 2021
A Telegram Bot written in Python for mirroring files on the Internet to your Google Drive

No support is going to be provided of any kind, only maintaining this for vps user on request. This is a Telegram Bot written in Python for mirroring

Sunil Kumar 42 Oct 28, 2022
Bagas Mirror&Leech Bot is a multipurpose Telegram Bot written in Python for mirroring files on the Internet to our beloved Google Drive. Based on python-aria-mirror-bot

- [ MAYBE UPDATE & ADD MORE MODULE ] Bagas Mirror&Leech Bot Bagas Mirror&Leech Bot is a multipurpose Telegram Bot written in Python for mirroring file

null 4 Nov 23, 2021
With Google Drive API. My computer and my phone are in love now.

Channel trought Google Drive Google Drive API In this case, "Google Drive App" is the program. To install everything you need(has some extra things),

Luis Quiñones Requelme 1 Dec 15, 2021
Autodrive is designed to make it as easy as possible to interact with the Google Drive and Sheets APIs via Python

Autodrive Autodrive is designed to make it as easy as possible to interact with the Google Drive and Sheets APIs via Python. It is especially designed

Chris Larabee 1 Oct 2, 2021
A Telegram Bot written in Python for mirroring files on the Internet to Google Drive

No support is going to be provided of any kind, only maintaining this for vps user on request. This is a Telegram Bot written in Python for mirroring

null 0 Dec 26, 2021
A telegram bot writen in python for mirroring files on the internet to Google Drive

owner of this repo :- AYUSH contact me :- AYUSH Slam Mirror Bot This is a telegram bot writen in python for mirroring files on the internet to our bel

Thanusara Pasindu 1 Nov 21, 2021
A discord bot that utilizes Google's Rest API for Calendar, Drive, and Sheets

Bott This is a discord bot that utilizes Google's Rest API for Calendar, Drive, and Sheets. The bot first takes the sheet from the schedule manager in

null 1 Dec 4, 2021
Automation that uses Github Actions, Google Drive API, YouTube Data API and youtube-dl together to feed BackJam app with new music

Automation that uses Github Actions, Google Drive API, YouTube Data API and youtube-dl together to feed BackJam app with new music

Antônio Oliveira 1 Nov 21, 2021
A telegram bot writen in python for mirroring files on the internet to our beloved Google Drive

[] Mirror Bot This is a telegram bot writen in python for mirroring files on the internet to our beloved Google Drive. Deploying on Heroku Give Star &

null 43 Mar 6, 2022
A Telegram Bot written in Python for mirroring files on the Internet to your Google Drive or Telegram

Original Repo mirror-leech-telegram-bot This is a Telegram Bot written in Python for mirroring files on the Internet to your Google Drive or Telegram.

null 0 Jan 3, 2022
A multipurpose Telegram Bot written in Python for mirroring files on the Internet to Google Drive

Mirror Leech Bot Mirror Leech Bot is a multipurpose Telegram Bot written in Python for mirroring files on the Internet to our beloved Google Drive. Ba

null 1 Jan 1, 2022