Gdrive-python: A wrapping module in python of gdrive

Overview

gdrive-python

gdrive-python is a wrapping module in python of gdrive made by @prasmussen.

Installation

First of all to install the package you can execute:

pip install gdrive-python

Than you have to login inside your Google account with the command and than follow the instructions:

python -m gdrive about [options]

options:
  --version     Version of the gdrive script to download
  --os-name     Operating system name, by default it gets current os. Options: ['windows', 'linux', 'darwin']
  --arch        Architecture. Options: ['amd64', '386']
  --url         Url of the gdrive script

Example output:

vpippi$ python -m gdrive about
CMD: gdrive_folder/gdrive --config gdrive_folder about
Authentication needed
Go to the following url in your browser:
https://accounts.google.com/o/oauth2/auth?access_type=offline&client_id=############.apps.googleusercontent.com&redirect_uri=#########&response_type=code&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive&state=state

Enter verification code:
# paste here the code and press enter

FileNotFoundError

Somethimes it can happen that the command python -m gdrive about returns the FileNotFoundError

vpippi$ python -m gdrive about
CMD: gdrive_folder/gdrive --config gdrive_folder about
Traceback (most recent call last):
  ...
FileNotFoundError: [Errno 2] No such file or directory: 'gdrive_folder/gdrive'

In my case it happened because the current system architecture is amd64 but this version don't works in that system. You can avoid that problem by installing the 386 architecture.

python -m gdrive about --arch 386

Usage

import the gdrive classes in that way:

form gdrive import GDrive, GDrivePath, GDriveThread

GDrive

drive = GDrive()

If you whant you can also enable the printing commands setting:

drive.print_output = True

__init__(self, gdrive_path=None)

  • gdrive_path defines the gdrive script location path. If not specified it gets the default location gdrive_folder/gdrive

@staticmethod download_script(version='2.1.1', os_name=None, arch=None, url=None)

  • version is the version of the gdrive script to download
  • os_name is the operating system name, by default it gets current os. Options: ['windows', 'linux', 'darwin']
  • arch is the architecture. Options: ['amd64', '386']
  • url is the url of the gdrive script. If an url is provided the other fields are ignored.

The script download the specified version in the current directory (eg. gdrive_2.1.1_windows_amd64.tar.gz) and than extract the archive inside the directory gdrive_folder.

Returns None.

upload(self, filename, parent_id=None, parent=None, recursive=True, name=None, description=None, mime=None, share=None, timeout=None, chunksize=None, delete=False, thread=False)

  • filename path of the file/folder to upload
  • parent parent directory by name (eg. /path/foldername)
  • parent_id parent id, used to upload file to a specific directory, if specified parent folder is ignored.
  • recursive upload directory recursively
  • name filename
  • description file description
  • mime force mime type
  • share share file
  • timeout set timeout in seconds, use 0 for no timeout. Timeout is reached when no data is transferred in set amount of seconds, default: 300
  • chunksize set chunk size in bytes, default: 8388608
  • delete delete local file when upload is successful
  • thread defines if you want to upload the file in a separate thread (see the thread section)

While uploading a large file could be useful set print_output = True

Example:

>>> drive.print_output = True
>>> drive.upload('File99.mp4')
CMD: gdrive_folder\gdrive.exe --config gdrive_folder upload --recursive checkpoint_042.pth
Uploading checkpoint_042.pth
1.1 GB / 2.0 GB, Rate: 13.7 MB/s

thread

When thead=True the methods return a GDriveThread(threading.Thread) object.

Usage:

>>> thread = drive.upload('File99.mp4', thread=True)
>>> thread.start()
>>> # do whatever you want
>>> thread.join()

about(self)

Returns a dictionary that shows the account info.

Example:

>>> drive.about()
{
    'User': 'name username, [email protected]',
    'Used': '51 GB',
    'Free': '9 GB',
    'Total': '60 GB',
    'Max upload size': '60 GB',
}

logout(self)

The logout function delete the file gdrive_folder/token_v2.json which contains the google info. After this command the login is required again (see installation procedure).

list(self, max=30, querys=[], sort_order=None, name_width=0, absolute=False, bytes=None, parent=None)

Returns a list of dictionaries. Example:

>>> drive.list()
[
    {'Id': '######', 'Name': 'File01.mp4', 'Type': 'bin', 'Size': '196.1 MB', 'Created': '2022-01-13 19:42:00'},
    {'Id': '######', 'Name': 'File02.mp4', 'Type': 'bin', 'Size': '210.7 MB', 'Created': '2022-01-13 19:42:00'},
    {'Id': '######', 'Name': 'File03.mp4', 'Type': 'bin', 'Size': '197.5 MB', 'Created': '2022-01-13 19:42:00'},
    {'Id': '######', 'Name': 'File04.mp4', 'Type': 'bin', 'Size': '191.5 MB', 'Created': '2022-01-13 19:42:00'},
    {'Id': '######', 'Name': 'File05.mp4', 'Type': 'bin', 'Size': '176.1 MB', 'Created': '2022-01-13 19:42:00'},
    {'Id': '######', 'Name': 'File06.mp4', 'Type': 'bin', 'Size': '178.0 MB', 'Created': '2022-01-13 19:42:00'},
    ...
]

list_dirs(self, *args, **kwargs)

Same parameters as the list method.

Returns only the a list of dirs.

list_files(self, *args, **kwargs)

Same parameters as the list method.

Returns only the a list of files.

get_id(self, name)

  • name name of the file/folder that you want the id

Since Google Drive allows different files/directories with the same name, the function returns:

  • string if only one element is found
  • list of the ids if more than one file is returned
  • None if only no one element is found

Example:

>>> drive.get_id('File01.mp4')
'BWoSkGeDNbYqyumaRXtQvzgHndUMET'

>>> drive.get_id('File00.mp4')
['BWoSkGeDNbYqyumaRXtQvzgHndUMET', 'vzgHndUMETscKflCxpVOwhjrAiPLFI']

>>> drive.get_id('File99.mp4')
None

info(self, id)

  • id id of the file/folder

Returns a dictionary of all info values of the given element.

Owner
Vittorio Pippi
Vittorio Pippi
A template that help you getting started with Pycord.

A Pycord Template with some example! Getting Started: Clone this repository using git clone https://github.com/AungS8430/pycord-template.git If you ha

2 Feb 10, 2022
Nasdaq Cloud Data Service (NCDS) provides a modern and efficient method of delivery for realtime exchange data and other financial information. This repository provides an SDK for developing applications to access the NCDS.

Nasdaq Cloud Data Service (NCDS) Nasdaq Cloud Data Service (NCDS) provides a modern and efficient method of delivery for realtime exchange data and ot

Nasdaq 8 Dec 01, 2022
OKEX数字货币自动交易python语言SDK

okex-py OKEx数字货币自动交易python语言SDK (非官方) OKEx Cryptocurrency Exchange python SDK (Unofficial) 本项目基于V5 API 使用例子 Example import okex.v5.account_api as acco

43 Dec 01, 2022
MAASTA is a wrapper to create an Ansible inventory for MAAS instances that are provisioned by Terraform.

MAASTA is a wrapper to create an Ansible inventory for MAAS instances that are provisioned by Terraform.

Saeid Bostandoust 144 Dec 16, 2022
Create a roles overview page for all Ansible roles/playbooks in Gitlab

ansible-create-roles-overview Overview The script ./create_roles_overview.py queries a Gitlab API for Ansible roles and playbooks. It will iterate ove

2 Oct 11, 2021
Simple PoC script that allows you to exploit telegram's "send with timer" feature by saving any media sent with this functionality.

Simple PoC script that allows you to exploit telegram's "send with timer" feature by saving any media sent with this functionality.

Matteo 52 Nov 29, 2022
An API wrapper around Discord API.

NeoCord This project is work in progress not for production use. An asynchronous API wrapper around Discord API written in Python. Features Modern API

Izhar Ahmad 14 Jan 03, 2022
Brute Force Attack On Facebook Accounts

Brute Force Attack On Facebook Accounts For Install: pkg install update && pkg upgrade -y pkg install python pip install requests pip install mechani

MK X Shaon 1 Oct 30, 2021
Python Markov Chain chatbot running on Telegram

Hanasubot Hanasubot (Japanese 話すボット, talking bot) is a Python chatbot running on Telegram. The bot is based on Markov Chains so it can learn your word

12 Dec 27, 2022
A twitter multi-tool for OSINT on twitter accounts.

TwitterCheckr A twitter multi-tool for OSINT on twitter accounts. Infomation TwitterCheckr also known as TCheckr is multi-tool for OSINT on twitter a

IRIS 16 Dec 23, 2022
This project is a basic login system in terminal for Discord

Welcome to Discord Login System(Terminal) 👋 This project is a basic login system in terminal for Discord Author 👤 arukovic Github: @SONIC-CODEZ Show

SONIC-CODEZ 2 Feb 11, 2022
Python wrapper for the Sportradar APIs ⚽️🏈

Sportradar APIs This is a Python wrapper for the sports APIs provided by Sportradar. You'll need to sign up for an API key to use the service. Sportra

John W. Miller 39 Jan 01, 2023
IdeasBot - Funny telegram bot to generate ideas for a project

Repository of PIdeas_bot About Funny telegram bot for generating projects ideas.

Just Koala 5 Oct 16, 2022
A Bot To Find Telegram User ID Easily

Telegram ID Bot 🤖 A Bot To Find Telegram User ID Easily Made with Python3 (C) @BXBotz Copyright permission under MIT License License - https://githu

MuFaz-TG 6 Nov 21, 2022
Discord bot that shows valorant your daily store by using the Ingame API

Valorant store checker - Discord Bot Discord bot that shows valorant your daily store by using the Ingame API. written using Python and the Pycord lib

STACIA 226 Jan 02, 2023
通过GitHub的actions 自动采集节点 生成订阅信息

VmessActions 通过GitHub的actions 自动采集节点 自动生成订阅信息 订阅内容自动更新再仓库的 clash.yml 和 v2ray.txt 中 然后PC端/手机端根据自己的软件支持的格式,订阅对应的链接即可

skywolf627 372 Jan 04, 2023
Mixcloud API wrapper for Python and Async IO

aiomixcloud Mixcloud API wrapper for Python and Async IO aiomixcloud is a wrapper library for the HTTP API of Mixcloud. It supports asynchronous opera

Aristotelis Mikropoulos 26 Dec 31, 2022
TgMusicBot is a telegram userbot for playing songs in telegram voice calls based on Pyrogram and PyTgCalls.

TgMusicBot [Stable] TgMusicBot is a telegram userbot for playing songs in telegram voice calls based on Pyrogram and PyTgCalls. Commands !start / !hel

Kürşad 21 Dec 25, 2022
A clean, easy to scale discord bot template

A clean, easy to scale discord bot template. Develope using nextcord library and can be use with any other discord.py forked library.

めがねこ 3 Mar 03, 2022
Tweet stream in OBS browser source

Tweetron TweetronはOBSブラウザーソースを使用してツイートを画面上に表示するツールソフトです Windowsのみ対応 (Windows10動作確認済) ダウンロード こちらから最新版をダウンロードしてください (現在ベータテスト版を配布しています) Download ver0.0.

Cube 0 Apr 05, 2022